A nice patch from Larry Doolittle that adds -Wshadow and

cleans up most of the now-revealed problems.
This commit is contained in:
Eric Andersen 2001-03-21 07:34:27 +00:00
parent 7447642a47
commit 1ca20a7747
28 changed files with 221 additions and 222 deletions

View File

@ -108,7 +108,7 @@ STRIPTOOL = $(CROSS)strip
OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo "-Os"; else echo "-O2" ; fi) then echo "-Os"; else echo "-O2" ; fi)
WARNINGS = -Wall WARNINGS = -Wall -Wshadow
ARFLAGS = -r ARFLAGS = -r

View File

@ -45,7 +45,7 @@ static const struct suffix_mult dd_suffixes[] = {
int dd_main(int argc, char **argv) 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 in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1; size_t bs = 512, count = -1;
ssize_t n; ssize_t n;
@ -73,7 +73,7 @@ int dd_main(int argc, char **argv)
trunc = FALSE; trunc = FALSE;
buf += 7; buf += 7;
} else if (strncmp("sync", buf, 4) == 0) { } else if (strncmp("sync", buf, 4) == 0) {
sync = TRUE; sync_flag = TRUE;
buf += 4; buf += 4;
} else { } else {
error_msg_and_die("invalid conversion `%s'", argv[i]+5); error_msg_and_die("invalid conversion `%s'", argv[i]+5);
@ -138,7 +138,7 @@ int dd_main(int argc, char **argv)
in_full++; in_full++;
else else
in_part++; in_part++;
if (sync) { if (sync_flag) {
memset(buf + n, '\0', bs - n); memset(buf + n, '\0', bs - n);
n = bs; n = bs;
} }

View File

@ -40,7 +40,7 @@ echo_main(int argc, char** argv)
while (argc > 0 && *argv[0] == '-') while (argc > 0 && *argv[0] == '-')
{ {
register char *temp; register char *temp;
register int index; register int ix;
/* /*
* If it appears that we are handling options, then make sure * If it appears that we are handling options, then make sure
@ -49,9 +49,9 @@ echo_main(int argc, char** argv)
*/ */
temp = argv[0] + 1; 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; goto just_echo;
} }

View File

@ -123,19 +123,19 @@ static unsigned int expand(char *arg, register unsigned char *buffer)
static int complement(unsigned char *buffer, int buffer_len) static int complement(unsigned char *buffer, int buffer_len)
{ {
register short i, j, index; register short i, j, ix;
char conv[ASCII + 2]; char conv[ASCII + 2];
index = 0; ix = 0;
for (i = 0; i <= ASCII; i++) { for (i = 0; i <= ASCII; i++) {
for (j = 0; j < buffer_len; j++) for (j = 0; j < buffer_len; j++)
if (buffer[j] == i) if (buffer[j] == i)
break; break;
if (j == buffer_len) if (j == buffer_len)
conv[index++] = i & ASCII; conv[ix++] = i & ASCII;
} }
memcpy(buffer, conv, index); memcpy(buffer, conv, ix);
return index; return ix;
} }
extern int tr_main(int argc, char **argv) extern int tr_main(int argc, char **argv)

6
dd.c
View File

@ -45,7 +45,7 @@ static const struct suffix_mult dd_suffixes[] = {
int dd_main(int argc, char **argv) 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 in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1; size_t bs = 512, count = -1;
ssize_t n; ssize_t n;
@ -73,7 +73,7 @@ int dd_main(int argc, char **argv)
trunc = FALSE; trunc = FALSE;
buf += 7; buf += 7;
} else if (strncmp("sync", buf, 4) == 0) { } else if (strncmp("sync", buf, 4) == 0) {
sync = TRUE; sync_flag = TRUE;
buf += 4; buf += 4;
} else { } else {
error_msg_and_die("invalid conversion `%s'", argv[i]+5); error_msg_and_die("invalid conversion `%s'", argv[i]+5);
@ -138,7 +138,7 @@ int dd_main(int argc, char **argv)
in_full++; in_full++;
else else
in_part++; in_part++;
if (sync) { if (sync_flag) {
memset(buf + n, '\0', bs - n); memset(buf + n, '\0', bs - n);
n = bs; n = bs;
} }

6
echo.c
View File

@ -40,7 +40,7 @@ echo_main(int argc, char** argv)
while (argc > 0 && *argv[0] == '-') while (argc > 0 && *argv[0] == '-')
{ {
register char *temp; register char *temp;
register int index; register int ix;
/* /*
* If it appears that we are handling options, then make sure * If it appears that we are handling options, then make sure
@ -49,9 +49,9 @@ echo_main(int argc, char** argv)
*/ */
temp = argv[0] + 1; 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; goto just_echo;
} }

View File

@ -1439,18 +1439,18 @@ extern int fsck_minix_main(int argc, char **argv)
check(); check();
} }
if (verbose) { 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)) if (!inode_in_use(i))
free++; free_cnt++;
printf("\n%6ld inodes used (%ld%%)\n", (INODES - free), printf("\n%6ld inodes used (%ld%%)\n", (INODES - free_cnt),
100 * (INODES - free) / INODES); 100 * (INODES - free_cnt) / INODES);
for (i = FIRSTZONE, free = 0; i < ZONES; i++) for (i = FIRSTZONE, free_cnt = 0; i < ZONES; i++)
if (!zone_in_use(i)) if (!zone_in_use(i))
free++; free_cnt++;
printf("%6ld zones used (%ld%%)\n", (ZONES - free), printf("%6ld zones used (%ld%%)\n", (ZONES - free_cnt),
100 * (ZONES - free) / ZONES); 100 * (ZONES - free_cnt) / ZONES);
printf("\n%6d regular files\n" printf("\n%6d regular files\n"
"%6d directories\n" "%6d directories\n"
"%6d character device files\n" "%6d character device files\n"

1
init.c
View File

@ -512,7 +512,6 @@ static pid_t run(char *command, char *terminal, int get_enter)
*/ */
if (*cmdpath == '-') { if (*cmdpath == '-') {
char *s;
/* skip over the dash */ /* skip over the dash */
++cmdpath; ++cmdpath;

View File

@ -512,7 +512,6 @@ static pid_t run(char *command, char *terminal, int get_enter)
*/ */
if (*cmdpath == '-') { if (*cmdpath == '-') {
char *s;
/* skip over the dash */ /* skip over the dash */
++cmdpath; ++cmdpath;

70
lash.c
View File

@ -687,16 +687,16 @@ static void free_job(struct job *cmd)
cmd->job_list = keep; cmd->job_list = keep;
} }
/* remove a job from the job_list */ /* remove a job from a jobset */
static void remove_job(struct jobset *job_list, struct job *job) static void remove_job(struct jobset *j_list, struct job *job)
{ {
struct job *prevjob; struct job *prevjob;
free_job(job); free_job(job);
if (job == job_list->head) { if (job == j_list->head) {
job_list->head = job->next; j_list->head = job->next;
} else { } else {
prevjob = job_list->head; prevjob = j_list->head;
while (prevjob->next != job) while (prevjob->next != job)
prevjob = prevjob->next; prevjob = prevjob->next;
prevjob->next = job->next; prevjob->next = job->next;
@ -707,7 +707,7 @@ static void remove_job(struct jobset *job_list, struct job *job)
/* Checks to see if any background processes have exited -- if they /* Checks to see if any background processes have exited -- if they
have, figure out why and see if a job has completed */ 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; struct job *job;
pid_t childpid; pid_t childpid;
@ -715,7 +715,7 @@ static void checkjobs(struct jobset *job_list)
int prognum = 0; int prognum = 0;
while ((childpid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 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; prognum = 0;
while (prognum < job->num_progs && while (prognum < job->num_progs &&
job->progs[prognum].pid != childpid) prognum++; job->progs[prognum].pid != childpid) prognum++;
@ -734,7 +734,7 @@ static void checkjobs(struct jobset *job_list)
if (!job->running_progs) { if (!job->running_progs) {
printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text); printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text);
remove_job(job_list, job); remove_job(j_list, job);
} }
} else { } else {
/* child stopped */ /* child stopped */
@ -907,35 +907,35 @@ static char* itoa(register int i)
#endif #endif
#if defined BB_FEATURE_SH_ENVIRONMENT && ! defined BB_FEATURE_SH_WORDEXP #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; char *token, *begin;
begin = string; begin = string;
/* Short circuit the trivial case */ /* Short circuit the trivial case */
if ( !string || ! string[*index]) if ( !string || ! string[*ix])
return NULL; return NULL;
/* Find the end of the token. */ /* Find the end of the token. */
while( string && string[*index] && !isspace(string[*index]) ) { while( string && string[*ix] && !isspace(string[*ix]) ) {
(*index)++; (*ix)++;
} }
/* Find the end of any whitespace trailing behind /* Find the end of any whitespace trailing behind
* the token and let that be part of the token */ * the token and let that be part of the token */
while( string && string[*index] && isspace(string[*index]) ) { while( string && string[*ix] && isspace(string[*ix]) ) {
(*index)++; (*ix)++;
} }
if (! string && *index==0) { if (! string && *ix==0) {
/* Nothing useful was found */ /* Nothing useful was found */
return NULL; return NULL;
} }
token = xmalloc(*index+1); token = xmalloc(*ix+1);
token[*index] = '\0'; token[*ix] = '\0';
strncpy(token, string, *index); strncpy(token, string, *ix);
return token; return token;
} }
@ -947,7 +947,7 @@ static int expand_arguments(char *command)
#ifdef BB_FEATURE_SH_ENVIRONMENT #ifdef BB_FEATURE_SH_ENVIRONMENT
expand_t expand_result; expand_t expand_result;
char *src, *dst, *var; char *src, *dst, *var;
int index = 0; int ix = 0;
int i=0, length, total_length=0, retval; int i=0, length, total_length=0, retval;
const char *out_of_space = "out of space during expansion"; const char *out_of_space = "out of space during expansion";
#endif #endif
@ -956,13 +956,13 @@ static int expand_arguments(char *command)
chomp(command); chomp(command);
/* Fix up escape sequences to be the Real Thing(tm) */ /* Fix up escape sequences to be the Real Thing(tm) */
while( command && command[index]) { while( command && command[ix]) {
if (command[index] == '\\') { if (command[ix] == '\\') {
char *tmp = command+index+1; char *tmp = command+ix+1;
command[index] = process_escape_sequence( &tmp ); command[ix] = process_escape_sequence( &tmp );
memmove(command+index + 1, tmp, strlen(tmp)+1); memmove(command+ix + 1, tmp, strlen(tmp)+1);
} }
index++; ix++;
} }
#ifdef BB_FEATURE_SH_ENVIRONMENT #ifdef BB_FEATURE_SH_ENVIRONMENT
@ -1025,8 +1025,8 @@ static int expand_arguments(char *command)
* we write stuff into the original (in a minute) */ * we write stuff into the original (in a minute) */
cmd = cmd_copy = strdup(command); cmd = cmd_copy = strdup(command);
*command = '\0'; *command = '\0';
for (index = 0, tmpcmd = cmd; for (ix = 0, tmpcmd = cmd;
(tmpcmd = strsep_space(cmd, &index)) != NULL; cmd += index, index=0) { (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
if (*tmpcmd == '\0') if (*tmpcmd == '\0')
break; break;
retval = glob(tmpcmd, flags, NULL, &expand_result); retval = glob(tmpcmd, flags, NULL, &expand_result);
@ -1096,11 +1096,11 @@ static int expand_arguments(char *command)
case '0':case '1':case '2':case '3':case '4': case '0':case '1':case '2':case '3':case '4':
case '5':case '6':case '7':case '8':case '9': case '5':case '6':case '7':case '8':case '9':
{ {
int index=*(dst + 1)-48; int ixx=*(dst + 1)-48;
if (index >= argc) { if (ixx >= argc) {
var='\0'; var='\0';
} else { } else {
var = argv[index]; var = argv[ixx];
} }
} }
break; break;
@ -1575,19 +1575,19 @@ static int pseudo_exec(struct child_prog *child)
static void insert_job(struct job *newjob, int inbg) static void insert_job(struct job *newjob, int inbg)
{ {
struct job *thejob; struct job *thejob;
struct jobset *job_list=newjob->job_list; struct jobset *j_list=newjob->job_list;
/* find the ID for thejob to use */ /* find the ID for thejob to use */
newjob->jobid = 1; 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) if (thejob->jobid >= newjob->jobid)
newjob->jobid = thejob->jobid + 1; newjob->jobid = thejob->jobid + 1;
/* add thejob to the list of running jobs */ /* add thejob to the list of running jobs */
if (!job_list->head) { if (!j_list->head) {
thejob = job_list->head = xmalloc(sizeof(*thejob)); thejob = j_list->head = xmalloc(sizeof(*thejob));
} else { } 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->next = xmalloc(sizeof(*thejob));
thejob = thejob->next; thejob = thejob->next;
} }

View File

@ -50,8 +50,8 @@ extern int parse_mode(const char *s, mode_t * theMode)
S_ISVTX /* t */ S_ISVTX /* t */
}; };
static const char group_string[] = "ugoa"; static const char group_chars[] = "ugoa";
static const char mode_string[] = "rwxst"; static const char mode_chars[] = "rwxst";
const char *p; const char *p;
@ -74,9 +74,9 @@ extern int parse_mode(const char *s, mode_t * theMode)
if ((c = *s++) == '\0') { if ((c = *s++) == '\0') {
return -1; return -1;
} }
for (p=group_string ; *p ; p++) { for (p=group_chars ; *p ; p++) {
if (*p == c) { if (*p == c) {
groups |= group_set[(int)(p-group_string)]; groups |= group_set[(int)(p-group_chars)];
goto NEXT_GROUP; goto NEXT_GROUP;
} }
} }
@ -101,9 +101,9 @@ extern int parse_mode(const char *s, mode_t * theMode)
NEXT_MODE: NEXT_MODE:
if (((c = *s++) != '\0') && (c != ',')) { if (((c = *s++) != '\0') && (c != ',')) {
for (p=mode_string ; *p ; p++) { for (p=mode_chars ; *p ; p++) {
if (*p == c) { if (*p == c) {
mode |= mode_set[(int)(p-mode_string)]; mode |= mode_set[(int)(p-mode_chars)];
goto NEXT_MODE; goto NEXT_MODE;
} }
} }

View File

@ -26,6 +26,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <dirent.h> #include <dirent.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "libbb.h" #include "libbb.h"

View File

@ -15,7 +15,7 @@
* Foundation; either version 2 of the License, or (at * Foundation; either version 2 of the License, or (at
* your option) any later version. * 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> * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
* adjustments by Larry Doolittle <LRDoolittle@lbl.gov> * adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
@ -60,18 +60,18 @@
static int static int
INET_resolve(char *name, struct sockaddr *sa) 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; s_in->sin_family = AF_INET;
sin->sin_port = 0; s_in->sin_port = 0;
/* Default is special, meaning 0.0.0.0. */ /* Default is special, meaning 0.0.0.0. */
if (strcmp(name, "default")==0) { if (strcmp(name, "default")==0) {
sin->sin_addr.s_addr = INADDR_ANY; s_in->sin_addr.s_addr = INADDR_ANY;
return 1; return 1;
} }
/* Look to see if it's a dotted quad. */ /* 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; return 0;
} }
/* guess not.. */ /* guess not.. */

View File

@ -291,24 +291,24 @@ void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path)
FILE *open_socket(char *host, int port) FILE *open_socket(char *host, int port)
{ {
struct sockaddr_in sin; struct sockaddr_in s_in;
struct hostent *hp; struct hostent *hp;
int fd; int fd;
FILE *fp; FILE *fp;
memset(&sin, 0, sizeof(sin)); memset(&s_in, 0, sizeof(s_in));
sin.sin_family = AF_INET; s_in.sin_family = AF_INET;
if ((hp = (struct hostent *) gethostbyname(host)) == NULL) if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
error_msg_and_die("cannot resolve %s", host); error_msg_and_die("cannot resolve %s", host);
memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length); memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length);
sin.sin_port = htons(port); s_in.sin_port = htons(port);
/* /*
* Get the server onto a stdio stream. * Get the server onto a stdio stream.
*/ */
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
perror_msg_and_die("socket()"); 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); perror_msg_and_die("connect(%s)", host);
if ((fp = fdopen(fd, "r+")) == NULL) if ((fp = fdopen(fd, "r+")) == NULL)
perror_msg_and_die("fdopen()"); perror_msg_and_die("fdopen()");
@ -534,7 +534,7 @@ progressmeter(int flag)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 $
*/ */

View File

@ -157,7 +157,7 @@ static const int NFS_MOUNT_NONLM = 0x0200; /* 3 */
#define HAVE_personality #define HAVE_personality
#define HAVE_tm_gmtoff #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 MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2) #define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
@ -873,16 +873,16 @@ static struct {
{ -1, EIO } { -1, EIO }
}; };
static char *nfs_strerror(int stat) static char *nfs_strerror(int status)
{ {
int i; int i;
static char buf[256]; static char buf[256];
for (i = 0; nfs_errtbl[i].stat != -1; i++) { 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); 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; return buf;
} }

18
rdate.c
View File

@ -40,7 +40,7 @@ static const int RFC_868_BIAS = 2208988800UL;
static time_t askremotedate(const char *host) static time_t askremotedate(const char *host)
{ {
struct hostent *h; struct hostent *h;
struct sockaddr_in sin; struct sockaddr_in s_in;
struct servent *tserv; struct servent *tserv;
unsigned long int nett, localt; unsigned long int nett, localt;
int fd; int fd;
@ -54,11 +54,11 @@ static time_t askremotedate(const char *host)
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */
perror_msg_and_die("%s", "socket"); perror_msg_and_die("%s", "socket");
memcpy(&sin.sin_addr, h->h_addr, sizeof(sin.sin_addr)); memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr));
sin.sin_port= tserv->s_port; s_in.sin_port= tserv->s_port;
sin.sin_family = AF_INET; 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); perror_msg_and_die("%s", host);
if (read(fd, (void *)&nett, 4) != 4) /* read time from server */ if (read(fd, (void *)&nett, 4) != 4) /* read time from server */
@ -79,7 +79,7 @@ static time_t askremotedate(const char *host)
int rdate_main(int argc, char **argv) int rdate_main(int argc, char **argv)
{ {
time_t time; time_t remote_time;
int opt; int opt;
int setdate = 0; int setdate = 0;
int printdate= 0; int printdate= 0;
@ -111,15 +111,15 @@ int rdate_main(int argc, char **argv)
if (optind == argc) if (optind == argc)
show_usage(); show_usage();
time = askremotedate(argv[optind]); remote_time = askremotedate(argv[optind]);
if (setdate) { if (setdate) {
if (stime(&time) < 0) if (stime(&remote_time) < 0)
perror_msg_and_die("Could not set time of day"); perror_msg_and_die("Could not set time of day");
} }
if (printdate) if (printdate)
printf("%s", ctime(&time)); printf("%s", ctime(&remote_time));
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

12
route.c
View File

@ -15,7 +15,7 @@
* Foundation; either version 2 of the License, or (at * Foundation; either version 2 of the License, or (at
* your option) any later version. * 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> * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
* adjustments by Larry Doolittle <LRDoolittle@lbl.gov> * adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
@ -60,18 +60,18 @@
static int static int
INET_resolve(char *name, struct sockaddr *sa) 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; s_in->sin_family = AF_INET;
sin->sin_port = 0; s_in->sin_port = 0;
/* Default is special, meaning 0.0.0.0. */ /* Default is special, meaning 0.0.0.0. */
if (strcmp(name, "default")==0) { if (strcmp(name, "default")==0) {
sin->sin_addr.s_addr = INADDR_ANY; s_in->sin_addr.s_addr = INADDR_ANY;
return 1; return 1;
} }
/* Look to see if it's a dotted quad. */ /* 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; return 0;
} }
/* guess not.. */ /* guess not.. */

70
sh.c
View File

@ -687,16 +687,16 @@ static void free_job(struct job *cmd)
cmd->job_list = keep; cmd->job_list = keep;
} }
/* remove a job from the job_list */ /* remove a job from a jobset */
static void remove_job(struct jobset *job_list, struct job *job) static void remove_job(struct jobset *j_list, struct job *job)
{ {
struct job *prevjob; struct job *prevjob;
free_job(job); free_job(job);
if (job == job_list->head) { if (job == j_list->head) {
job_list->head = job->next; j_list->head = job->next;
} else { } else {
prevjob = job_list->head; prevjob = j_list->head;
while (prevjob->next != job) while (prevjob->next != job)
prevjob = prevjob->next; prevjob = prevjob->next;
prevjob->next = job->next; prevjob->next = job->next;
@ -707,7 +707,7 @@ static void remove_job(struct jobset *job_list, struct job *job)
/* Checks to see if any background processes have exited -- if they /* Checks to see if any background processes have exited -- if they
have, figure out why and see if a job has completed */ 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; struct job *job;
pid_t childpid; pid_t childpid;
@ -715,7 +715,7 @@ static void checkjobs(struct jobset *job_list)
int prognum = 0; int prognum = 0;
while ((childpid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 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; prognum = 0;
while (prognum < job->num_progs && while (prognum < job->num_progs &&
job->progs[prognum].pid != childpid) prognum++; job->progs[prognum].pid != childpid) prognum++;
@ -734,7 +734,7 @@ static void checkjobs(struct jobset *job_list)
if (!job->running_progs) { if (!job->running_progs) {
printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text); printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text);
remove_job(job_list, job); remove_job(j_list, job);
} }
} else { } else {
/* child stopped */ /* child stopped */
@ -907,35 +907,35 @@ static char* itoa(register int i)
#endif #endif
#if defined BB_FEATURE_SH_ENVIRONMENT && ! defined BB_FEATURE_SH_WORDEXP #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; char *token, *begin;
begin = string; begin = string;
/* Short circuit the trivial case */ /* Short circuit the trivial case */
if ( !string || ! string[*index]) if ( !string || ! string[*ix])
return NULL; return NULL;
/* Find the end of the token. */ /* Find the end of the token. */
while( string && string[*index] && !isspace(string[*index]) ) { while( string && string[*ix] && !isspace(string[*ix]) ) {
(*index)++; (*ix)++;
} }
/* Find the end of any whitespace trailing behind /* Find the end of any whitespace trailing behind
* the token and let that be part of the token */ * the token and let that be part of the token */
while( string && string[*index] && isspace(string[*index]) ) { while( string && string[*ix] && isspace(string[*ix]) ) {
(*index)++; (*ix)++;
} }
if (! string && *index==0) { if (! string && *ix==0) {
/* Nothing useful was found */ /* Nothing useful was found */
return NULL; return NULL;
} }
token = xmalloc(*index+1); token = xmalloc(*ix+1);
token[*index] = '\0'; token[*ix] = '\0';
strncpy(token, string, *index); strncpy(token, string, *ix);
return token; return token;
} }
@ -947,7 +947,7 @@ static int expand_arguments(char *command)
#ifdef BB_FEATURE_SH_ENVIRONMENT #ifdef BB_FEATURE_SH_ENVIRONMENT
expand_t expand_result; expand_t expand_result;
char *src, *dst, *var; char *src, *dst, *var;
int index = 0; int ix = 0;
int i=0, length, total_length=0, retval; int i=0, length, total_length=0, retval;
const char *out_of_space = "out of space during expansion"; const char *out_of_space = "out of space during expansion";
#endif #endif
@ -956,13 +956,13 @@ static int expand_arguments(char *command)
chomp(command); chomp(command);
/* Fix up escape sequences to be the Real Thing(tm) */ /* Fix up escape sequences to be the Real Thing(tm) */
while( command && command[index]) { while( command && command[ix]) {
if (command[index] == '\\') { if (command[ix] == '\\') {
char *tmp = command+index+1; char *tmp = command+ix+1;
command[index] = process_escape_sequence( &tmp ); command[ix] = process_escape_sequence( &tmp );
memmove(command+index + 1, tmp, strlen(tmp)+1); memmove(command+ix + 1, tmp, strlen(tmp)+1);
} }
index++; ix++;
} }
#ifdef BB_FEATURE_SH_ENVIRONMENT #ifdef BB_FEATURE_SH_ENVIRONMENT
@ -1025,8 +1025,8 @@ static int expand_arguments(char *command)
* we write stuff into the original (in a minute) */ * we write stuff into the original (in a minute) */
cmd = cmd_copy = strdup(command); cmd = cmd_copy = strdup(command);
*command = '\0'; *command = '\0';
for (index = 0, tmpcmd = cmd; for (ix = 0, tmpcmd = cmd;
(tmpcmd = strsep_space(cmd, &index)) != NULL; cmd += index, index=0) { (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
if (*tmpcmd == '\0') if (*tmpcmd == '\0')
break; break;
retval = glob(tmpcmd, flags, NULL, &expand_result); retval = glob(tmpcmd, flags, NULL, &expand_result);
@ -1096,11 +1096,11 @@ static int expand_arguments(char *command)
case '0':case '1':case '2':case '3':case '4': case '0':case '1':case '2':case '3':case '4':
case '5':case '6':case '7':case '8':case '9': case '5':case '6':case '7':case '8':case '9':
{ {
int index=*(dst + 1)-48; int ixx=*(dst + 1)-48;
if (index >= argc) { if (ixx >= argc) {
var='\0'; var='\0';
} else { } else {
var = argv[index]; var = argv[ixx];
} }
} }
break; break;
@ -1575,19 +1575,19 @@ static int pseudo_exec(struct child_prog *child)
static void insert_job(struct job *newjob, int inbg) static void insert_job(struct job *newjob, int inbg)
{ {
struct job *thejob; struct job *thejob;
struct jobset *job_list=newjob->job_list; struct jobset *j_list=newjob->job_list;
/* find the ID for thejob to use */ /* find the ID for thejob to use */
newjob->jobid = 1; 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) if (thejob->jobid >= newjob->jobid)
newjob->jobid = thejob->jobid + 1; newjob->jobid = thejob->jobid + 1;
/* add thejob to the list of running jobs */ /* add thejob to the list of running jobs */
if (!job_list->head) { if (!j_list->head) {
thejob = job_list->head = xmalloc(sizeof(*thejob)); thejob = j_list->head = xmalloc(sizeof(*thejob));
} else { } 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->next = xmalloc(sizeof(*thejob));
thejob = thejob->next; thejob = thejob->next;
} }

View File

@ -687,16 +687,16 @@ static void free_job(struct job *cmd)
cmd->job_list = keep; cmd->job_list = keep;
} }
/* remove a job from the job_list */ /* remove a job from a jobset */
static void remove_job(struct jobset *job_list, struct job *job) static void remove_job(struct jobset *j_list, struct job *job)
{ {
struct job *prevjob; struct job *prevjob;
free_job(job); free_job(job);
if (job == job_list->head) { if (job == j_list->head) {
job_list->head = job->next; j_list->head = job->next;
} else { } else {
prevjob = job_list->head; prevjob = j_list->head;
while (prevjob->next != job) while (prevjob->next != job)
prevjob = prevjob->next; prevjob = prevjob->next;
prevjob->next = job->next; prevjob->next = job->next;
@ -707,7 +707,7 @@ static void remove_job(struct jobset *job_list, struct job *job)
/* Checks to see if any background processes have exited -- if they /* Checks to see if any background processes have exited -- if they
have, figure out why and see if a job has completed */ 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; struct job *job;
pid_t childpid; pid_t childpid;
@ -715,7 +715,7 @@ static void checkjobs(struct jobset *job_list)
int prognum = 0; int prognum = 0;
while ((childpid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 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; prognum = 0;
while (prognum < job->num_progs && while (prognum < job->num_progs &&
job->progs[prognum].pid != childpid) prognum++; job->progs[prognum].pid != childpid) prognum++;
@ -734,7 +734,7 @@ static void checkjobs(struct jobset *job_list)
if (!job->running_progs) { if (!job->running_progs) {
printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text); printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text);
remove_job(job_list, job); remove_job(j_list, job);
} }
} else { } else {
/* child stopped */ /* child stopped */
@ -907,35 +907,35 @@ static char* itoa(register int i)
#endif #endif
#if defined BB_FEATURE_SH_ENVIRONMENT && ! defined BB_FEATURE_SH_WORDEXP #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; char *token, *begin;
begin = string; begin = string;
/* Short circuit the trivial case */ /* Short circuit the trivial case */
if ( !string || ! string[*index]) if ( !string || ! string[*ix])
return NULL; return NULL;
/* Find the end of the token. */ /* Find the end of the token. */
while( string && string[*index] && !isspace(string[*index]) ) { while( string && string[*ix] && !isspace(string[*ix]) ) {
(*index)++; (*ix)++;
} }
/* Find the end of any whitespace trailing behind /* Find the end of any whitespace trailing behind
* the token and let that be part of the token */ * the token and let that be part of the token */
while( string && string[*index] && isspace(string[*index]) ) { while( string && string[*ix] && isspace(string[*ix]) ) {
(*index)++; (*ix)++;
} }
if (! string && *index==0) { if (! string && *ix==0) {
/* Nothing useful was found */ /* Nothing useful was found */
return NULL; return NULL;
} }
token = xmalloc(*index+1); token = xmalloc(*ix+1);
token[*index] = '\0'; token[*ix] = '\0';
strncpy(token, string, *index); strncpy(token, string, *ix);
return token; return token;
} }
@ -947,7 +947,7 @@ static int expand_arguments(char *command)
#ifdef BB_FEATURE_SH_ENVIRONMENT #ifdef BB_FEATURE_SH_ENVIRONMENT
expand_t expand_result; expand_t expand_result;
char *src, *dst, *var; char *src, *dst, *var;
int index = 0; int ix = 0;
int i=0, length, total_length=0, retval; int i=0, length, total_length=0, retval;
const char *out_of_space = "out of space during expansion"; const char *out_of_space = "out of space during expansion";
#endif #endif
@ -956,13 +956,13 @@ static int expand_arguments(char *command)
chomp(command); chomp(command);
/* Fix up escape sequences to be the Real Thing(tm) */ /* Fix up escape sequences to be the Real Thing(tm) */
while( command && command[index]) { while( command && command[ix]) {
if (command[index] == '\\') { if (command[ix] == '\\') {
char *tmp = command+index+1; char *tmp = command+ix+1;
command[index] = process_escape_sequence( &tmp ); command[ix] = process_escape_sequence( &tmp );
memmove(command+index + 1, tmp, strlen(tmp)+1); memmove(command+ix + 1, tmp, strlen(tmp)+1);
} }
index++; ix++;
} }
#ifdef BB_FEATURE_SH_ENVIRONMENT #ifdef BB_FEATURE_SH_ENVIRONMENT
@ -1025,8 +1025,8 @@ static int expand_arguments(char *command)
* we write stuff into the original (in a minute) */ * we write stuff into the original (in a minute) */
cmd = cmd_copy = strdup(command); cmd = cmd_copy = strdup(command);
*command = '\0'; *command = '\0';
for (index = 0, tmpcmd = cmd; for (ix = 0, tmpcmd = cmd;
(tmpcmd = strsep_space(cmd, &index)) != NULL; cmd += index, index=0) { (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
if (*tmpcmd == '\0') if (*tmpcmd == '\0')
break; break;
retval = glob(tmpcmd, flags, NULL, &expand_result); retval = glob(tmpcmd, flags, NULL, &expand_result);
@ -1096,11 +1096,11 @@ static int expand_arguments(char *command)
case '0':case '1':case '2':case '3':case '4': case '0':case '1':case '2':case '3':case '4':
case '5':case '6':case '7':case '8':case '9': case '5':case '6':case '7':case '8':case '9':
{ {
int index=*(dst + 1)-48; int ixx=*(dst + 1)-48;
if (index >= argc) { if (ixx >= argc) {
var='\0'; var='\0';
} else { } else {
var = argv[index]; var = argv[ixx];
} }
} }
break; break;
@ -1575,19 +1575,19 @@ static int pseudo_exec(struct child_prog *child)
static void insert_job(struct job *newjob, int inbg) static void insert_job(struct job *newjob, int inbg)
{ {
struct job *thejob; struct job *thejob;
struct jobset *job_list=newjob->job_list; struct jobset *j_list=newjob->job_list;
/* find the ID for thejob to use */ /* find the ID for thejob to use */
newjob->jobid = 1; 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) if (thejob->jobid >= newjob->jobid)
newjob->jobid = thejob->jobid + 1; newjob->jobid = thejob->jobid + 1;
/* add thejob to the list of running jobs */ /* add thejob to the list of running jobs */
if (!job_list->head) { if (!j_list->head) {
thejob = job_list->head = xmalloc(sizeof(*thejob)); thejob = j_list->head = xmalloc(sizeof(*thejob));
} else { } 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->next = xmalloc(sizeof(*thejob));
thejob = thejob->next; thejob = thejob->next;
} }

View File

@ -477,8 +477,6 @@ static void doSyslogd (void)
int sock_fd; int sock_fd;
fd_set fds; fd_set fds;
RESERVE_BB_BUFFER(lfile, BUFSIZ);
/* Set up signal handlers. */ /* Set up signal handlers. */
signal (SIGINT, quit_signal); signal (SIGINT, quit_signal);
signal (SIGTERM, quit_signal); signal (SIGTERM, quit_signal);

View File

@ -477,8 +477,6 @@ static void doSyslogd (void)
int sock_fd; int sock_fd;
fd_set fds; fd_set fds;
RESERVE_BB_BUFFER(lfile, BUFSIZ);
/* Set up signal handlers. */ /* Set up signal handlers. */
signal (SIGINT, quit_signal); signal (SIGINT, quit_signal);
signal (SIGTERM, quit_signal); signal (SIGTERM, quit_signal);

10
tr.c
View File

@ -123,19 +123,19 @@ static unsigned int expand(char *arg, register unsigned char *buffer)
static int complement(unsigned char *buffer, int buffer_len) static int complement(unsigned char *buffer, int buffer_len)
{ {
register short i, j, index; register short i, j, ix;
char conv[ASCII + 2]; char conv[ASCII + 2];
index = 0; ix = 0;
for (i = 0; i <= ASCII; i++) { for (i = 0; i <= ASCII; i++) {
for (j = 0; j < buffer_len; j++) for (j = 0; j < buffer_len; j++)
if (buffer[j] == i) if (buffer[j] == i)
break; break;
if (j == buffer_len) if (j == buffer_len)
conv[index++] = i & ASCII; conv[ix++] = i & ASCII;
} }
memcpy(buffer, conv, index); memcpy(buffer, conv, ix);
return index; return ix;
} }
extern int tr_main(int argc, char **argv) extern int tr_main(int argc, char **argv)

View File

@ -57,7 +57,9 @@ static int doForce = FALSE;
#if defined BB_FEATURE_MOUNT_LOOP #if defined BB_FEATURE_MOUNT_LOOP
static int freeLoop = TRUE; static int freeLoop = TRUE;
#endif #endif
#if defined BB_MTAB
static int useMtab = TRUE; static int useMtab = TRUE;
#endif
static int umountAll = FALSE; static int umountAll = FALSE;
static int doRemount = FALSE; static int doRemount = FALSE;
extern const char mtab_file[]; /* Defined in utility.c */ extern const char mtab_file[]; /* Defined in utility.c */
@ -162,7 +164,7 @@ void mtab_free(void)
} }
#endif #endif
static int do_umount(const char *name, int useMtab) static int do_umount(const char *name)
{ {
int status; int status;
char *blockDevice = mtab_getinfo(name, MTAB_GETDEVICE); char *blockDevice = mtab_getinfo(name, MTAB_GETDEVICE);
@ -204,7 +206,7 @@ static int do_umount(const char *name, int useMtab)
return (FALSE); return (FALSE);
} }
static int umount_all(int useMtab) static int umount_all(void)
{ {
int status = TRUE; int status = TRUE;
char *mountpt; char *mountpt;
@ -214,14 +216,14 @@ static int umount_all(int useMtab)
/* Never umount /proc on a umount -a */ /* Never umount /proc on a umount -a */
if (strstr(mountpt, "proc")!= NULL) if (strstr(mountpt, "proc")!= NULL)
continue; continue;
if (!do_umount(mountpt, useMtab)) { if (!do_umount(mountpt)) {
/* Don't bother retrying the umount on busy devices */ /* Don't bother retrying the umount on busy devices */
if (errno == EBUSY) { if (errno == EBUSY) {
perror_msg("%s", mountpt); perror_msg("%s", mountpt);
status = FALSE; status = FALSE;
continue; continue;
} }
if (!do_umount(mountpt, useMtab)) { if (!do_umount(mountpt)) {
printf("Couldn't umount %s on %s: %s\n", printf("Couldn't umount %s on %s: %s\n",
mountpt, mtab_getinfo(mountpt, MTAB_GETDEVICE), mountpt, mtab_getinfo(mountpt, MTAB_GETDEVICE),
strerror(errno)); strerror(errno));
@ -275,12 +277,12 @@ extern int umount_main(int argc, char **argv)
mtab_read(); mtab_read();
if (umountAll == TRUE) { if (umountAll == TRUE) {
if (umount_all(useMtab) == TRUE) if (umount_all() == TRUE)
return EXIT_SUCCESS; return EXIT_SUCCESS;
else else
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (do_umount(*argv, useMtab) == TRUE) if (do_umount(*argv) == TRUE)
return EXIT_SUCCESS; return EXIT_SUCCESS;
perror_msg_and_die("%s", *argv); perror_msg_and_die("%s", *argv);
} }

View File

@ -1439,18 +1439,18 @@ extern int fsck_minix_main(int argc, char **argv)
check(); check();
} }
if (verbose) { 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)) if (!inode_in_use(i))
free++; free_cnt++;
printf("\n%6ld inodes used (%ld%%)\n", (INODES - free), printf("\n%6ld inodes used (%ld%%)\n", (INODES - free_cnt),
100 * (INODES - free) / INODES); 100 * (INODES - free_cnt) / INODES);
for (i = FIRSTZONE, free = 0; i < ZONES; i++) for (i = FIRSTZONE, free_cnt = 0; i < ZONES; i++)
if (!zone_in_use(i)) if (!zone_in_use(i))
free++; free_cnt++;
printf("%6ld zones used (%ld%%)\n", (ZONES - free), printf("%6ld zones used (%ld%%)\n", (ZONES - free_cnt),
100 * (ZONES - free) / ZONES); 100 * (ZONES - free_cnt) / ZONES);
printf("\n%6d regular files\n" printf("\n%6d regular files\n"
"%6d directories\n" "%6d directories\n"
"%6d character device files\n" "%6d character device files\n"

View File

@ -157,7 +157,7 @@ static const int NFS_MOUNT_NONLM = 0x0200; /* 3 */
#define HAVE_personality #define HAVE_personality
#define HAVE_tm_gmtoff #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 MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r))
#define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2) #define MAX_NFSPROT ((nfs_mount_version >= 4) ? 3 : 2)
@ -873,16 +873,16 @@ static struct {
{ -1, EIO } { -1, EIO }
}; };
static char *nfs_strerror(int stat) static char *nfs_strerror(int status)
{ {
int i; int i;
static char buf[256]; static char buf[256];
for (i = 0; nfs_errtbl[i].stat != -1; i++) { 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); 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; return buf;
} }

View File

@ -40,7 +40,7 @@ static const int RFC_868_BIAS = 2208988800UL;
static time_t askremotedate(const char *host) static time_t askremotedate(const char *host)
{ {
struct hostent *h; struct hostent *h;
struct sockaddr_in sin; struct sockaddr_in s_in;
struct servent *tserv; struct servent *tserv;
unsigned long int nett, localt; unsigned long int nett, localt;
int fd; int fd;
@ -54,11 +54,11 @@ static time_t askremotedate(const char *host)
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) /* get net connection */
perror_msg_and_die("%s", "socket"); perror_msg_and_die("%s", "socket");
memcpy(&sin.sin_addr, h->h_addr, sizeof(sin.sin_addr)); memcpy(&s_in.sin_addr, h->h_addr, sizeof(s_in.sin_addr));
sin.sin_port= tserv->s_port; s_in.sin_port= tserv->s_port;
sin.sin_family = AF_INET; 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); perror_msg_and_die("%s", host);
if (read(fd, (void *)&nett, 4) != 4) /* read time from server */ if (read(fd, (void *)&nett, 4) != 4) /* read time from server */
@ -79,7 +79,7 @@ static time_t askremotedate(const char *host)
int rdate_main(int argc, char **argv) int rdate_main(int argc, char **argv)
{ {
time_t time; time_t remote_time;
int opt; int opt;
int setdate = 0; int setdate = 0;
int printdate= 0; int printdate= 0;
@ -111,15 +111,15 @@ int rdate_main(int argc, char **argv)
if (optind == argc) if (optind == argc)
show_usage(); show_usage();
time = askremotedate(argv[optind]); remote_time = askremotedate(argv[optind]);
if (setdate) { if (setdate) {
if (stime(&time) < 0) if (stime(&remote_time) < 0)
perror_msg_and_die("Could not set time of day"); perror_msg_and_die("Could not set time of day");
} }
if (printdate) if (printdate)
printf("%s", ctime(&time)); printf("%s", ctime(&remote_time));
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -57,7 +57,9 @@ static int doForce = FALSE;
#if defined BB_FEATURE_MOUNT_LOOP #if defined BB_FEATURE_MOUNT_LOOP
static int freeLoop = TRUE; static int freeLoop = TRUE;
#endif #endif
#if defined BB_MTAB
static int useMtab = TRUE; static int useMtab = TRUE;
#endif
static int umountAll = FALSE; static int umountAll = FALSE;
static int doRemount = FALSE; static int doRemount = FALSE;
extern const char mtab_file[]; /* Defined in utility.c */ extern const char mtab_file[]; /* Defined in utility.c */
@ -162,7 +164,7 @@ void mtab_free(void)
} }
#endif #endif
static int do_umount(const char *name, int useMtab) static int do_umount(const char *name)
{ {
int status; int status;
char *blockDevice = mtab_getinfo(name, MTAB_GETDEVICE); char *blockDevice = mtab_getinfo(name, MTAB_GETDEVICE);
@ -204,7 +206,7 @@ static int do_umount(const char *name, int useMtab)
return (FALSE); return (FALSE);
} }
static int umount_all(int useMtab) static int umount_all(void)
{ {
int status = TRUE; int status = TRUE;
char *mountpt; char *mountpt;
@ -214,14 +216,14 @@ static int umount_all(int useMtab)
/* Never umount /proc on a umount -a */ /* Never umount /proc on a umount -a */
if (strstr(mountpt, "proc")!= NULL) if (strstr(mountpt, "proc")!= NULL)
continue; continue;
if (!do_umount(mountpt, useMtab)) { if (!do_umount(mountpt)) {
/* Don't bother retrying the umount on busy devices */ /* Don't bother retrying the umount on busy devices */
if (errno == EBUSY) { if (errno == EBUSY) {
perror_msg("%s", mountpt); perror_msg("%s", mountpt);
status = FALSE; status = FALSE;
continue; continue;
} }
if (!do_umount(mountpt, useMtab)) { if (!do_umount(mountpt)) {
printf("Couldn't umount %s on %s: %s\n", printf("Couldn't umount %s on %s: %s\n",
mountpt, mtab_getinfo(mountpt, MTAB_GETDEVICE), mountpt, mtab_getinfo(mountpt, MTAB_GETDEVICE),
strerror(errno)); strerror(errno));
@ -275,12 +277,12 @@ extern int umount_main(int argc, char **argv)
mtab_read(); mtab_read();
if (umountAll == TRUE) { if (umountAll == TRUE) {
if (umount_all(useMtab) == TRUE) if (umount_all() == TRUE)
return EXIT_SUCCESS; return EXIT_SUCCESS;
else else
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (do_umount(*argv, useMtab) == TRUE) if (do_umount(*argv) == TRUE)
return EXIT_SUCCESS; return EXIT_SUCCESS;
perror_msg_and_die("%s", *argv); perror_msg_and_die("%s", *argv);
} }

14
wget.c
View File

@ -291,24 +291,24 @@ void parse_url(char *url, char **uri_host, int *uri_port, char **uri_path)
FILE *open_socket(char *host, int port) FILE *open_socket(char *host, int port)
{ {
struct sockaddr_in sin; struct sockaddr_in s_in;
struct hostent *hp; struct hostent *hp;
int fd; int fd;
FILE *fp; FILE *fp;
memset(&sin, 0, sizeof(sin)); memset(&s_in, 0, sizeof(s_in));
sin.sin_family = AF_INET; s_in.sin_family = AF_INET;
if ((hp = (struct hostent *) gethostbyname(host)) == NULL) if ((hp = (struct hostent *) gethostbyname(host)) == NULL)
error_msg_and_die("cannot resolve %s", host); error_msg_and_die("cannot resolve %s", host);
memcpy(&sin.sin_addr, hp->h_addr_list[0], hp->h_length); memcpy(&s_in.sin_addr, hp->h_addr_list[0], hp->h_length);
sin.sin_port = htons(port); s_in.sin_port = htons(port);
/* /*
* Get the server onto a stdio stream. * Get the server onto a stdio stream.
*/ */
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
perror_msg_and_die("socket()"); 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); perror_msg_and_die("connect(%s)", host);
if ((fp = fdopen(fd, "r+")) == NULL) if ((fp = fdopen(fd, "r+")) == NULL)
perror_msg_and_die("fdopen()"); perror_msg_and_die("fdopen()");
@ -534,7 +534,7 @@ progressmeter(int flag)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 $
*/ */