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: Fix warnings in manual/examples/search.c


On Wed, May 16, 2012 at 7:24 AM, Andreas Jaeger <aj@suse.de> wrote:
>
> Our example produces quite some warnings:
>
> gcc -Wall -c search.c
> search.c: In function ‘find_critter’:
> search.c:83:7: warning: passing argument 5 of ‘bsearch’ from incompatible pointer type [enabled by default]
> In file included from search.c:18:0:
> /usr/include/stdlib.h:755:14: note: expected ‘__compar_fn_t’ but argument is of type ‘int (*)(const struct critter *, const struct critter *)’
> search.c: In function ‘main’:
> search.c:102:41: warning: passing argument 4 of ‘qsort’ from incompatible pointer type [enabled by default]
> In file included from search.c:18:0:
> /usr/include/stdlib.h:761:13: note: expected ‘__compar_fn_t’ but argument is of type ‘int (*)(const struct critter *, const struct critter *)’
>
> I propose the following change that does not give any warnings.
>
> Ok to commit?
>
> Andreas
>
> 2012-05-16 ?Andreas Jaeger ?<aj@suse.de>
>
> ? ? ? ?* manual/examples/search.c (critter_cmp): Change signature to
> ? ? ? ?avoid warnings.
> ? ? ? ?* manual/string.texi (Collation Functions): Likewise.

This looks good to me. Every example of bsearch, or qsort always uses
`const void*' arguments or rather they should always have a signature
of `int (*func)(const void *, const void *)'.

Cheers,
Carlos.


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