This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: [PATCH] BZ #14083 Fix strspn warning with -Wconversion


On Wed, May 9, 2012 at 9:18 AM, Andreas Jaeger <aj@suse.de> wrote:
>
> This simple program:
> #include <string.h>
> #include <stdio.h>
> #include <stdlib.h>
>
>
> int main() {
> ?size_t x;
> ?x = strspn("hello","h");
> ?printf("%zd\n", x);
> ?return 0;
> }
>
> gives a warning with -Wconversion:
> $ gcc -Wconversion -O t.c
> t.c: In function ‘main’:
> t.c:8:7: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
>
> Fixed with the appended patch, tested on Linux/x86-64. Ok to commit?
>
> For details see also
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53277
>
> Andreas
>
> 2012-05-09 ?Andreas Jaeger ?<aj@suse.de>
>
> ? ? ? ?[BZ #14083]
> ? ? ? ?* string/bits/string2.h (strspn) [__GNUC_PREREQ(3, 2) &&
> ? ? ? ?!_HAVE_STRING_ARCH_strspn]: Cast zero to size_t to avoid
> ? ? ? ?-Wconversion warning.
> ? ? ? ?(strspn) [!__GNUC_PREREQ(3, 2) && !_HAVE_STRING_ARCH_strspn]:
> ? ? ? ?Likewise.

This looks good to me.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]