From: Junio C Hamano <junkio@cox.net>
To: Florian Forster <octo@verplant.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Fix git to be (more) ANSI C99 compliant.
Date: Sun, 18 Jun 2006 01:29:53 -0700 [thread overview]
Message-ID: <7vac8a50ji.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <1150609831500-git-send-email-octo@verplant.org> (Florian Forster's message of "Sun, 18 Jun 2006 07:50:31 +0200")
Florian Forster <octo@verplant.org> writes:
> While most of this patch fixes void-pointer arithmetic and is therefore
> trivial, I had to change the use of a struct with FAMs in `diff-lib.c'. Since
> this is the first time I encountered FAMs it'd probably be a good idea if
> someone who knows would take a look at that.
Thanks. I am very tempted to apply it, but I started to wonder
that in some places it might make sense to convert void* to
char* instead of casting. Undecided.
> diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
> index f6310b9..646322d 100644
> --- a/builtin-tar-tree.c
> +++ b/builtin-tar-tree.c
> @@ -34,7 +34,7 @@ static void reliable_write(void *buf, un
> die("git-tar-tree: disk full?");
> }
> size -= ret;
> - buf += ret;
> + buf = (char *) buf + ret;
Please do not add the extra whitespace to align "=".
> @@ -244,14 +244,14 @@ static void convert_date(void *buffer, u
> // "tree <sha1>\n"
> memcpy(new + newlen, buffer, 46);
> newlen += 46;
> - buffer += 46;
> + buffer = (char *) buffer + 46;
> size -= 46;
>
> // "parent <sha1>\n"
> while (!memcmp(buffer, "parent ", 7)) {
> memcpy(new + newlen, buffer, 48);
> newlen += 48;
> - buffer += 48;
> + buffer = (char *) buffer + 48;
> size -= 48;
> }
>
> @@ -275,11 +275,11 @@ static void convert_commit(void *buffer,
>
> if (memcmp(buffer, "tree ", 5))
> die("Bad commit '%s'", (char*) buffer);
> - convert_ascii_sha1(buffer+5);
> - buffer += 46; /* "tree " + "hex sha1" + "\n" */
> + convert_ascii_sha1((char *) buffer + 5);
> + buffer = (char *) buffer + 46; /* "tree " + "hex sha1" + "\n" */
> while (!memcmp(buffer, "parent ", 7)) {
> - convert_ascii_sha1(buffer+7);
> - buffer += 48;
> + convert_ascii_sha1((char *) buffer + 7);
> + buffer = (char *) buffer + 48;
> }
> convert_date(orig_buffer, orig_size, result_sha1);
> }
Hmmmmmmm. Now I start to wonder if changing the type of "void *buffer"
to "char *buffer" is cleaner.
> diff --git a/diff-delta.c b/diff-delta.c
> index 25a798d..8b9172a 100644
> --- a/diff-delta.c
> +++ b/diff-delta.c
> @@ -22,6 +22,7 @@ #include <stdlib.h>
> #include <string.h>
> #include "delta.h"
>
> +#include "git-compat-util.h"
>
> /* maximum hash entry list for the same hash bucket */
> #define HASH_LIMIT 64
> @@ -131,7 +132,7 @@ struct delta_index {
> const void *src_buf;
> unsigned long src_size;
> unsigned int hash_mask;
> - struct index_entry *hash[0];
> + struct index_entry *hash[FLEX_ARRAY];
> };
Good -- I missed this when we did FLEX_ARRAY. Thanks.
> diff --git a/diff-lib.c b/diff-lib.c
> index 2183b41..fdc1173 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -34,21 +34,23 @@ int run_diff_files(struct rev_info *revs
> continue;
>
> if (ce_stage(ce)) {
> - struct {
> - struct combine_diff_path p;
> - struct combine_diff_parent filler[5];
> - } combine;
I admit this part was ugly. The new code does not do any extra
allocations and matches the other use of "struct combine_diff_path"
more closely. Good change.
> @@ -1136,13 +1136,14 @@ int fetch(unsigned char *sha1)
>
> static inline int needs_quote(int ch)
> {
> - switch (ch) {
> - case '/': case '-': case '.':
> - case 'A'...'Z': case 'a'...'z': case '0'...'9':
> + if (((ch >= 'A') && (ch <= 'Z'))
> + || ((ch >= 'a') && (ch <= 'z'))
> + || ((ch >= '0') && (ch <= '9'))
> + || (ch == '/')
> + || (ch == '-')
> + || (ch == '.'))
> return 0;
> - default:
> - return 1;
> - }
> + return 1;
> }
Ugh. Delight of standard compliance X-<.
> diff --git a/http-push.c b/http-push.c
> index 2d9441e..0684e46 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -1077,13 +1077,14 @@ static int fetch_indices(void)
>
> static inline int needs_quote(int ch)
Hmph. Thanks for noticing the duplicated code; maybe move it to
cache.h perhaps?
next prev parent reply other threads:[~2006-06-18 8:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-18 5:50 [PATCH] Fix git to be (more) ANSI C99 compliant Florian Forster
2006-06-18 8:07 ` Timo Hirvonen
2006-06-18 8:14 ` Thomas Glanzmann
2006-06-18 8:21 ` Florian Forster
2006-06-18 8:43 ` Timo Hirvonen
2006-06-18 8:26 ` Rene Scharfe
2006-06-18 8:35 ` Florian Forster
2006-06-18 15:18 ` [PATCH 0/7] Improve ANSI C99 compliance Florian Forster
2006-06-18 15:18 ` [PATCH 1/7] Remove ranges from switch statements Florian Forster
2006-06-18 15:18 ` [PATCH 2/7] Initialize FAMs using `FLEX_ARRAY' Florian Forster
2006-06-18 15:18 ` [PATCH 3/7] Don't instantiate structures with FAMs Florian Forster
2006-06-18 15:18 ` [PATCH 4/7] Cast pointers to `void *' when used in a format Florian Forster
2006-06-18 15:18 ` [PATCH 5/7] Don't use empty structure initializers Florian Forster
2006-06-18 15:18 ` [PATCH 6/7] Change types used in bitfields to be `int's Florian Forster
2006-06-18 15:18 ` [PATCH 7/7] Remove all void-pointer arithmetic Florian Forster
2006-06-18 21:07 ` [PATCH 1/7] Remove ranges from switch statements Junio C Hamano
2006-06-18 21:24 ` Timo Hirvonen
2006-06-18 8:29 ` Junio C Hamano [this message]
2006-06-18 16:50 ` [PATCH] Fix git to be (more) ANSI C99 compliant Linus Torvalds
2006-06-19 21:21 ` Florian Forster
2006-06-20 1:59 ` Junio C Hamano
2006-06-20 8:16 ` Rene Scharfe
2006-06-20 8:58 ` Junio C Hamano
2006-06-21 11:15 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vac8a50ji.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=octo@verplant.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.