Use "-Wall -O2" for the compiler to get more warnings.

And fix up the warnings that it pointed out. Let's keep the tree
clean from early on.

Not that the code is very beautiful anyway ;)
This commit is contained in:
Linus Torvalds 2005-04-08 09:59:28 -07:00
parent bf0c6e839c
commit 19b2860cba
8 changed files with 9 additions and 9 deletions

View File

@ -1,4 +1,4 @@
CFLAGS=-g CFLAGS=-g -O3 -Wall
CC=gcc CC=gcc
PROG=update-cache show-diff init-db write-tree read-tree commit-tree cat-file PROG=update-cache show-diff init-db write-tree read-tree commit-tree cat-file

View File

@ -11,7 +11,6 @@ int main(int argc, char **argv)
char type[20]; char type[20];
void *buf; void *buf;
unsigned long size; unsigned long size;
int fd;
if (argc != 3 || get_sha1_hex(argv[2], sha1)) if (argc != 3 || get_sha1_hex(argv[2], sha1))
usage("cat-file: cat-file [-t | tagname] <sha1>"); usage("cat-file: cat-file [-t | tagname] <sha1>");

View File

@ -8,7 +8,7 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char *sha1_dir = getenv(DB_ENVIRONMENT), *path; char *sha1_dir = getenv(DB_ENVIRONMENT), *path;
int len, i, fd; int len, i;
if (mkdir(".dircache", 0700) < 0) { if (mkdir(".dircache", 0700) < 0) {
perror("unable to create .dircache"); perror("unable to create .dircache");
@ -25,7 +25,7 @@ int main(int argc, char **argv)
if (sha1_dir) { if (sha1_dir) {
struct stat st; struct stat st;
if (!stat(sha1_dir, &st) < 0 && S_ISDIR(st.st_mode)) 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); fprintf(stderr, "DB_ENVIRONMENT set to bad directory %s: ", sha1_dir);
} }

View File

@ -89,7 +89,7 @@ void * read_sha1_file(unsigned char *sha1, char *type, unsigned long *size)
z_stream stream; z_stream stream;
char buffer[8192]; char buffer[8192];
struct stat st; struct stat st;
int i, fd, ret, bytes; int fd, ret, bytes;
void *map, *buf; void *map, *buf;
char *filename = sha1_file_name(sha1); 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) int write_sha1_buffer(unsigned char *sha1, void *buf, unsigned int size)
{ {
char *filename = sha1_file_name(sha1); char *filename = sha1_file_name(sha1);
int i, fd; int fd;
fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
if (fd < 0) if (fd < 0)
@ -228,6 +228,7 @@ int read_cache(void)
if (fd < 0) if (fd < 0)
return (errno == ENOENT) ? 0 : error("open failed"); return (errno == ENOENT) ? 0 : error("open failed");
size = 0; // avoid gcc warning
map = (void *)-1; map = (void *)-1;
if (!fstat(fd, &st)) { if (!fstat(fd, &st)) {
map = NULL; map = NULL;

View File

@ -72,7 +72,6 @@ static int unpack(unsigned char *sha1)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int fd;
unsigned char sha1[20]; unsigned char sha1[20];
if (argc != 2) if (argc != 2)

View File

@ -60,7 +60,6 @@ int main(int argc, char **argv)
struct stat st; struct stat st;
struct cache_entry *ce = active_cache[i]; struct cache_entry *ce = active_cache[i];
int n, changed; int n, changed;
unsigned int mode;
unsigned long size; unsigned long size;
char type[20]; char type[20];
void *new; void *new;

View File

@ -50,6 +50,7 @@ static int remove_file_from_cache(char *path)
if (pos < active_nr) if (pos < active_nr)
memmove(active_cache + pos, active_cache + pos + 1, (active_nr - pos - 1) * sizeof(struct cache_entry *)); 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) static int add_cache_entry(struct cache_entry *ce)
@ -250,4 +251,5 @@ int main(int argc, char **argv)
return 0; return 0;
out: out:
unlink(".dircache/index.lock"); unlink(".dircache/index.lock");
return 0;
} }

View File

@ -31,7 +31,7 @@ static int prepend_integer(char *buffer, unsigned val, int i)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
unsigned long size, offset, val; unsigned long size, offset;
int i, entries = read_cache(); int i, entries = read_cache();
char *buffer; char *buffer;