git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <bebarino@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] sparse: Fix errors and silence warnings
Date: Sun,  3 Apr 2011 00:06:54 -0700	[thread overview]
Message-ID: <1301814414-11368-1-git-send-email-bebarino@gmail.com> (raw)

 * 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>
---
 builtin/grep.c         |    6 +++---
 builtin/index-pack.c   |    2 +-
 builtin/receive-pack.c |    2 +-
 csum-file.c            |    2 +-
 pack-check.c           |    2 +-
 pkt-line.c             |    2 +-
 rerere.c               |    2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/builtin/grep.c b/builtin/grep.c
index 891e5ea..10a1f65 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -414,10 +414,10 @@ static void *load_file(const char *filename, size_t *sz)
 	err_ret:
 		if (errno != ENOENT)
 			error(_("'%s': %s"), filename, strerror(errno));
-		return 0;
+		return NULL;
 	}
 	if (!S_ISREG(st.st_mode))
-		return 0;
+		return NULL;
 	*sz = xsize_t(st.st_size);
 	i = open(filename, O_RDONLY);
 	if (i < 0)
@@ -427,7 +427,7 @@ static void *load_file(const char *filename, size_t *sz)
 		error(_("'%s': short read %s"), filename, strerror(errno));
 		close(i);
 		free(data);
-		return 0;
+		return NULL;
 	}
 	close(i);
 	data[*sz] = 0;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 5a67c81..31f001f 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -294,7 +294,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
 	void *data;
 
 	obj->idx.offset = consumed_bytes;
-	input_crc32 = crc32(0, Z_NULL, 0);
+	input_crc32 = crc32(0, NULL, 0);
 
 	p = fill(1);
 	c = *p;
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 27050e7..e1ba4dc 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
 #include "pack.h"
 #include "refs.h"
 #include "pkt-line.h"
diff --git a/csum-file.c b/csum-file.c
index 4d50cc5..be49d5f 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -116,7 +116,7 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp
 
 void crc32_begin(struct sha1file *f)
 {
-	f->crc32 = crc32(0, Z_NULL, 0);
+	f->crc32 = crc32(0, NULL, 0);
 	f->do_crc = 1;
 }
 
diff --git a/pack-check.c b/pack-check.c
index c3bf21d..a1a5216 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -23,7 +23,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
 		   off_t offset, off_t len, unsigned int nr)
 {
 	const uint32_t *index_crc;
-	uint32_t data_crc = crc32(0, Z_NULL, 0);
+	uint32_t data_crc = crc32(0, NULL, 0);
 
 	do {
 		unsigned int avail;
diff --git a/pkt-line.c b/pkt-line.c
index cd1bd26..5a04984 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -1,7 +1,7 @@
 #include "cache.h"
 #include "pkt-line.h"
 
-const char *packet_trace_prefix = "git";
+static const char *packet_trace_prefix = "git";
 static const char trace_key[] = "GIT_TRACE_PACKET";
 
 void packet_trace_identity(const char *prog)
diff --git a/rerere.c b/rerere.c
index 3d00a71..22dfc84 100644
--- a/rerere.c
+++ b/rerere.c
@@ -438,7 +438,7 @@ static int merge(const char *name, const char *path)
 		ret = 1;
 		goto out;
 	}
-	ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", 0);
+	ret = ll_merge(&result, path, &base, NULL, &cur, "", &other, "", NULL);
 	if (!ret) {
 		FILE *f;
 
-- 
1.7.5.rc0.96.gc4b2c

             reply	other threads:[~2011-04-03  7:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-03  7:06 Stephen Boyd [this message]
2011-04-03  8:17 ` [PATCH] sparse: Fix errors and silence warnings 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=1301814414-11368-1-git-send-email-bebarino@gmail.com \
    --to=bebarino@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).