[ext4:unicode 4/10] fs/unicode/utf8-core.c:90 utf8_casefold() warn: impossible condition '(dest[nlen] == -1) => (0-255 == (-1))'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git unicode
head:   c0ae3a05c89c497446d6e208b68623993b5afc3c
commit: 45568caefa60a247ce9ecee3f4a57d1f81f5dd0e [4/10] unicode: implement higher level API for string handling

smatch warnings:
fs/unicode/utf8-core.c:90 utf8_casefold() warn: impossible condition '(dest[nlen] == -1) => (0-255 == (-1))'
fs/unicode/utf8-core.c:112 utf8_normalize() warn: impossible condition '(dest[nlen] == -1) => (0-255 == (-1))'

# https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git/commit/?id=45568caefa60a247ce9ecee3f4a57d1f81f5dd0e
git remote add ext4 https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git
git remote update ext4
git checkout 45568caefa60a247ce9ecee3f4a57d1f81f5dd0e
vim +90 fs/unicode/utf8-core.c

45568cae Gabriel Krisman Bertazi 2019-03-18   75  
45568cae Gabriel Krisman Bertazi 2019-03-18   76  int utf8_casefold(const struct unicode_map *um, const struct qstr *str,
45568cae Gabriel Krisman Bertazi 2019-03-18   77  		  unsigned char *dest, size_t dlen)
45568cae Gabriel Krisman Bertazi 2019-03-18   78  {
45568cae Gabriel Krisman Bertazi 2019-03-18   79  	const struct utf8data *data = utf8nfdicf(um->version);
45568cae Gabriel Krisman Bertazi 2019-03-18   80  	struct utf8cursor cur;
45568cae Gabriel Krisman Bertazi 2019-03-18   81  	size_t nlen = 0;
45568cae Gabriel Krisman Bertazi 2019-03-18   82  
45568cae Gabriel Krisman Bertazi 2019-03-18   83  	if (utf8ncursor(&cur, data, str->name, str->len) < 0)
45568cae Gabriel Krisman Bertazi 2019-03-18   84  		return -EINVAL;
45568cae Gabriel Krisman Bertazi 2019-03-18   85  
45568cae Gabriel Krisman Bertazi 2019-03-18   86  	for (nlen = 0; nlen < dlen; nlen++) {
45568cae Gabriel Krisman Bertazi 2019-03-18   87  		dest[nlen] = utf8byte(&cur);
45568cae Gabriel Krisman Bertazi 2019-03-18   88  		if (!dest[nlen])
45568cae Gabriel Krisman Bertazi 2019-03-18   89  			return nlen;
45568cae Gabriel Krisman Bertazi 2019-03-18  @90  		if (dest[nlen] == -1)
                                                                    ^^^^^^^^^^^^^^^^

45568cae Gabriel Krisman Bertazi 2019-03-18   91  			break;
45568cae Gabriel Krisman Bertazi 2019-03-18   92  	}
45568cae Gabriel Krisman Bertazi 2019-03-18   93  	return -EINVAL;
45568cae Gabriel Krisman Bertazi 2019-03-18   94  }
45568cae Gabriel Krisman Bertazi 2019-03-18   95  
45568cae Gabriel Krisman Bertazi 2019-03-18   96  EXPORT_SYMBOL(utf8_casefold);
45568cae Gabriel Krisman Bertazi 2019-03-18   97  
45568cae Gabriel Krisman Bertazi 2019-03-18   98  int utf8_normalize(const struct unicode_map *um, const struct qstr *str,
45568cae Gabriel Krisman Bertazi 2019-03-18   99  		   unsigned char *dest, size_t dlen)
45568cae Gabriel Krisman Bertazi 2019-03-18  100  {
45568cae Gabriel Krisman Bertazi 2019-03-18  101  	const struct utf8data *data = utf8nfdi(um->version);
45568cae Gabriel Krisman Bertazi 2019-03-18  102  	struct utf8cursor cur;
45568cae Gabriel Krisman Bertazi 2019-03-18  103  	ssize_t nlen = 0;
45568cae Gabriel Krisman Bertazi 2019-03-18  104  
45568cae Gabriel Krisman Bertazi 2019-03-18  105  	if (utf8ncursor(&cur, data, str->name, str->len) < 0)
45568cae Gabriel Krisman Bertazi 2019-03-18  106  		return -EINVAL;
45568cae Gabriel Krisman Bertazi 2019-03-18  107  
45568cae Gabriel Krisman Bertazi 2019-03-18  108  	for (nlen = 0; nlen < dlen; nlen++) {
45568cae Gabriel Krisman Bertazi 2019-03-18  109  		dest[nlen] = utf8byte(&cur);
45568cae Gabriel Krisman Bertazi 2019-03-18  110  		if (!dest[nlen])
45568cae Gabriel Krisman Bertazi 2019-03-18  111  			return nlen;
45568cae Gabriel Krisman Bertazi 2019-03-18 @112  		if (dest[nlen] == -1)
                                                                    ^^^^^^^^^^^^^^^^

45568cae Gabriel Krisman Bertazi 2019-03-18  113  			break;
45568cae Gabriel Krisman Bertazi 2019-03-18  114  	}
45568cae Gabriel Krisman Bertazi 2019-03-18  115  	return -EINVAL;
45568cae Gabriel Krisman Bertazi 2019-03-18  116  }
45568cae Gabriel Krisman Bertazi 2019-03-18  117  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux