Skip to content

Commit 1e4cd68

Browse files
bebarinogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cb35c06 commit 1e4cd68

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

builtin/grep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ static void *load_file(const char *filename, size_t *sz)
414414
err_ret:
415415
if (errno != ENOENT)
416416
error(_("'%s': %s"), filename, strerror(errno));
417-
return 0;
417+
return NULL;
418418
}
419419
if (!S_ISREG(st.st_mode))
420-
return 0;
420+
return NULL;
421421
*sz = xsize_t(st.st_size);
422422
i = open(filename, O_RDONLY);
423423
if (i < 0)
@@ -427,7 +427,7 @@ static void *load_file(const char *filename, size_t *sz)
427427
error(_("'%s': short read %s"), filename, strerror(errno));
428428
close(i);
429429
free(data);
430-
return 0;
430+
return NULL;
431431
}
432432
close(i);
433433
data[*sz] = 0;

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
294294
void *data;
295295

296296
obj->idx.offset = consumed_bytes;
297-
input_crc32 = crc32(0, Z_NULL, 0);
297+
input_crc32 = crc32(0, NULL, 0);
298298

299299
p = fill(1);
300300
c = *p;

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "cache.h"
1+
#include "builtin.h"
22
#include "pack.h"
33
#include "refs.h"
44
#include "pkt-line.h"

csum-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp
116116

117117
void crc32_begin(struct sha1file *f)
118118
{
119-
f->crc32 = crc32(0, Z_NULL, 0);
119+
f->crc32 = crc32(0, NULL, 0);
120120
f->do_crc = 1;
121121
}
122122

pack-check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
2323
off_t offset, off_t len, unsigned int nr)
2424
{
2525
const uint32_t *index_crc;
26-
uint32_t data_crc = crc32(0, Z_NULL, 0);
26+
uint32_t data_crc = crc32(0, NULL, 0);
2727

2828
do {
2929
unsigned int avail;

pkt-line.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "cache.h"
22
#include "pkt-line.h"
33

4-
const char *packet_trace_prefix = "git";
4+
static const char *packet_trace_prefix = "git";
55
static const char trace_key[] = "GIT_TRACE_PACKET";
66

77
void packet_trace_identity(const char *prog)

rerere.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static int merge(const char *name, const char *path)
438438
ret = 1;
439439
goto out;
440440
}
441-
ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", 0);
441+
ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", NULL);
442442
if (!ret) {
443443
FILE *f;
444444

0 commit comments

Comments
 (0)