diff --git a/Makefile b/Makefile index a6bba79ba1f46a..6a0a1c958fa2a1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CFLAGS=-g +CFLAGS=-g -O3 -Wall CC=gcc PROG=update-cache show-diff init-db write-tree read-tree commit-tree cat-file diff --git a/cat-file.c b/cat-file.c index 3071672c6ce2ff..3829fb6097ad98 100644 --- a/cat-file.c +++ b/cat-file.c @@ -11,7 +11,6 @@ int main(int argc, char **argv) char type[20]; void *buf; unsigned long size; - int fd; if (argc != 3 || get_sha1_hex(argv[2], sha1)) usage("cat-file: cat-file [-t | tagname] "); diff --git a/init-db.c b/init-db.c index bc65086368b44f..1fcef0b373ccec 100644 --- a/init-db.c +++ b/init-db.c @@ -8,7 +8,7 @@ int main(int argc, char **argv) { char *sha1_dir = getenv(DB_ENVIRONMENT), *path; - int len, i, fd; + int len, i; if (mkdir(".dircache", 0700) < 0) { perror("unable to create .dircache"); @@ -25,7 +25,7 @@ int main(int argc, char **argv) if (sha1_dir) { struct stat st; if (!stat(sha1_dir, &st) < 0 && S_ISDIR(st.st_mode)) - return; + return 0; fprintf(stderr, "DB_ENVIRONMENT set to bad directory %s: ", sha1_dir); } diff --git a/read-cache.c b/read-cache.c index b151981c1b3d15..60a0b5b2e78f40 100644 --- a/read-cache.c +++ b/read-cache.c @@ -89,7 +89,7 @@ void * read_sha1_file(unsigned char *sha1, char *type, unsigned long *size) z_stream stream; char buffer[8192]; struct stat st; - int i, fd, ret, bytes; + int fd, ret, bytes; void *map, *buf; char *filename = sha1_file_name(sha1); @@ -173,7 +173,7 @@ int write_sha1_file(char *buf, unsigned len) int write_sha1_buffer(unsigned char *sha1, void *buf, unsigned int size) { char *filename = sha1_file_name(sha1); - int i, fd; + int fd; fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); if (fd < 0) @@ -228,6 +228,7 @@ int read_cache(void) if (fd < 0) return (errno == ENOENT) ? 0 : error("open failed"); + size = 0; // avoid gcc warning map = (void *)-1; if (!fstat(fd, &st)) { map = NULL; diff --git a/read-tree.c b/read-tree.c index 3785e259756b4b..af486ff33f6f66 100644 --- a/read-tree.c +++ b/read-tree.c @@ -72,7 +72,6 @@ static int unpack(unsigned char *sha1) int main(int argc, char **argv) { - int fd; unsigned char sha1[20]; if (argc != 2) diff --git a/show-diff.c b/show-diff.c index e7aa60b4ab92ab..3c6d4f98b48634 100644 --- a/show-diff.c +++ b/show-diff.c @@ -60,7 +60,6 @@ int main(int argc, char **argv) struct stat st; struct cache_entry *ce = active_cache[i]; int n, changed; - unsigned int mode; unsigned long size; char type[20]; void *new; diff --git a/update-cache.c b/update-cache.c index 0bcd5d40819133..413e09d48fa0aa 100644 --- a/update-cache.c +++ b/update-cache.c @@ -50,6 +50,7 @@ static int remove_file_from_cache(char *path) if (pos < active_nr) memmove(active_cache + pos, active_cache + pos + 1, (active_nr - pos - 1) * sizeof(struct cache_entry *)); } + return 0; } static int add_cache_entry(struct cache_entry *ce) @@ -250,4 +251,5 @@ int main(int argc, char **argv) return 0; out: unlink(".dircache/index.lock"); + return 0; } diff --git a/write-tree.c b/write-tree.c index 012eeeff1b5dd9..6e531b40a84914 100644 --- a/write-tree.c +++ b/write-tree.c @@ -31,7 +31,7 @@ static int prepend_integer(char *buffer, unsigned val, int i) int main(int argc, char **argv) { - unsigned long size, offset, val; + unsigned long size, offset; int i, entries = read_cache(); char *buffer;