{"thread":{"id":"4560","subject":"[PATCH 4/7] Cast pointers to `void *' when used in a format.","startedAt":"2006-06-18T15:18:05Z","lastAt":"2006-06-18T15:18:07Z","messageCount":3,"participants":["Florian Forster"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"22029","messageId":"11506438892551-git-send-email-octo@verplant.org","threadId":"4560","inReplyTo":"11506438893796-git-send-email-octo@verplant.org","subject":"[PATCH 3/7] Don't instantiate structures with FAMs.","fromName":"Florian Forster","fromEmail":"octo@verplant.org","sentAt":"2006-06-18T15:18:05Z","receivedAt":"2006-06-18T15:18:05Z","isPatch":true,"sender":{"key":"octo@verplant.org","avatar":null},"body":"Since structures with `flexible array members' are an incomplete datatype ANSI\nC99 forbids creating instances of them. This patch removes such an instance\nfrom `diff-lib.c' and replaces it with a pointer to a `struct\ncombine_diff_path'. Since all neccessary memory is allocated at once the number\nof calls to `xmalloc' is not increased.\n\nSigned-off-by: Florian Forster <octo@verplant.org>\n\n\n---\n\n diff-lib.c |   41 ++++++++++++++++++++++-------------------\n 1 files changed, 22 insertions(+), 19 deletions(-)\n\nc163a36f0bd0e07ffb9ee7d4bfb22f1cbb38eef8\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 2183b41..fdc1173 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -34,21 +34,23 @@ int run_diff_files(struct rev_info *revs\n \t\t\tcontinue;\n \n \t\tif (ce_stage(ce)) {\n-\t\t\tstruct {\n-\t\t\t\tstruct combine_diff_path p;\n-\t\t\t\tstruct combine_diff_parent filler[5];\n-\t\t\t} combine;\n+\t\t\tstruct combine_diff_path *dpath;\n \t\t\tint num_compare_stages = 0;\n+\t\t\tsize_t path_len;\n \n-\t\t\tcombine.p.next = NULL;\n-\t\t\tcombine.p.len = ce_namelen(ce);\n-\t\t\tcombine.p.path = xmalloc(combine.p.len + 1);\n-\t\t\tmemcpy(combine.p.path, ce->name, combine.p.len);\n-\t\t\tcombine.p.path[combine.p.len] = 0;\n-\t\t\tcombine.p.mode = 0;\n-\t\t\tmemset(combine.p.sha1, 0, 20);\n-\t\t\tmemset(&combine.p.parent[0], 0,\n-\t\t\t       sizeof(combine.filler));\n+\t\t\tpath_len = ce_namelen(ce);\n+\n+\t\t\tdpath = xmalloc (combine_diff_path_size (5, path_len));\n+\t\t\tdpath->path = (char *) &(dpath->parent[5]);\n+\n+\t\t\tdpath->next = NULL;\n+\t\t\tdpath->len = path_len;\n+\t\t\tmemcpy(dpath->path, ce->name, path_len);\n+\t\t\tdpath->path[path_len] = '\\0';\n+\t\t\tdpath->mode = 0;\n+\t\t\tmemset(dpath->sha1, 0, 20);\n+\t\t\tmemset(&(dpath->parent[0]), 0,\n+\t\t\t\t\tsizeof(struct combine_diff_parent)*5);\n \n \t\t\twhile (i < entries) {\n \t\t\t\tstruct cache_entry *nce = active_cache[i];\n@@ -64,11 +66,11 @@ int run_diff_files(struct rev_info *revs\n \t\t\t\tif (2 <= stage) {\n \t\t\t\t\tint mode = ntohl(nce->ce_mode);\n \t\t\t\t\tnum_compare_stages++;\n-\t\t\t\t\tmemcpy(combine.p.parent[stage-2].sha1,\n+\t\t\t\t\tmemcpy(dpath->parent[stage-2].sha1,\n \t\t\t\t\t       nce->sha1, 20);\n-\t\t\t\t\tcombine.p.parent[stage-2].mode =\n+\t\t\t\t\tdpath->parent[stage-2].mode =\n \t\t\t\t\t\tcanon_mode(mode);\n-\t\t\t\t\tcombine.p.parent[stage-2].status =\n+\t\t\t\t\tdpath->parent[stage-2].status =\n \t\t\t\t\t\tDIFF_STATUS_MODIFIED;\n \t\t\t\t}\n \n@@ -83,13 +85,14 @@ int run_diff_files(struct rev_info *revs\n \t\t\ti--;\n \n \t\t\tif (revs->combine_merges && num_compare_stages == 2) {\n-\t\t\t\tshow_combined_diff(&combine.p, 2,\n+\t\t\t\tshow_combined_diff(dpath, 2,\n \t\t\t\t\t\t   revs->dense_combined_merges,\n \t\t\t\t\t\t   revs);\n-\t\t\t\tfree(combine.p.path);\n+\t\t\t\tfree(dpath);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tfree(combine.p.path);\n+\t\t\tfree(dpath);\n+\t\t\tdpath = NULL;\n \n \t\t\t/*\n \t\t\t * Show the diff for the 'ce' if we found the one\n-- \n1.3.3\n"},{"id":"22022","messageId":"11506438893167-git-send-email-octo@verplant.org","threadId":"4560","inReplyTo":"11506438892551-git-send-email-octo@verplant.org","subject":"[PATCH 4/7] Cast pointers to `void *' when used in a format.","fromName":"Florian Forster","fromEmail":"octo@verplant.org","sentAt":"2006-06-18T15:18:06Z","receivedAt":"2006-06-18T15:18:06Z","isPatch":true,"sender":{"key":"octo@verplant.org","avatar":null},"body":"ANSI C99 requires void-pointers when using the `%p' format. This patch adds the\nneccessary cast in `blame.c'.\n\nSigned-off-by: Florian Forster <octo@verplant.org>\n\n\n---\n\n blame.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\n372bb52dd567d39c3e64919e100ae9bd8af603ca\ndiff --git a/blame.c b/blame.c\nindex 25d3bcf..51eab2e 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -301,9 +301,9 @@ static void fill_line_map(struct commit \n \t\t\t\tif (DEBUG)\n \t\t\t\t\tprintf(\"map: i1: %d %d %p i2: %d %d %p\\n\",\n \t\t\t\t\t       i1, map[i1],\n-\t\t\t\t\t       i1 != -1 ? blame_lines[map[i1]] : NULL,\n+\t\t\t\t\t       (void *) (i1 != -1 ? blame_lines[map[i1]] : NULL),\n \t\t\t\t\t       i2, map2[i2],\n-\t\t\t\t\t       i2 != -1 ? blame_lines[map2[i2]] : NULL);\n+\t\t\t\t\t       (void *) (i2 != -1 ? blame_lines[map2[i2]] : NULL));\n \t\t\t\tif (map2[i2] != -1 &&\n \t\t\t\t    blame_lines[map[i1]] &&\n \t\t\t\t    !blame_lines[map2[i2]])\n-- \n1.3.3\n"},{"id":"22024","messageId":"11506438893544-git-send-email-octo@verplant.org","threadId":"4560","inReplyTo":"11506438893167-git-send-email-octo@verplant.org","subject":"[PATCH 5/7] Don't use empty structure initializers.","fromName":"Florian Forster","fromEmail":"octo@verplant.org","sentAt":"2006-06-18T15:18:07Z","receivedAt":"2006-06-18T15:18:07Z","isPatch":true,"sender":{"key":"octo@verplant.org","avatar":null},"body":"Empty initializers for structures are not allowed in ANSI C99. This patch\nremoves such an initializer from `builtin-read-tree.c'. Since the struct was\nstatic (and is therefore implicitely initialized to zero anyway) it wasn't\nactually needed.\n\nSigned-off-by: Florian Forster <octo@verplant.org>\n\n\n---\n\n builtin-read-tree.c |    3 +--\n 1 files changed, 1 insertions(+), 2 deletions(-)\n\n91df4330d35f1f1670dd04af0a14f1ca84a72b2b\ndiff --git a/builtin-read-tree.c b/builtin-read-tree.c\nindex bb50fbd..fdd6706 100644\n--- a/builtin-read-tree.c\n+++ b/builtin-read-tree.c\n@@ -30,8 +30,7 @@ static int merge_size = 0;\n \n static struct object_list *trees = NULL;\n \n-static struct cache_entry df_conflict_entry = {\n-};\n+static struct cache_entry df_conflict_entry;\n \n struct tree_entry_list {\n \tstruct tree_entry_list *next;\n-- \n1.3.3\n"}]}