linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [ext4:unicode 4/10] fs/unicode/utf8-core.c:90 utf8_casefold() warn: impossible condition '(dest[nlen] == -1) => (0-255 == (-1))'
@ 2019-04-08  6:29 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2019-04-08  6:29 UTC (permalink / raw)
  To: kbuild, Gabriel Krisman Bertazi; +Cc: kbuild-all, linux-ext4, Theodore Ts'o

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-08  6:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-08  6:29 [ext4:unicode 4/10] fs/unicode/utf8-core.c:90 utf8_casefold() warn: impossible condition '(dest[nlen] == -1) => (0-255 == (-1))' Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).