This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi there, As shown in attached patch, the (p!=NULL) means we found target character within width 'prec'. So the 'size' is always smaller than the width 'prec', thus the inner if statement is unnecessary. Is it ok? BR, Terry newlib/ChangeLog 2014-10-29 Terry Guo <terry.guo@arm.com> * libc/stdio/vfprintf.c (_VFPRINTF_R): Remove unnecessary comparison. diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index dd9c22a..fbca32e 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -1516,16 +1516,14 @@ string: if (prec >= 0) { /* * can't use strlen; can only look for the - * NUL in the first `prec' characters, and + * NULL in the first `prec' characters, and * strlen () will go further. */ char *p = memchr (cp, 0, prec); - if (p != NULL) { + if (p != NULL) size = p - cp; - if (size > prec) - size = prec; - } else + else size = prec; } else size = strlen (cp);
Attachment:
remove-unnecessary-comparison-v1.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |