Re: [PATCH] Fix git to be (more) ANSI C99 compliant.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Sun, 18 Jun 2006, Florian Forster wrote:
>
> Using this patch I was able to build git with
> $ make CFLAGS="-Wall -Werror -ansi -pedantic -std=c99 -D_XOPEN_SOURCE=500 -D_BSD_SOURCE"

"-ansi -pedantic" is really not useful.

> While most of this patch fixes void-pointer arithmetic

This one I disagree with. Doing arithmetic on "void *" is _really_ useful, 
and I think most compilers end up supporting it either to be compatible 
with gcc, or just because it's hard to not do it.

It makes code a _lot_ cleaner.

In general, explicit casts are a sign of bad programming, and "void *" is 
there exactly to avoid it. And doing arithmetic on pointers is useful and 
fairly common, and if you accept void-pointer arithmetic, it avoids a lot 
of ugly and useless casts.

> @@ -301,9 +301,9 @@ static void fill_line_map(struct commit 
>  				if (DEBUG)
>  					printf("map: i1: %d %d %p i2: %d %d %p\n",
>  					       i1, map[i1],
> -					       i1 != -1 ? blame_lines[map[i1]] : NULL,
> +					       (void *) (i1 != -1 ? blame_lines[map[i1]] : NULL),
>  					       i2, map2[i2],
> -					       i2 != -1 ? blame_lines[map2[i2]] : NULL);
> +					       (void *) (i2 != -1 ? blame_lines[map2[i2]] : NULL));

Gaah. This is another case of casting that I'm sure is technically 
correct, but that I wonder whether there is any machine that actually 
cares..

But at least in that case I suspect the cast _may_ be required due to 
different pointer representations.

		Linus
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]