{"thread":{"id":"26972","subject":"[PATCH] sparse: Fix errors and silence warnings","startedAt":"2011-04-03T07:06:54Z","lastAt":"2011-04-03T08:17:46Z","messageCount":2,"participants":["Stephen Boyd","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"164983","messageId":"1301814414-11368-1-git-send-email-bebarino@gmail.com","threadId":"26972","inReplyTo":null,"subject":"[PATCH] sparse: Fix errors and silence warnings","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2011-04-03T07:06:54Z","receivedAt":"2011-04-03T07:06:54Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":" * load_file() returns a void pointer but is using 0 for the return\n   value\n\n * builtin/receive-pack.c forgot to include builtin.h\n\n * packet_trace_prefix can be marked static\n\n * ll_merge takes a pointer for its last argument, not an int\n\n * crc32 expects a pointer as the second argument but Z_NULL is defined\n   to be 0 (see 38f4d13 sparse fix: Using plain integer as NULL pointer,\n   2006-11-18 for more info)\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n builtin/grep.c         |    6 +++---\n builtin/index-pack.c   |    2 +-\n builtin/receive-pack.c |    2 +-\n csum-file.c            |    2 +-\n pack-check.c           |    2 +-\n pkt-line.c             |    2 +-\n rerere.c               |    2 +-\n 7 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 891e5ea..10a1f65 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -414,10 +414,10 @@ static void *load_file(const char *filename, size_t *sz)\n \terr_ret:\n \t\tif (errno != ENOENT)\n \t\t\terror(_(\"'%s': %s\"), filename, strerror(errno));\n-\t\treturn 0;\n+\t\treturn NULL;\n \t}\n \tif (!S_ISREG(st.st_mode))\n-\t\treturn 0;\n+\t\treturn NULL;\n \t*sz = xsize_t(st.st_size);\n \ti = open(filename, O_RDONLY);\n \tif (i < 0)\n@@ -427,7 +427,7 @@ static void *load_file(const char *filename, size_t *sz)\n \t\terror(_(\"'%s': short read %s\"), filename, strerror(errno));\n \t\tclose(i);\n \t\tfree(data);\n-\t\treturn 0;\n+\t\treturn NULL;\n \t}\n \tclose(i);\n \tdata[*sz] = 0;\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 5a67c81..31f001f 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -294,7 +294,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_\n \tvoid *data;\n \n \tobj->idx.offset = consumed_bytes;\n-\tinput_crc32 = crc32(0, Z_NULL, 0);\n+\tinput_crc32 = crc32(0, NULL, 0);\n \n \tp = fill(1);\n \tc = *p;\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 27050e7..e1ba4dc 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"pack.h\"\n #include \"refs.h\"\n #include \"pkt-line.h\"\ndiff --git a/csum-file.c b/csum-file.c\nindex 4d50cc5..be49d5f 100644\n--- a/csum-file.c\n+++ b/csum-file.c\n@@ -116,7 +116,7 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp\n \n void crc32_begin(struct sha1file *f)\n {\n-\tf->crc32 = crc32(0, Z_NULL, 0);\n+\tf->crc32 = crc32(0, NULL, 0);\n \tf->do_crc = 1;\n }\n \ndiff --git a/pack-check.c b/pack-check.c\nindex c3bf21d..a1a5216 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -23,7 +23,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,\n \t\t   off_t offset, off_t len, unsigned int nr)\n {\n \tconst uint32_t *index_crc;\n-\tuint32_t data_crc = crc32(0, Z_NULL, 0);\n+\tuint32_t data_crc = crc32(0, NULL, 0);\n \n \tdo {\n \t\tunsigned int avail;\ndiff --git a/pkt-line.c b/pkt-line.c\nindex cd1bd26..5a04984 100644\n--- a/pkt-line.c\n+++ b/pkt-line.c\n@@ -1,7 +1,7 @@\n #include \"cache.h\"\n #include \"pkt-line.h\"\n \n-const char *packet_trace_prefix = \"git\";\n+static const char *packet_trace_prefix = \"git\";\n static const char trace_key[] = \"GIT_TRACE_PACKET\";\n \n void packet_trace_identity(const char *prog)\ndiff --git a/rerere.c b/rerere.c\nindex 3d00a71..22dfc84 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -438,7 +438,7 @@ static int merge(const char *name, const char *path)\n \t\tret = 1;\n \t\tgoto out;\n \t}\n-\tret = ll_merge(&result, path, &base, NULL, &cur, \"\", &other, \"\", 0);\n+\tret = ll_merge(&result, path, &base, NULL, &cur, \"\", &other, \"\", NULL);\n \tif (!ret) {\n \t\tFILE *f;\n \n-- \n1.7.5.rc0.96.gc4b2c\n"},{"id":"164985","messageId":"7vaag7g34l.fsf@alter.siamese.dyndns.org","threadId":"26972","inReplyTo":"1301814414-11368-1-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH] sparse: Fix errors and silence warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-03T08:17:46Z","receivedAt":"2011-04-03T08:17:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> writes:\n\n>  * load_file() returns a void pointer but is using 0 for the return\n>    value\n>\n>  * builtin/receive-pack.c forgot to include builtin.h\n>\n>  * packet_trace_prefix can be marked static\n>\n>  * ll_merge takes a pointer for its last argument, not an int\n>\n>  * crc32 expects a pointer as the second argument but Z_NULL is defined\n>    to be 0 (see 38f4d13 sparse fix: Using plain integer as NULL pointer,\n>    2006-11-18 for more info)\n\nI think these were originally coded this way to match the way the upstream\nzlib.h from which we use the function expects us to.  But I tend to agree\nthat we should ignore Z_NULL and use NULL throughout the system.\n\nThe patch looked fine.  Thanks.\n"}]}