[SLOF] [PATCH] libc: Remove dead code in print_itoa()
Alexey Kardashevskiy
aik at ozlabs.ru
Mon Nov 30 16:18:26 AEDT 2015
On 11/28/2015 05:00 AM, Thomas Huth wrote:
> When compiling SLOF with "-Wextra", GCC complains about this:
>
> libc/stdio/vsnprintf.c: In function ‘print_itoa’:
> lib/libc/stdio/vsnprintf.c:33:2: warning: comparison of unsigned
> expression < 0 is always false [-Wtype-limits]
> if(value < 0) {
> ^
>
> When looking more closely at the code, it seems like this is not
> only dead code, but even wrong code, since the sign is already
> handled in print_format()! So let's simply remove that dead code.
>
> Signed-off-by: Thomas Huth <thuth at redhat.com>
Thanks, applied.
> ---
> lib/libc/stdio/vsnprintf.c | 11 -----------
> 1 file changed, 11 deletions(-)
>
> diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c
> index e78fb3d..47ba34d 100644
> --- a/lib/libc/stdio/vsnprintf.c
> +++ b/lib/libc/stdio/vsnprintf.c
> @@ -25,22 +25,11 @@ static int
> print_itoa(char **buffer,unsigned long value, unsigned short int base)
> {
> const char zeichen[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
> - static char sign = 0;
>
> if(base <= 2 || base > 16)
> return 0;
>
> - if(value < 0) {
> - sign = 1;
> - value *= -1;
> - }
> -
> if(value < base) {
> - if(sign) {
> - **buffer = '-';
> - *buffer += 1;
> - sign = 0;
> - }
> **buffer = zeichen[value];
> *buffer += 1;
> } else {
>
--
Alexey
More information about the SLOF
mailing list