aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-03-06 20:44:17 -0500
committerJunio C Hamano <junkio@cox.net>2007-03-07 10:47:10 -0800
commit3a55602eeca4ac8670e8698a7187e18b95683344 (patch)
tree625a8af9c4655ace00b275c3e272c2764db3bcb8 /sha1_file.c
parentff1f99453f1fe2fd9470f6ea268aed5a1839bd09 (diff)
downloadgit-3a55602eeca4ac8670e8698a7187e18b95683344.tar.gz
git-3a55602eeca4ac8670e8698a7187e18b95683344.tar.xz
General const correctness fixes
We shouldn't attempt to assign constant strings into char*, as the string is not writable at runtime. Likewise we should always be treating unsigned values as unsigned values, not as signed values. Most of these are very straightforward. The only exception is the (unnecessary) xstrdup/free in builtin-branch.c for the detached head case. Since this is a user-level interactive type program and that particular code path is executed no more than once, I feel that the extra xstrdup call is well worth the easy elimination of this warning. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c
index cfce7acdb..b17a82879 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2065,10 +2065,9 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
enum object_type type, const char *path)
{
unsigned long size = st->st_size;
- void *buf;
+ void *buf = NULL;
int ret, re_allocated = 0;
- buf = "";
if (size)
buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);