@matheusbsbs / matheus-bagliano / commits / 1e4cd68c00
Fork 0

sparse: Fix errors and silence warnings

* load_file() returns a void pointer but is using 0 for the return value * builtin/receive-pack.c forgot to include builtin.h * packet_trace_prefix can be marked static * ll_merge takes a pointer for its last argument, not an int * crc32 expects a pointer as the second argument but Z_NULL is defined to be 0 (see 38f4d13 sparse fix: Using plain integer as NULL pointer, 2006-11-18 for more info) Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Boyd committed Apr 3, 2011 at 00:06 UTC 1e4cd68c0041d4c6aaa0562a4528a030944d37ee
7 files changed +9 -9
builtin/grep.c
+3 -3
@@ -414,10 +414,10 @@ static void *load_file(const char *filename, size_t *sz)
414 err_ret:
415 if (errno != ENOENT)
416 error(_("'%s': %s"), filename, strerror(errno));
417 - return 0;
417 + return NULL;
418 }
419 if (!S_ISREG(st.st_mode))
420 - return 0;
420 + return NULL;
421 *sz = xsize_t(st.st_size);
422 i = open(filename, O_RDONLY);
423 if (i < 0)
@@ -427,7 +427,7 @@ static void *load_file(const char *filename, size_t *sz)
427 error(_("'%s': short read %s"), filename, strerror(errno));
428 close(i);
429 free(data);
430 - return 0;
430 + return NULL;
431 }
432 close(i);
433 data[*sz] = 0;
builtin/index-pack.c
+1 -1
@@ -294,7 +294,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
294 void *data;
295
296 obj->idx.offset = consumed_bytes;
297 - input_crc32 = crc32(0, Z_NULL, 0);
297 + input_crc32 = crc32(0, NULL, 0);
298
299 p = fill(1);
300 c = *p;
builtin/receive-pack.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "cache.h"
1 +#include "builtin.h"
2 #include "pack.h"
3 #include "refs.h"
4 #include "pkt-line.h"
csum-file.c
+1 -1
@@ -116,7 +116,7 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp
116
117 void crc32_begin(struct sha1file *f)
118 {
119 - f->crc32 = crc32(0, Z_NULL, 0);
119 + f->crc32 = crc32(0, NULL, 0);
120 f->do_crc = 1;
121 }
122
pack-check.c
+1 -1
@@ -23,7 +23,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
23 off_t offset, off_t len, unsigned int nr)
24 {
25 const uint32_t *index_crc;
26 - uint32_t data_crc = crc32(0, Z_NULL, 0);
26 + uint32_t data_crc = crc32(0, NULL, 0);
27
28 do {
29 unsigned int avail;
pkt-line.c
+1 -1
@@ -1,7 +1,7 @@
1 #include "cache.h"
2 #include "pkt-line.h"
3
4 -const char *packet_trace_prefix = "git";
4 +static const char *packet_trace_prefix = "git";
5 static const char trace_key[] = "GIT_TRACE_PACKET";
6
7 void packet_trace_identity(const char *prog)
rerere.c
+1 -1
@@ -438,7 +438,7 @@ static int merge(const char *name, const char *path)
438 ret = 1;
439 goto out;
440 }
441 - ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", 0);
441 + ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", NULL);
442 if (!ret) {
443 FILE *f;
444