A nice patch from Larry Doolittle that adds -Wshadow and
cleans up most of the now-revealed problems.
diff --git a/Makefile b/Makefile
index de7320f..4ff1078 100644
--- a/Makefile
+++ b/Makefile
@@ -108,7 +108,7 @@
OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo "-Os"; else echo "-O2" ; fi)
-WARNINGS = -Wall
+WARNINGS = -Wall -Wshadow
ARFLAGS = -r
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 1618dd1..3f58929 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -45,7 +45,7 @@
int dd_main(int argc, char **argv)
{
- int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
+ int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE;
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1;
ssize_t n;
@@ -73,7 +73,7 @@
trunc = FALSE;
buf += 7;
} else if (strncmp("sync", buf, 4) == 0) {
- sync = TRUE;
+ sync_flag = TRUE;
buf += 4;
} else {
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
@@ -138,7 +138,7 @@
in_full++;
else
in_part++;
- if (sync) {
+ if (sync_flag) {
memset(buf + n, '\0', bs - n);
n = bs;
}
diff --git a/coreutils/echo.c b/coreutils/echo.c
index e9bc50a..1ca3734 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -40,7 +40,7 @@
while (argc > 0 && *argv[0] == '-')
{
register char *temp;
- register int index;
+ register int ix;
/*
* If it appears that we are handling options, then make sure
@@ -49,9 +49,9 @@
*/
temp = argv[0] + 1;
- for (index = 0; temp[index]; index++)
+ for (ix = 0; temp[ix]; ix++)
{
- if (strrchr("neE", temp[index]) == 0)
+ if (strrchr("neE", temp[ix]) == 0)
goto just_echo;
}
diff --git a/coreutils/tr.c b/coreutils/tr.c
index b7a6009..ddb7387 100644
--- a/coreutils/tr.c
+++ b/coreutils/tr.c
@@ -123,19 +123,19 @@
static int complement(unsigned char *buffer, int buffer_len)
{
- register short i, j, index;
+ register short i, j, ix;
char conv[ASCII + 2];
- index = 0;
+ ix = 0;
for (i = 0; i <= ASCII; i++) {
for (j = 0; j < buffer_len; j++)
if (buffer[j] == i)
break;
if (j == buffer_len)
- conv[index++] = i & ASCII;
+ conv[ix++] = i & ASCII;
}
- memcpy(buffer, conv, index);
- return index;
+ memcpy(buffer, conv, ix);
+ return ix;
}
extern int tr_main(int argc, char **argv)
diff --git a/dd.c b/dd.c
index 1618dd1..3f58929 100644
--- a/dd.c
+++ b/dd.c
@@ -45,7 +45,7 @@
int dd_main(int argc, char **argv)
{
- int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
+ int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE;
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1;
ssize_t n;
@@ -73,7 +73,7 @@
trunc = FALSE;
buf += 7;
} else if (strncmp("sync", buf, 4) == 0) {
- sync = TRUE;
+ sync_flag = TRUE;
buf += 4;
} else {
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
@@ -138,7 +138,7 @@
in_full++;
else
in_part++;
- if (sync) {
+ if (sync_flag) {
memset(buf + n, '\0', bs - n);
n = bs;
}
diff --git a/echo.c b/echo.c
index e9bc50a..1ca3734 100644
--- a/echo.c
+++ b/echo.c
@@ -40,7 +40,7 @@
while (argc > 0 && *argv[0] == '-')
{
register char *temp;
- register int index;
+ register int ix;
/*
* If it appears that we are handling options, then make sure
@@ -49,9 +49,9 @@
*/
temp = argv[0] + 1;
- for (index = 0; temp[index]; index++)
+ for (ix = 0; temp[ix]; ix++)
{
- if (strrchr("neE", temp[index]) == 0)
+ if (strrchr("neE", temp[ix]) == 0)
goto just_echo;
}
diff --git a/fsck_minix.c b/fsck_minix.c
index bd0c8a6..a2421fc 100644
--- a/fsck_minix.c
+++ b/fsck_minix.c
@@ -1439,18 +1439,18 @@
check();
}
if (verbose) {
- int i, free;
+ int i, free_cnt;
- for (i = 1, free = 0; i <= INODES; i++)
+ for (i = 1, free_cnt = 0; i <= INODES; i++)
if (!inode_in_use(i))
- free++;
- printf("\n%6ld inodes used (%ld%%)\n", (INODES - free),
- 100 * (INODES - free) / INODES);
- for (i = FIRSTZONE, free = 0; i < ZONES; i++)
+ free_cnt++;
+ printf("\n%6ld inodes used (%ld%%)\n", (INODES - free_cnt),
+ 100 * (INODES - free_cnt) / INODES);
+ for (i = FIRSTZONE, free_cnt = 0; i < ZONES; i++)
if (!zone_in_use(i))
- free++;
- printf("%6ld zones used (%ld%%)\n", (ZONES - free),
- 100 * (ZONES - free) / ZONES);
+ free_cnt++;
+ printf("%6ld zones used (%ld%%)\n", (ZONES - free_cnt),
+ 100 * (ZONES - free_cnt) / ZONES);
printf("\n%6d regular files\n"
"%6d directories\n"
"%6d character device files\n"
diff --git a/init.c b/init.c
index b775893..417aadd 100644
--- a/init.c
+++ b/init.c
@@ -512,7 +512,6 @@
*/
if (*cmdpath == '-') {
- char *s;
/* skip over the dash */
++cmdpath;
diff --git a/init/init.c b/init/init.c
index b775893..417aadd 100644
--- a/init/init.c
+++ b/init/init.c
@@ -512,7 +512,6 @@
*/
if (*cmdpath == '-') {
- char *s;
/* skip over the dash */
++cmdpath;
diff --git a/lash.c b/lash.c
index 8727e12..5a59c01 100644
--- a/lash.c
+++ b/lash.c
@@ -687,16 +687,16 @@
cmd->job_list = keep;
}
-/* remove a job from the job_list */
-static void remove_job(struct jobset *job_list, struct job *job)
+/* remove a job from a jobset */
+static void remove_job(struct jobset *j_list, struct job *job)
{
struct job *prevjob;
free_job(job);
- if (job == job_list->head) {
- job_list->head = job->next;
+ if (job == j_list->head) {
+ j_list->head = job->next;
} else {
- prevjob = job_list->head;
+ prevjob = j_list->head;
while (prevjob->next != job)
prevjob = prevjob->next;
prevjob->next = job->next;
@@ -707,7 +707,7 @@
/* Checks to see if any background processes have exited -- if they
have, figure out why and see if a job has completed */
-static void checkjobs(struct jobset *job_list)
+static void checkjobs(struct jobset *j_list)
{
struct job *job;
pid_t childpid;
@@ -715,7 +715,7 @@
int prognum = 0;
while ((childpid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 0) {
- for (job = job_list->head; job; job = job->next) {
+ for (job = j_list->head; job; job = job->next) {
prognum = 0;
while (prognum < job->num_progs &&
job->progs[prognum].pid != childpid) prognum++;
@@ -734,7 +734,7 @@
if (!job->running_progs) {
printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text);
- remove_job(job_list, job);
+ remove_job(j_list, job);
}
} else {
/* child stopped */
@@ -907,35 +907,35 @@
#endif
#if defined BB_FEATURE_SH_ENVIRONMENT && ! defined BB_FEATURE_SH_WORDEXP
-char * strsep_space( char *string, int * index)
+char * strsep_space( char *string, int * ix)
{
char *token, *begin;
begin = string;
/* Short circuit the trivial case */
- if ( !string || ! string[*index])
+ if ( !string || ! string[*ix])
return NULL;
/* Find the end of the token. */
- while( string && string[*index] && !isspace(string[*index]) ) {
- (*index)++;
+ while( string && string[*ix] && !isspace(string[*ix]) ) {
+ (*ix)++;
}
/* Find the end of any whitespace trailing behind
* the token and let that be part of the token */
- while( string && string[*index] && isspace(string[*index]) ) {
- (*index)++;
+ while( string && string[*ix] && isspace(string[*ix]) ) {
+ (*ix)++;
}
- if (! string && *index==0) {
+ if (! string && *ix==0) {
/* Nothing useful was found */
return NULL;
}
- token = xmalloc(*index+1);
- token[*index] = '\0';
- strncpy(token, string, *index);
+ token = xmalloc(*ix+1);
+ token[*ix] = '\0';
+ strncpy(token, string, *ix);
return token;
}
@@ -947,7 +947,7 @@
#ifdef BB_FEATURE_SH_ENVIRONMENT
expand_t expand_result;
char *src, *dst, *var;
- int index = 0;
+ int ix = 0;
int i=0, length, total_length=0, retval;
const char *out_of_space = "out of space during expansion";
#endif
@@ -956,13 +956,13 @@
chomp(command);
/* Fix up escape sequences to be the Real Thing(tm) */
- while( command && command[index]) {
- if (command[index] == '\\') {
- char *tmp = command+index+1;
- command[index] = process_escape_sequence( &tmp );
- memmove(command+index + 1, tmp, strlen(tmp)+1);
+ while( command && command[ix]) {
+ if (command[ix] == '\\') {
+ char *tmp = command+ix+1;
+ command[ix] = process_escape_sequence( &tmp );
+ memmove(command+ix + 1, tmp, strlen(tmp)+1);
}
- index++;
+ ix++;
}
#ifdef BB_FEATURE_SH_ENVIRONMENT
@@ -1025,8 +1025,8 @@
* we write stuff into the original (in a minute) */
cmd = cmd_copy = strdup(command);
*command = '\0';
- for (index = 0, tmpcmd = cmd;
- (tmpcmd = strsep_space(cmd, &index)) != NULL; cmd += index, index=0) {
+ for (ix = 0, tmpcmd = cmd;
+ (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
if (*tmpcmd == '\0')
break;
retval = glob(tmpcmd, flags, NULL, &expand_result);
@@ -1096,11 +1096,11 @@
case '0':case '1':case '2':case '3':case '4':
case '5':case '6':case '7':case '8':case '9':
{
- int index=*(dst + 1)-48;
- if (index >= argc) {
+ int ixx=*(dst + 1)-48;
+ if (ixx >= argc) {
var='\0';
} else {
- var = argv[index];
+ var = argv[ixx];
}
}
break;
@@ -1575,19 +1575,19 @@
static void insert_job(struct job *newjob, int inbg)
{
struct job *thejob;
- struct jobset *job_list=newjob->job_list;
+ struct jobset *j_list=newjob->job_list;
/* find the ID for thejob to use */
newjob->jobid = 1;
- for (thejob = job_list->head; thejob; thejob = thejob->next)
+ for (thejob = j_list->head; thejob; thejob = thejob->next)
if (thejob->jobid >= newjob->jobid)
newjob->jobid = thejob->jobid + 1;
/* add thejob to the list of running jobs */
- if (!job_list->head) {
- thejob = job_list->head = xmalloc(sizeof(*thejob));
+ if (!j_list->head) {
+ thejob = j_list->head = xmalloc(sizeof(*thejob));
} else {
- for (thejob = job_list->head; thejob->next; thejob = thejob->next) /* nothing */;
+ for (thejob = j_list->head; thejob->next; thejob = thejob->next) /* nothing */;
thejob->next = xmalloc(sizeof(*thejob));
thejob = thejob->next;
}
diff --git a/libbb/parse_mode.c b/libbb/parse_mode.c
index 33a8781..a68b7d3 100644
--- a/libbb/parse_mode.c
+++ b/libbb/parse_mode.c
@@ -50,8 +50,8 @@
S_ISVTX /* t */
};
- static const char group_string[] = "ugoa";
- static const char mode_string[] = "rwxst";
+ static const char group_chars[] = "ugoa";
+ static const char mode_chars[] = "rwxst";
const char *p;
@@ -74,9 +74,9 @@
if ((c = *s++) == '\0') {
return -1;
}
- for (p=group_string ; *p ; p++) {
+ for (p=group_chars ; *p ; p++) {
if (*p == c) {
- groups |= group_set[(int)(p-group_string)];
+ groups |= group_set[(int)(p-group_chars)];
goto NEXT_GROUP;
}
}
@@ -101,9 +101,9 @@
NEXT_MODE:
if (((c = *s++) != '\0') && (c != ',')) {
- for (p=mode_string ; *p ; p++) {
+ for (p=mode_chars ; *p ; p++) {
if (*p == c) {
- mode |= mode_set[(int)(p-mode_string)];
+ mode |= mode_set[(int)(p-mode_chars)];
goto NEXT_MODE;
}
}
diff --git a/libbb/recursive_action.c b/libbb/recursive_action.c
index 6b93340..8424ca0 100644
--- a/libbb/recursive_action.c
+++ b/libbb/recursive_action.c
@@ -26,6 +26,7 @@
*/
#include <stdio.h>
+#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include "libbb.h"
diff --git a/networking/route.c b/networking/route.c
index 337b358..d571fc5 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -15,7 +15,7 @@
* Foundation; either version 2 of the License, or (at
* your option) any later version.
*
- * $Id: route.c,v 1.9 2001/03/09 21:24:12 andersen Exp $
+ * $Id: route.c,v 1.10 2001/03/21 07:34:26 andersen Exp $
*
* displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
* adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
@@ -60,18 +60,18 @@
static int
INET_resolve(char *name, struct sockaddr *sa)
{
- struct sockaddr_in *sin = (struct sockaddr_in *)sa;
+ struct sockaddr_in *s_in = (struct sockaddr_in *)sa;
- sin->sin_family = AF_INET;
- sin->sin_port = 0;
+ s_in->sin_family = AF_INET;
+ s_in->sin_port = 0;
/* Default is special, meaning 0.0.0.0. */
if (strcmp(name, "default")==0) {
- sin->sin_addr.s_addr = INADDR_ANY;
+ s_in->sin_addr.s_addr = INADDR_ANY;
return 1;
}
/* Look to see if it's a dotted quad. */
- if (inet_aton(name, &sin->sin_addr)) {
+ if (inet_aton(name, &s_in->sin_addr)) {
return 0;
}
/* guess not.. */
diff --git a/networking/wget.c b/networking/wget.c
index 85023f9..f62d835 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -291,24 +291,24 @@
FILE *open_socket(char *host, int port)
{
- struct sockaddr_in sin;
+ struct sockaddr_in s_in;
struct hostent *hp;
int fd;
FILE *fp;
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
+ memset(&s_in, 0, sizeof(s_in));
+ s_in.sin_family = AF_INET;
if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
error_msg_and_die("cannot resolve %s", host);
- memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length);
- sin.sin_port = htons(port);
+ memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length);
+ s_in.sin_port = htons(port);
/*
* Get the server onto a stdio stream.
*/
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
perror_msg_and_die("socket()");
- if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
+ if (connect(fd, (struct sockaddr *) &s_in, sizeof(s_in)) < 0)
perror_msg_and_die("connect(%s)", host);
if ((fp = fdopen(fd, "r+")) == NULL)
perror_msg_and_die("fdopen()");
@@ -534,7 +534,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: wget.c,v 1.29 2001/03/09 21:24:12 andersen Exp $
+ * $Id: wget.c,v 1.30 2001/03/21 07:34:26 andersen Exp $
*/
diff --git a/nfsmount.c b/nfsmount.c
index cd81510..6643ed5 100644
--- a/nfsmount.c
+++ b/nfsmount.c
@@ -157,7 +157,7 @@
#define HAVE_personality
#define HAVE_tm_gmtoff
-static char *nfs_strerror(int stat);
+static char *nfs_strerror(int status);
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
@@ -873,16 +873,16 @@
{ -1, EIO }
};
-static char *nfs_strerror(int stat)
+static char *nfs_strerror(int status)
{
int i;
static char buf[256];
for (i = 0; nfs_errtbl[i].stat != -1; i++) {
- if (nfs_errtbl[i].stat == stat)
+ if (nfs_errtbl[i].stat == status)
return strerror(nfs_errtbl[i].errnum);
}
- sprintf(buf, _("unknown nfs status return value: %d"), stat);
+ sprintf(buf, _("unknown nfs status return value: %d"), status);
return buf;
}
diff --git a/rdate.c b/rdate.c
index 5f31282..ead1e7c 100644
--- a/rdate.c
+++ b/rdate.c
@@ -40,7 +40,7 @@
static time_t askremotedate(const char *host)
{
struct hostent *h;
- struct sockaddr_in sin;
+ struct sockaddr_in s_in;
struct servent *tserv;
unsigned long int nett, localt;
int fd;
@@ -54,11 +54,11 @@
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */
perror_msg_and_die("%s", "socket");
- memcpy(&sin.sin_addr, h->h_addr, sizeof(sin.sin_addr));
- sin.sin_port= tserv->s_port;
- sin.sin_family = AF_INET;
+ memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr));
+ s_in.sin_port= tserv->s_port;
+ s_in.sin_family = AF_INET;
- if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) /* connect to time server */
+ if (connect(fd, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) /* connect to time server */
perror_msg_and_die("%s", host);
if (read(fd, (void *)&nett, 4) != 4) /* read time from server */
@@ -79,7 +79,7 @@
int rdate_main(int argc, char **argv)
{
- time_t time;
+ time_t remote_time;
int opt;
int setdate = 0;
int printdate= 0;
@@ -111,15 +111,15 @@
if (optind == argc)
show_usage();
- time = askremotedate(argv[optind]);
+ remote_time = askremotedate(argv[optind]);
if (setdate) {
- if (stime(&time) < 0)
+ if (stime(&remote_time) < 0)
perror_msg_and_die("Could not set time of day");
}
if (printdate)
- printf("%s", ctime(&time));
+ printf("%s", ctime(&remote_time));
return EXIT_SUCCESS;
}
diff --git a/route.c b/route.c
index 337b358..d571fc5 100644
--- a/route.c
+++ b/route.c
@@ -15,7 +15,7 @@
* Foundation; either version 2 of the License, or (at
* your option) any later version.
*
- * $Id: route.c,v 1.9 2001/03/09 21:24:12 andersen Exp $
+ * $Id: route.c,v 1.10 2001/03/21 07:34:26 andersen Exp $
*
* displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
* adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
@@ -60,18 +60,18 @@
static int
INET_resolve(char *name, struct sockaddr *sa)
{
- struct sockaddr_in *sin = (struct sockaddr_in *)sa;
+ struct sockaddr_in *s_in = (struct sockaddr_in *)sa;
- sin->sin_family = AF_INET;
- sin->sin_port = 0;
+ s_in->sin_family = AF_INET;
+ s_in->sin_port = 0;
/* Default is special, meaning 0.0.0.0. */
if (strcmp(name, "default")==0) {
- sin->sin_addr.s_addr = INADDR_ANY;
+ s_in->sin_addr.s_addr = INADDR_ANY;
return 1;
}
/* Look to see if it's a dotted quad. */
- if (inet_aton(name, &sin->sin_addr)) {
+ if (inet_aton(name, &s_in->sin_addr)) {
return 0;
}
/* guess not.. */
diff --git a/sh.c b/sh.c
index 8727e12..5a59c01 100644
--- a/sh.c
+++ b/sh.c
@@ -687,16 +687,16 @@
cmd->job_list = keep;
}
-/* remove a job from the job_list */
-static void remove_job(struct jobset *job_list, struct job *job)
+/* remove a job from a jobset */
+static void remove_job(struct jobset *j_list, struct job *job)
{
struct job *prevjob;
free_job(job);
- if (job == job_list->head) {
- job_list->head = job->next;
+ if (job == j_list->head) {
+ j_list->head = job->next;
} else {
- prevjob = job_list->head;
+ prevjob = j_list->head;
while (prevjob->next != job)
prevjob = prevjob->next;
prevjob->next = job->next;
@@ -707,7 +707,7 @@
/* Checks to see if any background processes have exited -- if they
have, figure out why and see if a job has completed */
-static void checkjobs(struct jobset *job_list)
+static void checkjobs(struct jobset *j_list)
{
struct job *job;
pid_t childpid;
@@ -715,7 +715,7 @@
int prognum = 0;
while ((childpid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 0) {
- for (job = job_list->head; job; job = job->next) {
+ for (job = j_list->head; job; job = job->next) {
prognum = 0;
while (prognum < job->num_progs &&
job->progs[prognum].pid != childpid) prognum++;
@@ -734,7 +734,7 @@
if (!job->running_progs) {
printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text);
- remove_job(job_list, job);
+ remove_job(j_list, job);
}
} else {
/* child stopped */
@@ -907,35 +907,35 @@
#endif
#if defined BB_FEATURE_SH_ENVIRONMENT && ! defined BB_FEATURE_SH_WORDEXP
-char * strsep_space( char *string, int * index)
+char * strsep_space( char *string, int * ix)
{
char *token, *begin;
begin = string;
/* Short circuit the trivial case */
- if ( !string || ! string[*index])
+ if ( !string || ! string[*ix])
return NULL;
/* Find the end of the token. */
- while( string && string[*index] && !isspace(string[*index]) ) {
- (*index)++;
+ while( string && string[*ix] && !isspace(string[*ix]) ) {
+ (*ix)++;
}
/* Find the end of any whitespace trailing behind
* the token and let that be part of the token */
- while( string && string[*index] && isspace(string[*index]) ) {
- (*index)++;
+ while( string && string[*ix] && isspace(string[*ix]) ) {
+ (*ix)++;
}
- if (! string && *index==0) {
+ if (! string && *ix==0) {
/* Nothing useful was found */
return NULL;
}
- token = xmalloc(*index+1);
- token[*index] = '\0';
- strncpy(token, string, *index);
+ token = xmalloc(*ix+1);
+ token[*ix] = '\0';
+ strncpy(token, string, *ix);
return token;
}
@@ -947,7 +947,7 @@
#ifdef BB_FEATURE_SH_ENVIRONMENT
expand_t expand_result;
char *src, *dst, *var;
- int index = 0;
+ int ix = 0;
int i=0, length, total_length=0, retval;
const char *out_of_space = "out of space during expansion";
#endif
@@ -956,13 +956,13 @@
chomp(command);
/* Fix up escape sequences to be the Real Thing(tm) */
- while( command && command[index]) {
- if (command[index] == '\\') {
- char *tmp = command+index+1;
- command[index] = process_escape_sequence( &tmp );
- memmove(command+index + 1, tmp, strlen(tmp)+1);
+ while( command && command[ix]) {
+ if (command[ix] == '\\') {
+ char *tmp = command+ix+1;
+ command[ix] = process_escape_sequence( &tmp );
+ memmove(command+ix + 1, tmp, strlen(tmp)+1);
}
- index++;
+ ix++;
}
#ifdef BB_FEATURE_SH_ENVIRONMENT
@@ -1025,8 +1025,8 @@
* we write stuff into the original (in a minute) */
cmd = cmd_copy = strdup(command);
*command = '\0';
- for (index = 0, tmpcmd = cmd;
- (tmpcmd = strsep_space(cmd, &index)) != NULL; cmd += index, index=0) {
+ for (ix = 0, tmpcmd = cmd;
+ (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
if (*tmpcmd == '\0')
break;
retval = glob(tmpcmd, flags, NULL, &expand_result);
@@ -1096,11 +1096,11 @@
case '0':case '1':case '2':case '3':case '4':
case '5':case '6':case '7':case '8':case '9':
{
- int index=*(dst + 1)-48;
- if (index >= argc) {
+ int ixx=*(dst + 1)-48;
+ if (ixx >= argc) {
var='\0';
} else {
- var = argv[index];
+ var = argv[ixx];
}
}
break;
@@ -1575,19 +1575,19 @@
static void insert_job(struct job *newjob, int inbg)
{
struct job *thejob;
- struct jobset *job_list=newjob->job_list;
+ struct jobset *j_list=newjob->job_list;
/* find the ID for thejob to use */
newjob->jobid = 1;
- for (thejob = job_list->head; thejob; thejob = thejob->next)
+ for (thejob = j_list->head; thejob; thejob = thejob->next)
if (thejob->jobid >= newjob->jobid)
newjob->jobid = thejob->jobid + 1;
/* add thejob to the list of running jobs */
- if (!job_list->head) {
- thejob = job_list->head = xmalloc(sizeof(*thejob));
+ if (!j_list->head) {
+ thejob = j_list->head = xmalloc(sizeof(*thejob));
} else {
- for (thejob = job_list->head; thejob->next; thejob = thejob->next) /* nothing */;
+ for (thejob = j_list->head; thejob->next; thejob = thejob->next) /* nothing */;
thejob->next = xmalloc(sizeof(*thejob));
thejob = thejob->next;
}
diff --git a/shell/lash.c b/shell/lash.c
index 8727e12..5a59c01 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -687,16 +687,16 @@
cmd->job_list = keep;
}
-/* remove a job from the job_list */
-static void remove_job(struct jobset *job_list, struct job *job)
+/* remove a job from a jobset */
+static void remove_job(struct jobset *j_list, struct job *job)
{
struct job *prevjob;
free_job(job);
- if (job == job_list->head) {
- job_list->head = job->next;
+ if (job == j_list->head) {
+ j_list->head = job->next;
} else {
- prevjob = job_list->head;
+ prevjob = j_list->head;
while (prevjob->next != job)
prevjob = prevjob->next;
prevjob->next = job->next;
@@ -707,7 +707,7 @@
/* Checks to see if any background processes have exited -- if they
have, figure out why and see if a job has completed */
-static void checkjobs(struct jobset *job_list)
+static void checkjobs(struct jobset *j_list)
{
struct job *job;
pid_t childpid;
@@ -715,7 +715,7 @@
int prognum = 0;
while ((childpid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 0) {
- for (job = job_list->head; job; job = job->next) {
+ for (job = j_list->head; job; job = job->next) {
prognum = 0;
while (prognum < job->num_progs &&
job->progs[prognum].pid != childpid) prognum++;
@@ -734,7 +734,7 @@
if (!job->running_progs) {
printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text);
- remove_job(job_list, job);
+ remove_job(j_list, job);
}
} else {
/* child stopped */
@@ -907,35 +907,35 @@
#endif
#if defined BB_FEATURE_SH_ENVIRONMENT && ! defined BB_FEATURE_SH_WORDEXP
-char * strsep_space( char *string, int * index)
+char * strsep_space( char *string, int * ix)
{
char *token, *begin;
begin = string;
/* Short circuit the trivial case */
- if ( !string || ! string[*index])
+ if ( !string || ! string[*ix])
return NULL;
/* Find the end of the token. */
- while( string && string[*index] && !isspace(string[*index]) ) {
- (*index)++;
+ while( string && string[*ix] && !isspace(string[*ix]) ) {
+ (*ix)++;
}
/* Find the end of any whitespace trailing behind
* the token and let that be part of the token */
- while( string && string[*index] && isspace(string[*index]) ) {
- (*index)++;
+ while( string && string[*ix] && isspace(string[*ix]) ) {
+ (*ix)++;
}
- if (! string && *index==0) {
+ if (! string && *ix==0) {
/* Nothing useful was found */
return NULL;
}
- token = xmalloc(*index+1);
- token[*index] = '\0';
- strncpy(token, string, *index);
+ token = xmalloc(*ix+1);
+ token[*ix] = '\0';
+ strncpy(token, string, *ix);
return token;
}
@@ -947,7 +947,7 @@
#ifdef BB_FEATURE_SH_ENVIRONMENT
expand_t expand_result;
char *src, *dst, *var;
- int index = 0;
+ int ix = 0;
int i=0, length, total_length=0, retval;
const char *out_of_space = "out of space during expansion";
#endif
@@ -956,13 +956,13 @@
chomp(command);
/* Fix up escape sequences to be the Real Thing(tm) */
- while( command && command[index]) {
- if (command[index] == '\\') {
- char *tmp = command+index+1;
- command[index] = process_escape_sequence( &tmp );
- memmove(command+index + 1, tmp, strlen(tmp)+1);
+ while( command && command[ix]) {
+ if (command[ix] == '\\') {
+ char *tmp = command+ix+1;
+ command[ix] = process_escape_sequence( &tmp );
+ memmove(command+ix + 1, tmp, strlen(tmp)+1);
}
- index++;
+ ix++;
}
#ifdef BB_FEATURE_SH_ENVIRONMENT
@@ -1025,8 +1025,8 @@
* we write stuff into the original (in a minute) */
cmd = cmd_copy = strdup(command);
*command = '\0';
- for (index = 0, tmpcmd = cmd;
- (tmpcmd = strsep_space(cmd, &index)) != NULL; cmd += index, index=0) {
+ for (ix = 0, tmpcmd = cmd;
+ (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
if (*tmpcmd == '\0')
break;
retval = glob(tmpcmd, flags, NULL, &expand_result);
@@ -1096,11 +1096,11 @@
case '0':case '1':case '2':case '3':case '4':
case '5':case '6':case '7':case '8':case '9':
{
- int index=*(dst + 1)-48;
- if (index >= argc) {
+ int ixx=*(dst + 1)-48;
+ if (ixx >= argc) {
var='\0';
} else {
- var = argv[index];
+ var = argv[ixx];
}
}
break;
@@ -1575,19 +1575,19 @@
static void insert_job(struct job *newjob, int inbg)
{
struct job *thejob;
- struct jobset *job_list=newjob->job_list;
+ struct jobset *j_list=newjob->job_list;
/* find the ID for thejob to use */
newjob->jobid = 1;
- for (thejob = job_list->head; thejob; thejob = thejob->next)
+ for (thejob = j_list->head; thejob; thejob = thejob->next)
if (thejob->jobid >= newjob->jobid)
newjob->jobid = thejob->jobid + 1;
/* add thejob to the list of running jobs */
- if (!job_list->head) {
- thejob = job_list->head = xmalloc(sizeof(*thejob));
+ if (!j_list->head) {
+ thejob = j_list->head = xmalloc(sizeof(*thejob));
} else {
- for (thejob = job_list->head; thejob->next; thejob = thejob->next) /* nothing */;
+ for (thejob = j_list->head; thejob->next; thejob = thejob->next) /* nothing */;
thejob->next = xmalloc(sizeof(*thejob));
thejob = thejob->next;
}
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index d0e1773..52642e3 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -477,8 +477,6 @@
int sock_fd;
fd_set fds;
- RESERVE_BB_BUFFER(lfile, BUFSIZ);
-
/* Set up signal handlers. */
signal (SIGINT, quit_signal);
signal (SIGTERM, quit_signal);
diff --git a/syslogd.c b/syslogd.c
index d0e1773..52642e3 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -477,8 +477,6 @@
int sock_fd;
fd_set fds;
- RESERVE_BB_BUFFER(lfile, BUFSIZ);
-
/* Set up signal handlers. */
signal (SIGINT, quit_signal);
signal (SIGTERM, quit_signal);
diff --git a/tr.c b/tr.c
index b7a6009..ddb7387 100644
--- a/tr.c
+++ b/tr.c
@@ -123,19 +123,19 @@
static int complement(unsigned char *buffer, int buffer_len)
{
- register short i, j, index;
+ register short i, j, ix;
char conv[ASCII + 2];
- index = 0;
+ ix = 0;
for (i = 0; i <= ASCII; i++) {
for (j = 0; j < buffer_len; j++)
if (buffer[j] == i)
break;
if (j == buffer_len)
- conv[index++] = i & ASCII;
+ conv[ix++] = i & ASCII;
}
- memcpy(buffer, conv, index);
- return index;
+ memcpy(buffer, conv, ix);
+ return ix;
}
extern int tr_main(int argc, char **argv)
diff --git a/umount.c b/umount.c
index 2868a1b..cc7d38d 100644
--- a/umount.c
+++ b/umount.c
@@ -57,7 +57,9 @@
#if defined BB_FEATURE_MOUNT_LOOP
static int freeLoop = TRUE;
#endif
+#if defined BB_MTAB
static int useMtab = TRUE;
+#endif
static int umountAll = FALSE;
static int doRemount = FALSE;
extern const char mtab_file[]; /* Defined in utility.c */
@@ -162,7 +164,7 @@
}
#endif
-static int do_umount(const char *name, int useMtab)
+static int do_umount(const char *name)
{
int status;
char *blockDevice = mtab_getinfo(name, MTAB_GETDEVICE);
@@ -204,7 +206,7 @@
return (FALSE);
}
-static int umount_all(int useMtab)
+static int umount_all(void)
{
int status = TRUE;
char *mountpt;
@@ -214,14 +216,14 @@
/* Never umount /proc on a umount -a */
if (strstr(mountpt, "proc")!= NULL)
continue;
- if (!do_umount(mountpt, useMtab)) {
+ if (!do_umount(mountpt)) {
/* Don't bother retrying the umount on busy devices */
if (errno == EBUSY) {
perror_msg("%s", mountpt);
status = FALSE;
continue;
}
- if (!do_umount(mountpt, useMtab)) {
+ if (!do_umount(mountpt)) {
printf("Couldn't umount %s on %s: %s\n",
mountpt, mtab_getinfo(mountpt, MTAB_GETDEVICE),
strerror(errno));
@@ -275,12 +277,12 @@
mtab_read();
if (umountAll == TRUE) {
- if (umount_all(useMtab) == TRUE)
+ if (umount_all() == TRUE)
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
}
- if (do_umount(*argv, useMtab) == TRUE)
+ if (do_umount(*argv) == TRUE)
return EXIT_SUCCESS;
perror_msg_and_die("%s", *argv);
}
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index bd0c8a6..a2421fc 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -1439,18 +1439,18 @@
check();
}
if (verbose) {
- int i, free;
+ int i, free_cnt;
- for (i = 1, free = 0; i <= INODES; i++)
+ for (i = 1, free_cnt = 0; i <= INODES; i++)
if (!inode_in_use(i))
- free++;
- printf("\n%6ld inodes used (%ld%%)\n", (INODES - free),
- 100 * (INODES - free) / INODES);
- for (i = FIRSTZONE, free = 0; i < ZONES; i++)
+ free_cnt++;
+ printf("\n%6ld inodes used (%ld%%)\n", (INODES - free_cnt),
+ 100 * (INODES - free_cnt) / INODES);
+ for (i = FIRSTZONE, free_cnt = 0; i < ZONES; i++)
if (!zone_in_use(i))
- free++;
- printf("%6ld zones used (%ld%%)\n", (ZONES - free),
- 100 * (ZONES - free) / ZONES);
+ free_cnt++;
+ printf("%6ld zones used (%ld%%)\n", (ZONES - free_cnt),
+ 100 * (ZONES - free_cnt) / ZONES);
printf("\n%6d regular files\n"
"%6d directories\n"
"%6d character device files\n"
diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c
index cd81510..6643ed5 100644
--- a/util-linux/nfsmount.c
+++ b/util-linux/nfsmount.c
@@ -157,7 +157,7 @@
#define HAVE_personality
#define HAVE_tm_gmtoff
-static char *nfs_strerror(int stat);
+static char *nfs_strerror(int status);
#define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
@@ -873,16 +873,16 @@
{ -1, EIO }
};
-static char *nfs_strerror(int stat)
+static char *nfs_strerror(int status)
{
int i;
static char buf[256];
for (i = 0; nfs_errtbl[i].stat != -1; i++) {
- if (nfs_errtbl[i].stat == stat)
+ if (nfs_errtbl[i].stat == status)
return strerror(nfs_errtbl[i].errnum);
}
- sprintf(buf, _("unknown nfs status return value: %d"), stat);
+ sprintf(buf, _("unknown nfs status return value: %d"), status);
return buf;
}
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index 5f31282..ead1e7c 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -40,7 +40,7 @@
static time_t askremotedate(const char *host)
{
struct hostent *h;
- struct sockaddr_in sin;
+ struct sockaddr_in s_in;
struct servent *tserv;
unsigned long int nett, localt;
int fd;
@@ -54,11 +54,11 @@
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */
perror_msg_and_die("%s", "socket");
- memcpy(&sin.sin_addr, h->h_addr, sizeof(sin.sin_addr));
- sin.sin_port= tserv->s_port;
- sin.sin_family = AF_INET;
+ memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr));
+ s_in.sin_port= tserv->s_port;
+ s_in.sin_family = AF_INET;
- if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) /* connect to time server */
+ if (connect(fd, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) /* connect to time server */
perror_msg_and_die("%s", host);
if (read(fd, (void *)&nett, 4) != 4) /* read time from server */
@@ -79,7 +79,7 @@
int rdate_main(int argc, char **argv)
{
- time_t time;
+ time_t remote_time;
int opt;
int setdate = 0;
int printdate= 0;
@@ -111,15 +111,15 @@
if (optind == argc)
show_usage();
- time = askremotedate(argv[optind]);
+ remote_time = askremotedate(argv[optind]);
if (setdate) {
- if (stime(&time) < 0)
+ if (stime(&remote_time) < 0)
perror_msg_and_die("Could not set time of day");
}
if (printdate)
- printf("%s", ctime(&time));
+ printf("%s", ctime(&remote_time));
return EXIT_SUCCESS;
}
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 2868a1b..cc7d38d 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -57,7 +57,9 @@
#if defined BB_FEATURE_MOUNT_LOOP
static int freeLoop = TRUE;
#endif
+#if defined BB_MTAB
static int useMtab = TRUE;
+#endif
static int umountAll = FALSE;
static int doRemount = FALSE;
extern const char mtab_file[]; /* Defined in utility.c */
@@ -162,7 +164,7 @@
}
#endif
-static int do_umount(const char *name, int useMtab)
+static int do_umount(const char *name)
{
int status;
char *blockDevice = mtab_getinfo(name, MTAB_GETDEVICE);
@@ -204,7 +206,7 @@
return (FALSE);
}
-static int umount_all(int useMtab)
+static int umount_all(void)
{
int status = TRUE;
char *mountpt;
@@ -214,14 +216,14 @@
/* Never umount /proc on a umount -a */
if (strstr(mountpt, "proc")!= NULL)
continue;
- if (!do_umount(mountpt, useMtab)) {
+ if (!do_umount(mountpt)) {
/* Don't bother retrying the umount on busy devices */
if (errno == EBUSY) {
perror_msg("%s", mountpt);
status = FALSE;
continue;
}
- if (!do_umount(mountpt, useMtab)) {
+ if (!do_umount(mountpt)) {
printf("Couldn't umount %s on %s: %s\n",
mountpt, mtab_getinfo(mountpt, MTAB_GETDEVICE),
strerror(errno));
@@ -275,12 +277,12 @@
mtab_read();
if (umountAll == TRUE) {
- if (umount_all(useMtab) == TRUE)
+ if (umount_all() == TRUE)
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
}
- if (do_umount(*argv, useMtab) == TRUE)
+ if (do_umount(*argv) == TRUE)
return EXIT_SUCCESS;
perror_msg_and_die("%s", *argv);
}
diff --git a/wget.c b/wget.c
index 85023f9..f62d835 100644
--- a/wget.c
+++ b/wget.c
@@ -291,24 +291,24 @@
FILE *open_socket(char *host, int port)
{
- struct sockaddr_in sin;
+ struct sockaddr_in s_in;
struct hostent *hp;
int fd;
FILE *fp;
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
+ memset(&s_in, 0, sizeof(s_in));
+ s_in.sin_family = AF_INET;
if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
error_msg_and_die("cannot resolve %s", host);
- memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length);
- sin.sin_port = htons(port);
+ memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length);
+ s_in.sin_port = htons(port);
/*
* Get the server onto a stdio stream.
*/
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
perror_msg_and_die("socket()");
- if (connect(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
+ if (connect(fd, (struct sockaddr *) &s_in, sizeof(s_in)) < 0)
perror_msg_and_die("connect(%s)", host);
if ((fp = fdopen(fd, "r+")) == NULL)
perror_msg_and_die("fdopen()");
@@ -534,7 +534,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: wget.c,v 1.29 2001/03/09 21:24:12 andersen Exp $
+ * $Id: wget.c,v 1.30 2001/03/21 07:34:26 andersen Exp $
*/