diff: failed to confirm "static bug" in gcc - reinstating statics.

microscopic code improvements.
This commit is contained in:
Denis Vlasenko 2007-03-09 10:08:53 +00:00
parent f5a157615d
commit 02f0c4c2bf
3 changed files with 81 additions and 78 deletions

View File

@ -7,15 +7,12 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/ */
/* BB_AUDIT SUSv3 defects - unsupported options -H, -L, and -P. */ /* BB_AUDIT SUSv3 defects - none? */
/* BB_AUDIT GNU defects - unsupported long options. */ /* BB_AUDIT GNU defects - unsupported long options. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */ /* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
#include "busybox.h" #include "busybox.h"
/* FIXME - move to .h */
extern int chown_main(int argc, char **argv);
int chgrp_main(int argc, char **argv); int chgrp_main(int argc, char **argv);
int chgrp_main(int argc, char **argv) int chgrp_main(int argc, char **argv)
{ {

View File

@ -65,18 +65,25 @@
#define FLAG_U (1<<12) #define FLAG_U (1<<12)
#define FLAG_w (1<<13) #define FLAG_w (1<<13)
/* XXX: FIXME: the following variables should be static, but gcc currently /* The following variables should be static, but gcc currently
* creates a much bigger object if we do this. [which version of gcc? --vda] */ * creates a much bigger object if we do this. [which version of gcc? --vda] */
/* 4.x, IIRC also 3.x --bernhard */ /* 4.x, IIRC also 3.x --bernhard */
/* Works for gcc 3.4.3. Sizes without and with "static":
# size busybox.t[34]/coreutils/diff.o
text data bss dec hex filename
6969 8 305 7282 1c72 busybox.t3/coreutils/diff.o
6969 8 305 7282 1c72 busybox.t4/coreutils/diff.o
--vda
*/
/* This is the default number of lines of context. */ /* This is the default number of lines of context. */
int context = 3; static int context = 3;
int status; static int status;
char *start; static char *start;
const char *label1; static const char *label1;
const char *label2; static const char *label2;
struct stat stb1, stb2; static struct stat stb1, stb2;
char **dl; static char **dl;
USE_FEATURE_DIFF_DIR(int dl_count;) USE_FEATURE_DIFF_DIR(static int dl_count;)
struct cand { struct cand {
int x; int x;
@ -84,7 +91,7 @@ struct cand {
int pred; int pred;
}; };
struct line { static struct line {
int serial; int serial;
int value; int value;
} *file[2]; } *file[2];
@ -188,7 +195,7 @@ static int readhash(FILE * f)
sum = 1; sum = 1;
space = 0; space = 0;
if (!(option_mask32 & FLAG_b) && !(option_mask32 & FLAG_w)) { if (!(option_mask32 & (FLAG_b | FLAG_w))) {
for (i = 0; (t = getc(f)) != '\n'; i++) { for (i = 0; (t = getc(f)) != '\n'; i++) {
if (t == EOF) { if (t == EOF) {
if (i == 0) if (i == 0)
@ -241,19 +248,18 @@ static int files_differ(FILE * f1, FILE * f2, int flags)
{ {
size_t i, j; size_t i, j;
if ((flags & (D_EMPTY1 | D_EMPTY2)) || stb1.st_size != stb2.st_size || if ((flags & (D_EMPTY1 | D_EMPTY2)) || stb1.st_size != stb2.st_size
(stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT)) || (stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT)
) {
return 1; return 1;
}
while (1) { while (1) {
i = fread(bb_common_bufsiz1, 1, BUFSIZ/2, f1); i = fread(bb_common_bufsiz1, 1, BUFSIZ/2, f1);
j = fread(bb_common_bufsiz1 + BUFSIZ/2, 1, BUFSIZ/2, f2); j = fread(bb_common_bufsiz1 + BUFSIZ/2, 1, BUFSIZ/2, f2);
if (i != j) if (i != j)
return 1; return 1;
if (i == 0 && j == 0) { if (i == 0)
if (ferror(f1) || ferror(f2)) return (ferror(f1) || ferror(f2));
return 1;
return 0;
}
if (memcmp(bb_common_bufsiz1, if (memcmp(bb_common_bufsiz1,
bb_common_bufsiz1 + BUFSIZ/2, i) != 0) bb_common_bufsiz1 + BUFSIZ/2, i) != 0)
return 1; return 1;
@ -337,11 +343,11 @@ static void equiv(struct line *a, int n, struct line *b, int m, int *c)
static int isqrt(int n) static int isqrt(int n)
{ {
int y, x = 1; int y, x;
if (n == 0) if (n == 0)
return 0; return 0;
x = 1;
do { do {
y = x; y = x;
x = n / x; x = n / x;
@ -647,7 +653,6 @@ static void fetch(long *f, int a, int b, FILE * lb, int ch)
} }
} }
} }
return;
} }

View File

@ -514,6 +514,7 @@ int bb_test(int argc, char** argv);
#if ENABLE_ROUTE #if ENABLE_ROUTE
void bb_displayroutes(int noresolve, int netstatfmt); void bb_displayroutes(int noresolve, int netstatfmt);
#endif #endif
int chown_main(int argc, char **argv);
#if ENABLE_GUNZIP #if ENABLE_GUNZIP
int gunzip_main(int argc, char **argv); int gunzip_main(int argc, char **argv);
#endif #endif