Skip to content

Commit 19b2860

Browse files
author
Linus Torvalds
committed
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 ;)
1 parent bf0c6e8 commit 19b2860

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CFLAGS=-g
1+
CFLAGS=-g -O3 -Wall
22
CC=gcc
33

44
PROG=update-cache show-diff init-db write-tree read-tree commit-tree cat-file

cat-file.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ int main(int argc, char **argv)
1111
char type[20];
1212
void *buf;
1313
unsigned long size;
14-
int fd;
1514

1615
if (argc != 3 || get_sha1_hex(argv[2], sha1))
1716
usage("cat-file: cat-file [-t | tagname] <sha1>");

init-db.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
int main(int argc, char **argv)
99
{
1010
char *sha1_dir = getenv(DB_ENVIRONMENT), *path;
11-
int len, i, fd;
11+
int len, i;
1212

1313
if (mkdir(".dircache", 0700) < 0) {
1414
perror("unable to create .dircache");
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
2525
if (sha1_dir) {
2626
struct stat st;
2727
if (!stat(sha1_dir, &st) < 0 && S_ISDIR(st.st_mode))
28-
return;
28+
return 0;
2929
fprintf(stderr, "DB_ENVIRONMENT set to bad directory %s: ", sha1_dir);
3030
}
3131

read-cache.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void * read_sha1_file(unsigned char *sha1, char *type, unsigned long *size)
8989
z_stream stream;
9090
char buffer[8192];
9191
struct stat st;
92-
int i, fd, ret, bytes;
92+
int fd, ret, bytes;
9393
void *map, *buf;
9494
char *filename = sha1_file_name(sha1);
9595

@@ -173,7 +173,7 @@ int write_sha1_file(char *buf, unsigned len)
173173
int write_sha1_buffer(unsigned char *sha1, void *buf, unsigned int size)
174174
{
175175
char *filename = sha1_file_name(sha1);
176-
int i, fd;
176+
int fd;
177177

178178
fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
179179
if (fd < 0)
@@ -228,6 +228,7 @@ int read_cache(void)
228228
if (fd < 0)
229229
return (errno == ENOENT) ? 0 : error("open failed");
230230

231+
size = 0; // avoid gcc warning
231232
map = (void *)-1;
232233
if (!fstat(fd, &st)) {
233234
map = NULL;

read-tree.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ static int unpack(unsigned char *sha1)
7272

7373
int main(int argc, char **argv)
7474
{
75-
int fd;
7675
unsigned char sha1[20];
7776

7877
if (argc != 2)

show-diff.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ int main(int argc, char **argv)
6060
struct stat st;
6161
struct cache_entry *ce = active_cache[i];
6262
int n, changed;
63-
unsigned int mode;
6463
unsigned long size;
6564
char type[20];
6665
void *new;

update-cache.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static int remove_file_from_cache(char *path)
5050
if (pos < active_nr)
5151
memmove(active_cache + pos, active_cache + pos + 1, (active_nr - pos - 1) * sizeof(struct cache_entry *));
5252
}
53+
return 0;
5354
}
5455

5556
static int add_cache_entry(struct cache_entry *ce)
@@ -250,4 +251,5 @@ int main(int argc, char **argv)
250251
return 0;
251252
out:
252253
unlink(".dircache/index.lock");
254+
return 0;
253255
}

write-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static int prepend_integer(char *buffer, unsigned val, int i)
3131

3232
int main(int argc, char **argv)
3333
{
34-
unsigned long size, offset, val;
34+
unsigned long size, offset;
3535
int i, entries = read_cache();
3636
char *buffer;
3737

0 commit comments

Comments
 (0)