Fix warnings in manual/examples/search.c
Paul Eggert
eggert@cs.ucla.edu
Wed May 16 17:37:00 GMT 2012
On 05/16/2012 04:24 AM, Andreas Jaeger wrote:
> -critter_cmp (const struct critter *c1, const struct critter *c2)
> +critter_cmp (const void *v1, const void *v2)
> {
> + struct critter *c1 = (struct critter *)v1;
> + struct critter *c2 = (struct critter *)v2;
> +
> return strcmp (c1->name, c2->name);
Please redo it so that no casts are needed, as pointer casts
are big hammers that shouldn't be used unless necessary.
Like this:
int
critter_cmp (const void *v1, const void *v2)
{
const struct critter *c1 = v1;
const struct critter *c2 = v2;
return strcmp (c1->name, c2->name);
}
Similarly for the other two examples.
More information about the Libc-alpha
mailing list