]> git.ozlabs.org Git - petitboot/commitdiff
lib/fold: fix warning with -DDEBUG
authorJeremy Kerr <jk@ozlabs.org>
Fri, 28 Nov 2014 03:42:06 +0000 (11:42 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 1 Dec 2014 03:53:23 +0000 (11:53 +0800)
When compiling the fold code with DEBUG defined, we get:

../lib/fold/fold.c: In function 'fold_text':
../lib/fold/fold.c:37:3: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
   assert(bytes >= 0);
   ^

We should be comparing with != (size_t)-1, not >= 0

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/fold/fold.c

index 8bf133c8b34a9e0e37762eda8122dce4ac210141..fd23b066f3e58b49c107176d5957c8eaae68b845 100644 (file)
@@ -34,7 +34,7 @@ void fold_text(const char *text,
 
                bytes = mbrtowc(&wc, end, len - (end - text), &ps);
 
-               assert(bytes >= 0);
+               assert(bytes != (size_t)-1);
 
                /* we'll get a zero size for the nul terminator */
                if (!bytes) {