From d0055759dd8892194db7fce6acc5085d5c9aeaee Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Sun, 20 Sep 2015 12:13:58 +0000 Subject: [PATCH] commands: resolve compiler warnings Change-Id: I95f0d0c48f998d4d950a0800eedd5fbbf2e50423 --- minix/commands/Makefile.inc | 4 - minix/commands/add_route/add_route.c | 21 +- minix/commands/arp/arp.c | 17 +- minix/commands/at/at.c | 2 +- minix/commands/cawf/bsfilt.c | 1 + minix/commands/cawf/cawf.c | 1 + minix/commands/cawf/getopt.c | 2 + minix/commands/cawf/macsup.c | 2 +- minix/commands/cawf/nreq.c | 2 +- minix/commands/cawf/proto.h | 2 +- minix/commands/cron/cron.c | 30 ++- minix/commands/cron/misc.c | 4 +- minix/commands/cron/misc.h | 2 +- minix/commands/cron/tab.c | 24 ++- minix/commands/crontab/crontab.c | 11 - minix/commands/devsize/devsize.c | 2 +- minix/commands/dhcpd/devices.c | 6 +- minix/commands/dhcpd/dhcpd.c | 53 +++-- minix/commands/dhcpd/ether.c | 6 +- minix/commands/dhcpd/tags.c | 14 +- minix/commands/fdisk/fdisk.c | 12 +- minix/commands/fetch/fetch.c | 2 +- minix/commands/format/format.c | 10 +- minix/commands/fsck.mfs/fsck.c | 29 +-- minix/commands/host/host.c | 25 ++- minix/commands/hostaddr/hostaddr.c | 6 +- minix/commands/ifconfig/ifconfig.c | 8 +- minix/commands/ifdef/ifdef.c | 3 +- minix/commands/ipcs/ipcs.c | 5 +- minix/commands/irdpd/irdpd.c | 3 +- minix/commands/isoread/isoread.c | 3 +- minix/commands/lpd/lpd.c | 2 +- minix/commands/mt/mt.c | 4 +- minix/commands/nonamed/nonamed.c | 32 +-- minix/commands/part/part.c | 2 +- minix/commands/partition/partition.c | 4 +- minix/commands/pr_routes/pr_routes.c | 16 +- minix/commands/ramdisk/ramdisk.c | 2 +- minix/commands/rarpd/rarpd.c | 8 +- minix/commands/rawspeed/rawspeed.c | 17 +- minix/commands/remsync/remsync.c | 6 +- minix/commands/swifi/extra.c | 4 +- minix/commands/synctree/synctree.c | 2 +- minix/commands/tcpd/tcpd.c | 4 +- minix/commands/tcpdp/Makefile | 3 +- minix/commands/tcpdp/tcpd.c | 312 --------------------------- minix/commands/tcpstat/tcpstat.c | 7 +- minix/commands/telnet/ttn.c | 3 +- minix/commands/telnetd/main.c | 3 +- minix/commands/udpstat/udpstat.c | 7 +- minix/commands/zmodem/rz.c | 2 +- minix/commands/zmodem/sz.c | 6 +- minix/man/man2/ptrace.2 | 2 +- 53 files changed, 252 insertions(+), 508 deletions(-) delete mode 100644 minix/commands/tcpdp/tcpd.c diff --git a/minix/commands/Makefile.inc b/minix/commands/Makefile.inc index 5c8747be1..77d183c22 100644 --- a/minix/commands/Makefile.inc +++ b/minix/commands/Makefile.inc @@ -6,8 +6,4 @@ LDADD+= -lasyn -lterminfo BINDIR?=/usr/bin -# BJG too many warnings here -NOGCCERROR?= yes -NOCLANGERROR?= yes - .include "../Makefile.inc" diff --git a/minix/commands/add_route/add_route.c b/minix/commands/add_route/add_route.c index 34f5fdc3e..c914fcae9 100644 --- a/minix/commands/add_route/add_route.c +++ b/minix/commands/add_route/add_route.c @@ -21,6 +21,7 @@ Created August 7, 1991 by Philip Homburg #include #include #include +#include static char *prog_name; static enum { ADD, DEL } action; @@ -165,7 +166,8 @@ int main(int argc, char *argv[]) { if (parse_cidr(destination_str, &destination, &netmask)) cidr= 1; - else if (inet_aton(destination_str, &destination)) + else if (inet_aton(destination_str, + (struct in_addr *)&destination)) ; else if ((netent= getnetbyname(destination_str)) != NULL) destination= netent->n_net; @@ -194,7 +196,8 @@ int main(int argc, char *argv[]) else /* class D is multicast ... */ { fprintf(stderr, "%s: Warning: Martian address '%s'\n", - prog_name, inet_ntoa(destination)); + prog_name, + inet_ntoa(*(struct in_addr *)&destination)); defaultmask= htonl(0xffffffff); } if (destination & ~defaultmask) @@ -210,7 +213,7 @@ int main(int argc, char *argv[]) { if (cidr) usage(); - if (inet_aton(netmask_str, &netmask) == 0) + if (inet_aton(netmask_str, (struct in_addr *)&netmask) == 0) { fprintf(stderr, "%s: illegal netmask'%s'\n", prog_name, netmask_str); @@ -248,9 +251,11 @@ int main(int argc, char *argv[]) printf("%s %s route to %s ", action == ADD ? "adding" : "deleting", itab ? "input" : "output", - inet_ntoa(destination)); - printf("with netmask %s ", inet_ntoa(netmask)); - printf("using gateway %s", inet_ntoa(gateway)); + inet_ntoa(*(struct in_addr *)&destination)); + printf("with netmask %s ", + inet_ntoa(*(struct in_addr *)&netmask)); + printf("using gateway %s", + inet_ntoa(*(struct in_addr *)&gateway)); if (itab && action == ADD) printf(" at distance %d", metric); printf("\n"); @@ -305,7 +310,7 @@ static int name_to_ip(const char *name, ipaddr_t *addr) */ struct hostent *hostent; - if (!inet_aton(name, addr)) { + if (!inet_aton(name, (struct in_addr *)addr)) { if ((hostent= gethostbyname(name)) == NULL) return 0; if (hostent->h_addrtype != AF_INET) return 0; if (hostent->h_length != sizeof(*addr)) return 0; @@ -327,7 +332,7 @@ static int parse_cidr(const char *cidr, ipaddr_t *addr, ipaddr_t *mask) *slash++= 0; ok= 1; - if (!inet_aton(cidr, &a)) + if (!inet_aton(cidr, (struct in_addr *)&a)) ok= 0; len= strtoul(slash, &check, 10); diff --git a/minix/commands/arp/arp.c b/minix/commands/arp/arp.c index a66d61a1a..1a4d9f660 100644 --- a/minix/commands/arp/arp.c +++ b/minix/commands/arp/arp.c @@ -30,6 +30,8 @@ Manipulate ARP table #include +#include + char *progname; static int ipfd= -1; static int do_setuid= 0; @@ -256,9 +258,10 @@ static void print_one(ipaddr_t ipaddr, nwio_arp_t *arpp, int do_num) else he= NULL; if (he) - printf("%s (%s)", he->h_name, inet_ntoa(ipaddr)); + printf("%s (%s)", he->h_name, + inet_ntoa(*(struct in_addr *)&ipaddr)); else - printf("%s", inet_ntoa(ipaddr)); + printf("%s", inet_ntoa(*(struct in_addr *)&ipaddr)); if (!arpp) { printf(" -- no entry\n"); @@ -328,7 +331,8 @@ static void delete_all(void) continue; } fatal("unable to delete host %s: %s", - inet_ntoa(arptab[i].nwa_ipaddr), strerror(errno)); + inet_ntoa(*(struct in_addr *)&arptab[i].nwa_ipaddr), + strerror(errno)); } } @@ -348,7 +352,8 @@ static void delete(char *hostname) print_one(ipaddr, NULL, 0); exit(1); } - fatal("unable to delete host %s: %s", inet_ntoa(ipaddr), + fatal("unable to delete host %s: %s", + inet_ntoa(*(struct in_addr *)&ipaddr), errno == EINVAL ? "entry is incomplete" : strerror(errno)); } @@ -389,7 +394,7 @@ static void do_set(char *hostname, char *ethername, int temp, int pub, if (r == -1 && errno != ENOENT) { fatal("unable to delete entry for host %s: %s", - inet_ntoa(ipaddr), + inet_ntoa(*(struct in_addr *)&ipaddr), errno == EINVAL ? "incomplete entry" : strerror(errno)); } @@ -415,7 +420,7 @@ static ipaddr_t nametoipaddr(char *hostname) ipaddr_t ipaddr; struct hostent *he; - if (inet_aton(hostname, &ipaddr) == 0) + if (inet_aton(hostname, (struct in_addr *)&ipaddr) == 0) { he= gethostbyname(hostname); if (!he) diff --git a/minix/commands/at/at.c b/minix/commands/at/at.c index 3442e28d9..a700c741c 100644 --- a/minix/commands/at/at.c +++ b/minix/commands/at/at.c @@ -28,7 +28,7 @@ int main(int argc, char **argv, char **envp) int i, c, mask, ltim, year, lday = NODAY; char buf[64], job[30], pastjob[35], *dp, *sp; struct tm *p; - long clk; + time_t clk; FILE *fp; char pwd[PATH_MAX+1]; diff --git a/minix/commands/cawf/bsfilt.c b/minix/commands/cawf/bsfilt.c index e6b84580f..358fbdccb 100644 --- a/minix/commands/cawf/bsfilt.c +++ b/minix/commands/cawf/bsfilt.c @@ -28,6 +28,7 @@ * 4. This notice may not be removed or altered. */ +#include #include #ifdef UNIX diff --git a/minix/commands/cawf/cawf.c b/minix/commands/cawf/cawf.c index fb4f97b3d..1528652d4 100644 --- a/minix/commands/cawf/cawf.c +++ b/minix/commands/cawf/cawf.c @@ -36,6 +36,7 @@ static char Version[] = "4.0"; #include "cawf.h" #include +#include #ifndef UNIX #include #include diff --git a/minix/commands/cawf/getopt.c b/minix/commands/cawf/getopt.c index 2ca11971f..d761a2141 100644 --- a/minix/commands/cawf/getopt.c +++ b/minix/commands/cawf/getopt.c @@ -1,3 +1,4 @@ +#ifndef __minix /* Newsgroups: mod.std.unix Subject: public domain AT&T getopt source @@ -71,3 +72,4 @@ int getopt(int argc, char **argv, char **opts) { } return(c); } +#endif /* !__minix */ diff --git a/minix/commands/cawf/macsup.c b/minix/commands/cawf/macsup.c index 87c554d06..845bd00d8 100644 --- a/minix/commands/cawf/macsup.c +++ b/minix/commands/cawf/macsup.c @@ -35,7 +35,7 @@ * Delmacro(mx) - delete macro */ -int Delmacro(int mx) { +void Delmacro(int mx) { /* macro index mx */ unsigned char buf[MAXLINE]; /* error message buffer */ int i, j; /* temporary indexes */ diff --git a/minix/commands/cawf/nreq.c b/minix/commands/cawf/nreq.c index 149bc7250..1bc903071 100644 --- a/minix/commands/cawf/nreq.c +++ b/minix/commands/cawf/nreq.c @@ -690,7 +690,7 @@ static void nr_Uc(unsigned char *line, int brk) { if (*s4) s4++; } - while (*s1++ = *s4++) + while ((*s1++ = *s4++)) ; if (*s2 == 'h' && *(s2+1) == 'y') (void) Findhy(buf, i, 1); diff --git a/minix/commands/cawf/proto.h b/minix/commands/cawf/proto.h index 6b1a5cc40..5b2a80952 100644 --- a/minix/commands/cawf/proto.h +++ b/minix/commands/cawf/proto.h @@ -80,7 +80,7 @@ char *malloc(unsigned size); unsigned char *Asmcode(unsigned char **s, unsigned char *c); int Asmname(unsigned char *s, unsigned char *c); void Charput(int c); -int Delmacro(int mx); +void Delmacro(int mx); int Defdev(); void Delstr(int sx); void Error(int t, int l, char *s1, char *s2); diff --git a/minix/commands/cron/cron.c b/minix/commands/cron/cron.c index 53ff88010..3f7e5a572 100644 --- a/minix/commands/cron/cron.c +++ b/minix/commands/cron/cron.c @@ -21,10 +21,6 @@ #include "misc.h" #include "tab.h" -#if __minix && !__minix_vmd -#define initgroups(name, gid) (0) -#endif - static volatile int busy; /* Set when something is afoot, don't sleep! */ static volatile int need_reload;/* Set if table reload required. */ static volatile int need_quit; /* Set if cron must exit. */ @@ -55,7 +51,7 @@ static void run_job(cronjob_t *job) need_reload= 1; } else { /* Bad error, halt processing AT jobs. */ - log(LOG_CRIT, "Can't rename %s: %s\n", + cronlog(LOG_CRIT, "Can't rename %s: %s\n", tab->file, strerror(errno)); tab_reschedule(job); } @@ -65,13 +61,14 @@ static void run_job(cronjob_t *job) need_reload= 1; if (stat(tab->data, &st) < 0) { - log(LOG_ERR, "Can't stat %s: %s\n", + cronlog(LOG_ERR, "Can't stat %s: %s\n", tab->data, strerror(errno)); tab_reschedule(job); return; } if ((pw= getpwuid(st.st_uid)) == nil) { - log(LOG_ERR, "Unknown owner for uid %lu of AT job %s\n", + cronlog(LOG_ERR, + "Unknown owner for uid %lu of AT job %s\n", (unsigned long) st.st_uid, job->cmd); tab_reschedule(job); return; @@ -79,7 +76,7 @@ static void run_job(cronjob_t *job) } else { pw= nil; if (job->user != nil && (pw= getpwnam(job->user)) == nil) { - log(LOG_ERR, "%s: Unknown user\n", job->user); + cronlog(LOG_ERR, "%s: Unknown user\n", job->user); tab_reschedule(job); return; } @@ -88,7 +85,7 @@ static void run_job(cronjob_t *job) if (need_mailer) { errfd[0]= -1; if (pipe(errfd) < 0 || pipe(mailfd) < 0) { - log(LOG_ERR, "pipe() call failed: %s\n", + cronlog(LOG_ERR, "pipe() call failed: %s\n", strerror(errno)); if (errfd[0] != -1) { close(errfd[0]); @@ -101,7 +98,7 @@ static void run_job(cronjob_t *job) fcntl(errfd[1], F_GETFD) | FD_CLOEXEC); if ((pid= fork()) == -1) { - log(LOG_ERR, "fork() call failed: %s\n", + cronlog(LOG_ERR, "fork() call failed: %s\n", strerror(errno)); close(errfd[0]); close(errfd[1]); @@ -143,7 +140,7 @@ static void run_job(cronjob_t *job) close(mailfd[0]); close(errfd[1]); if (read(errfd[0], &errno, sizeof(errno)) > 0) { - log(LOG_ERR, "can't execute /usr/bin/mail: %s\n", + cronlog(LOG_ERR, "can't execute /usr/bin/mail: %s\n", strerror(errno)); close(errfd[0]); close(mailfd[1]); @@ -154,7 +151,7 @@ static void run_job(cronjob_t *job) } if (pipe(errfd) < 0) { - log(LOG_ERR, "pipe() call failed: %s\n", strerror(errno)); + cronlog(LOG_ERR, "pipe() call failed: %s\n", strerror(errno)); if (need_mailer) close(mailfd[1]); tab_reschedule(job); return; @@ -162,7 +159,7 @@ static void run_job(cronjob_t *job) (void) fcntl(errfd[1], F_SETFD, fcntl(errfd[1], F_GETFD) | FD_CLOEXEC); if ((pid= fork()) == -1) { - log(LOG_ERR, "fork() call failed: %s\n", strerror(errno)); + cronlog(LOG_ERR, "fork() call failed: %s\n", strerror(errno)); close(errfd[0]); close(errfd[1]); if (need_mailer) close(mailfd[1]); @@ -207,7 +204,8 @@ static void run_job(cronjob_t *job) if (need_mailer) close(mailfd[1]); close(errfd[1]); if (read(errfd[0], &errno, sizeof(errno)) > 0) { - log(LOG_ERR, "can't execute /bin/sh: %s\n", strerror(errno)); + cronlog(LOG_ERR, "can't execute /bin/sh: %s\n", + strerror(errno)); close(errfd[0]); tab_reschedule(job); return; @@ -256,13 +254,13 @@ static void load_crontabs(void) tab_parse(tab, nil); } if (ferror(pkgs)) { - log(LOG_CRIT, "/usr/lib/packages: %s\n", + cronlog(LOG_CRIT, "/usr/lib/packages: %s\n", strerror(errno)); } fclose(pkgs); } else { if (errno != ENOENT) { - log(LOG_ERR, "/usr/lib/packages: %s\n", + cronlog(LOG_ERR, "/usr/lib/packages: %s\n", strerror(errno)); } } diff --git a/minix/commands/cron/misc.c b/minix/commands/cron/misc.c index 30b0b036f..8cf217e7b 100644 --- a/minix/commands/cron/misc.c +++ b/minix/commands/cron/misc.c @@ -21,7 +21,7 @@ void *allocate(size_t len) void *mem; if ((mem= malloc(len)) == nil) { - log(LOG_ALERT, "Out of memory, exiting\n"); + cronlog(LOG_ALERT, "Out of memory, exiting\n"); exit(1); } alloc_count++; @@ -44,7 +44,7 @@ void selectlog(enum logto where) logto= where; } -void log(int level, const char *fmt, ...) +void cronlog(int level, const char *fmt, ...) /* Like syslog(), but may go to stderr. */ { va_list ap; diff --git a/minix/commands/cron/misc.h b/minix/commands/cron/misc.h index b8229b544..94349f3d8 100644 --- a/minix/commands/cron/misc.h +++ b/minix/commands/cron/misc.h @@ -33,7 +33,7 @@ enum log_dummy { LOG_ERR, LOG_CRIT, LOG_ALERT }; enum logto { SYSLOG, STDERR }; void selectlog(enum logto where); -void log(int level, const char *fmt, ...); +void cronlog(int level, const char *fmt, ...); #endif /* MISC__H */ diff --git a/minix/commands/cron/tab.c b/minix/commands/cron/tab.c index 2cdce435b..cdfcf453b 100644 --- a/minix/commands/cron/tab.c +++ b/minix/commands/cron/tab.c @@ -150,7 +150,7 @@ void tab_reschedule(cronjob_t *job) nodst_rtime= job->rtime= mktime(&tmptm); if (job->rtime == -1) { /* This should not happen. */ - log(LOG_ERR, + cronlog(LOG_ERR, "mktime failed for %04d-%02d-%02d %02d:%02d:%02d", 1900+nexttm.tm_year, nexttm.tm_mon+1, nexttm.tm_mday, nexttm.tm_hour, @@ -175,7 +175,7 @@ void tab_reschedule(cronjob_t *job) dst_rtime= job->rtime= mktime(&tmptm); if (job->rtime == -1) { /* This should not happen. */ - log(LOG_ERR, + cronlog(LOG_ERR, "mktime failed for %04d-%02d-%02d %02d:%02d:%02d\n", 1900+nexttm.tm_year, nexttm.tm_mon+1, nexttm.tm_mday, nexttm.tm_hour, @@ -309,7 +309,7 @@ static int range_parse(char *file, char *data, bitmap_t map, p= data; if (*p == 0) { - log(LOG_ERR, "%s: not enough time fields\n", file); + cronlog(LOG_ERR, "%s: not enough time fields\n", file); return 0; } @@ -371,11 +371,12 @@ static int range_parse(char *file, char *data, bitmap_t map, *p= end; return 1; syntax: - log(LOG_ERR, "%s: field '%s': bad syntax for a %d-%d time field\n", + cronlog(LOG_ERR, "%s: field '%s': bad syntax for a %d-%d time field\n", file, data, min, max); return 0; range: - log(LOG_ERR, "%s: field '%s': values out of the %d-%d allowed range\n", + cronlog(LOG_ERR, + "%s: field '%s': values out of the %d-%d allowed range\n", file, data, min, max); return 0; } @@ -401,7 +402,7 @@ void tab_parse(char *file, char *user) /* Try to open the file. */ if ((fd= open(file, O_RDONLY)) < 0 || fstat(fd, &st) < 0) { if (errno != ENOENT) { - log(LOG_ERR, "%s: %s\n", file, strerror(errno)); + cronlog(LOG_ERR, "%s: %s\n", file, strerror(errno)); } if (fd != -1) close(fd); return; @@ -409,7 +410,7 @@ void tab_parse(char *file, char *user) /* Forget it if the file is awfully big. */ if (st.st_size > TAB_MAX) { - log(LOG_ERR, "%s: %lu bytes is bigger than my %lu limit\n", + cronlog(LOG_ERR, "%s: %lu bytes is bigger than my %lu limit\n", file, (unsigned long) st.st_size, (unsigned long) TAB_MAX); @@ -443,7 +444,7 @@ void tab_parse(char *file, char *user) n= 0; while (n < st.st_size) { if ((r = read(fd, tab->data + n, st.st_size - n)) < 0) { - log(LOG_CRIT, "%s: %s", file, strerror(errno)); + cronlog(LOG_CRIT, "%s: %s", file, strerror(errno)); close(fd); return; } @@ -453,7 +454,7 @@ void tab_parse(char *file, char *user) close(fd); tab->data[n]= 0; if (strlen(tab->data) < n) { - log(LOG_ERR, "%s contains a null character\n", file); + cronlog(LOG_ERR, "%s contains a null character\n", file); return; } @@ -539,7 +540,7 @@ void tab_parse(char *file, char *user) break; default: usage: - log(LOG_ERR, + cronlog(LOG_ERR, "%s: bad option -%c, good options are: -u username\n", file, q[-1]); ok= 0; @@ -558,7 +559,8 @@ void tab_parse(char *file, char *user) */ while (*p != 0 && *p++ != '\n') {} if (*p++ != '\t') { - log(LOG_ERR, "%s: contains an empty command\n", + cronlog(LOG_ERR, + "%s: contains an empty command\n", file); ok= 0; goto endtab; diff --git a/minix/commands/crontab/crontab.c b/minix/commands/crontab/crontab.c index 6797ae28c..7985b87dc 100644 --- a/minix/commands/crontab/crontab.c +++ b/minix/commands/crontab/crontab.c @@ -16,10 +16,6 @@ #include "misc.h" #include "tab.h" -#if __minix && !__minix_vmd -#define seteuid(uid) ((uid),0) /* Minix can't fiddle with uids. */ -#endif - static int opentab(int uid, char *file, int how) /* Open a crontab file under the given uid. How is 'r' or 'w'. Return * the result of open(2). @@ -34,13 +30,6 @@ static int opentab(int uid, char *file, int how) default: errno= EINVAL; return -1; } -#if __minix && !__minix_vmd - /* Standard Minix has no saved uid, so use the lousy old access(). */ - if (uid != 0) { - if (access(file, how == 'r' ? R_OK : W_OK) < 0) return -1; - } -#endif - safe_uid= geteuid(); seteuid(uid); r= open(file, flags, 0666); diff --git a/minix/commands/devsize/devsize.c b/minix/commands/devsize/devsize.c index 9c51508c2..240bba899 100644 --- a/minix/commands/devsize/devsize.c +++ b/minix/commands/devsize/devsize.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/minix/commands/dhcpd/devices.c b/minix/commands/dhcpd/devices.c index 7b095372d..183d31e98 100644 --- a/minix/commands/dhcpd/devices.c +++ b/minix/commands/dhcpd/devices.c @@ -98,7 +98,7 @@ void closefd(fd_t *fdp) static void timeout(int signum) { /* nothing to do, ioctl will be aborted automatically */ - if (alarm(1) < 0) fatal("alarm(1)"); + if (alarm(1) == (unsigned int)-1) fatal("alarm(1)"); } int opendev(network_t *np, fdtype_t fdtype, int compete) @@ -219,13 +219,13 @@ int opendev(network_t *np, fdtype_t fdtype, int compete) * in case the driver isn't ready yet. */ if (signal(SIGALRM, timeout) == SIG_ERR) fatal("signal(SIGALRM)"); - if (alarm(1) < 0) fatal("alarm(1)"); + if (alarm(1) == (unsigned int)-1) fatal("alarm(1)"); if (ioctl(np->fdp->fd, NWIOGETHSTAT, ðstat) < 0) { /* Not an Ethernet. */ close(fdp->fd); return 0; } - if (alarm(0) < 0) fatal("alarm(0)"); + if (alarm(0) == (unsigned int)-1) fatal("alarm(0)"); np->eth= ethstat.nwes_addr; ethopt.nweo_flags= NWEO_COPY | NWEO_EN_LOC | NWEO_EN_BROAD | NWEO_REMANY | NWEO_TYPEANY | NWEO_RWDATALL; diff --git a/minix/commands/dhcpd/dhcpd.c b/minix/commands/dhcpd/dhcpd.c index daf1a6ae6..d4c1bfda0 100644 --- a/minix/commands/dhcpd/dhcpd.c +++ b/minix/commands/dhcpd/dhcpd.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "arp.h" #define EXTERN #include "dhcpd.h" @@ -359,11 +360,12 @@ static void printdata(void) strcpy(delta, "infinite"); } else if (expire < now) { - sprintf(delta, "-%lu", now - expire); + sprintf(delta, "-%llu", now - expire); } else { - sprintf(delta, "+%lu", expire - now); + sprintf(delta, "+%llu", expire - now); } - printf("\t%-15s %8s ", inet_ntoa(entry.ip), delta); + printf("\t%-15s %8s ", inet_ntoa(*(struct in_addr *)&entry.ip), + delta); for (i= 0; i < entry.len; i++) { printf("%02X", entry.clid[i]); } @@ -482,7 +484,7 @@ static size_t servdhcp(network_t *np, buf_t *bp, size_t dlen) if (dyn) { /* A dynamic address must have a lease. */ fprintf(stderr, "%s: No lease set for address %s\n", - program, inet_ntoa(cip)); + program, inet_ntoa(*(struct in_addr *)&cip)); exit(1); } lease= nil; @@ -528,7 +530,8 @@ static size_t servdhcp(network_t *np, buf_t *bp, size_t dlen) for (i= 0; i < cilen; i++) { fprintf(stderr, "%02X", client[i]); } - fprintf(stderr, " declines %s", inet_ntoa(cip)); + fprintf(stderr, " declines %s", + inet_ntoa(*(struct in_addr *)&cip)); if (gettag(bp->dhcp, DHCP_TAG_MESSAGE, &pdata, &len)) { fprintf(stderr, " saying: \"%.*s\"", (int)len, pdata); } @@ -953,7 +956,7 @@ main: /* Some weird sites use a hostname, not a client ID. */ if (np->hostname != nil) { settag(bp->dhcp, DHCP_TAG_HOSTNAME, - np->hostname, strlen(np->hostname)); + (void *)np->hostname, strlen(np->hostname)); } bp->udpio->uih_src_addr= np->ip; @@ -983,7 +986,7 @@ main: printf("%s: Sent DHCP %s to %s\n", np->fdp->device, dhcptypename(type), - inet_ntoa(np->server)); + inet_ntoa(*(struct in_addr *)&np->server)); if (debug >= 2) printdhcp(bp->dhcp); } } @@ -1073,9 +1076,12 @@ main: if (debug >= 1) { printf("%s: Got a DHCP %s from %s", - np->fdp->device, dhcptypename(type), inet_ntoa(server)); - printf(relay != server ? " through %s\n" : "\n", - inet_ntoa(relay)); + np->fdp->device, dhcptypename(type), + inet_ntoa(*(struct in_addr *)&server)); + if (relay != server) + printf(" through %s\n", + inet_ntoa(*(struct in_addr *)&relay)); + else printf("\n"); if (debug >= 2) printdhcp(bp->dhcp); } @@ -1136,7 +1142,8 @@ main: make_arp(bp, np); if (sendpacket(np, bp->eth, sizeof(arp46_t))) { if (debug >= 2) { - printf("Sent ARP for %s\n", inet_ntoa(np->ip)); + printf("Sent ARP for %s\n", + inet_ntoa(*(struct in_addr *)&np->ip)); } } np->flags &= ~NF_CONFLICT; @@ -1222,9 +1229,10 @@ main: np->delta= DELTA_FIRST; fprintf(stderr, "%s: Got a NAK from %s", - program, inet_ntoa(server)); + program, inet_ntoa(*(struct in_addr *)&server)); if (relay != server) { - fprintf(stderr, " through %s", inet_ntoa(relay)); + fprintf(stderr, " through %s", + inet_ntoa(*(struct in_addr *)&relay)); } if (gettag(bp->dhcp, DHCP_TAG_MESSAGE, &pdata, &len)) { fprintf(stderr, " saying: \"%.*s\"", (int)len, pdata); @@ -1243,9 +1251,9 @@ main: fprintf(stderr, "%s: %s: %s offered by ", program, np->fdp->device, - inet_ntoa(np->ip)); + inet_ntoa(*(struct in_addr *)&np->ip)); fprintf(stderr, "%s is already in use by %s\n", - inet_ntoa(np->server), + inet_ntoa(*(struct in_addr *)&np->server), ether_ntoa(&np->conflict)); } put_buf(&bp); @@ -1270,7 +1278,8 @@ main: if (sendpacket(np, bp->ip, sizeof(ip_hdr_t) + 16)) { if (debug >= 2) { printf("%s: Sent advert for %s to self\n", - np->fdp->device, inet_ntoa(np->gateway)); + np->fdp->device, + inet_ntoa(*(struct in_addr *)&np->gateway)); } } np->solicit= now + DELTA_ADV/2; @@ -1320,7 +1329,8 @@ main: if ((router= icmp_is_advert(bp)) != 0) { if (debug >= 2) { printf("%s: Router advert received from %s\n", - np->fdp->device, inet_ntoa(router)); + np->fdp->device, + inet_ntoa(*(struct in_addr *)&router)); } np->solicit= NEVER; np->sol_ct= -1; @@ -1369,8 +1379,10 @@ main: if (debug >= 1) { printf("%s: Got DHCP packet from %s to ", - np->fdp->device, inet_ntoa(bp->udpio->uih_src_addr)); - printf("%s\n", inet_ntoa(bp->udpio->uih_dst_addr)); + np->fdp->device, + inet_ntoa(*(struct in_addr *)&bp->udpio->uih_src_addr)); + printf("%s\n", + inet_ntoa(*(struct in_addr *)&bp->udpio->uih_dst_addr)); if (debug >= 2) printdhcp(bp->dhcp); } @@ -1381,7 +1393,8 @@ main: if (debug >= 1) { printf("%s: Sent DHCP packet to %s\n", np->fdp->device, - inet_ntoa(bp->udpio->uih_dst_addr)); + inet_ntoa(*(struct in_addr *) + &bp->udpio->uih_dst_addr)); if (debug >= 2) printdhcp(bp->dhcp); } } diff --git a/minix/commands/dhcpd/ether.c b/minix/commands/dhcpd/ether.c index 1b6384783..b9edadf1a 100644 --- a/minix/commands/dhcpd/ether.c +++ b/minix/commands/dhcpd/ether.c @@ -168,6 +168,7 @@ void icmp_solicit(buf_t *bp) void icmp_advert(buf_t *bp, network_t *np) { /* Fill in a router advert to be sent to my own interface. */ + u32_t *data; icmp_hdr_t *icmp= (icmp_hdr_t *) (bp->ip + 1); bp->ip->ih_vers_ihl= 0x45; @@ -178,8 +179,9 @@ void icmp_advert(buf_t *bp, network_t *np) icmp->ih_hun.ihh_ram.iram_na= 1; icmp->ih_hun.ihh_ram.iram_aes= 2; icmp->ih_hun.ihh_ram.iram_lt= htons(DELTA_ADV); - ((u32_t *) icmp->ih_dun.uhd_data)[0] = np->gateway; - ((u32_t *) icmp->ih_dun.uhd_data)[1] = htonl((u32_t) -9999); + data = (u32_t *) icmp->ih_dun.uhd_data; + data[0] = np->gateway; + data[1] = htonl((u32_t) -9999); icmp->ih_chksum= 0; icmp->ih_chksum= ~oneC_sum(0, icmp, 16); } diff --git a/minix/commands/dhcpd/tags.c b/minix/commands/dhcpd/tags.c index c85b1a835..6ab015c90 100644 --- a/minix/commands/dhcpd/tags.c +++ b/minix/commands/dhcpd/tags.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "dhcpd.h" #define doff(field) offsetof(dhcp_t, field) @@ -59,7 +60,7 @@ static int name2ip(ipaddr_t *pip, const char *name, ipaddr_t ifip) char *hn; /* Already an IP address? */ - if (inet_aton(name, pip)) return 1; + if (inet_aton(name, (struct in_addr *)pip)) return 1; /* In the hosts file? */ while ((he= _gethostent()) != nil) { @@ -130,7 +131,7 @@ static int cidr_aton(const char *cidr, ipaddr_t *addr, ipaddr_t *mask) if ((slash= strchr(cidr, '/')) == nil) return 0; *slash++= 0; - ok= inet_aton(cidr, &a); + ok= inet_aton(cidr, (struct in_addr *)&a); len= strtoul(slash, &check, 10); if (check == slash || *check != 0 || len > 32) ok= 0; @@ -153,8 +154,9 @@ char *cidr_ntoa(ipaddr_t addr, ipaddr_t mask) testmask= (testmask << 1) & 0xFFFFFFFFUL; } - sprintf(result, "%s/%-2d", inet_ntoa(addr), n); - if (n == -1) strcpy(strchr(result, '/')+1, inet_ntoa(mask)); + sprintf(result, "%s/%-2d", inet_ntoa(*(struct in_addr *)&addr), n); + if (n == -1) strcpy(strchr(result, '/')+1, + inet_ntoa(*(struct in_addr *)&mask)); return result; } @@ -576,7 +578,7 @@ int makedhcp(dhcp_t *dp, u8_t *class, size_t calen, u8_t *client, size_t cilen, ) { config_t *atname= cmd->next->next; if (ifno != -1) atname= atname->next; - name= atname->word; + name= (char *)atname->word; if (name2ip(&hip, name, ifip) && (ip == 0 || ip == hip)) { d= ntohl(hip) ^ ntohl(ifip); @@ -897,7 +899,7 @@ void printdhcp(dhcp_t *dp) case TT_IP: { ipaddr_t ip; memcpy(&ip, data+i, sizeof(ip)); - printf(" %s", inet_ntoa(ip)); + printf(" %s", inet_ntoa(*(struct in_addr *)&ip)); i += sizeof(ip); break;} case TT_NUMBER: { diff --git a/minix/commands/fdisk/fdisk.c b/minix/commands/fdisk/fdisk.c index 5b41d8308..c75d2b358 100644 --- a/minix/commands/fdisk/fdisk.c +++ b/minix/commands/fdisk/fdisk.c @@ -605,7 +605,7 @@ void change_partition(struct part_entry *entry) } sec_to_hst(low, &entry->start_head, &entry->start_sec, &entry->start_cyl); sec_to_hst(high, &entry->last_head, &entry->last_sec, &entry->last_cyl); - printf("Base of partition changed to %ld, size changed to %ld\n", + printf("Base of partition changed to %u, size changed to %u\n", entry->lowsec, entry->size); /* Accept the MINIX partition type. Usually ignore foreign types, so this @@ -755,17 +755,17 @@ void adj_base(struct part_entry *pe) return; if (pe->lowsec + adj < 1) printf( - "\t\tThat would make the base %lu and too small\n", pe->lowsec + adj); + "\t\tThat would make the base %u and too small\n", pe->lowsec + adj); else if (pe->size - adj < 1) printf( - "\t\tThat would make the size %lu and too small\n", pe->size - adj); + "\t\tThat would make the size %u and too small\n", pe->size - adj); else break; } pe->lowsec += adj; pe->size -= adj; sec_to_hst(pe->lowsec, &pe->start_head, &pe->start_sec, &pe->start_cyl); - printf("Base of partition adjusted to %ld, size adjusted to %ld\n", + printf("Base of partition adjusted to %u, size adjusted to %u\n", pe->lowsec, pe->size); } @@ -780,13 +780,13 @@ void adj_size(struct part_entry *pe) if (!get_an_int("\tEnter adjustment to size (an integer): ", &adj)) return; if (pe->size + adj >= 1) break; - printf("\t\tThat would make the size %lu and too small \n", + printf("\t\tThat would make the size %u and too small \n", pe->size + adj); } pe->size += adj; sec_to_hst(pe->lowsec + pe->size - 1, &pe->last_head, &pe->last_sec, &pe->last_cyl); - printf("Size of partition adjusted to %ld\n", pe->size); + printf("Size of partition adjusted to %u\n", pe->size); } struct part_entry *ask_partition() diff --git a/minix/commands/fetch/fetch.c b/minix/commands/fetch/fetch.c index 5b51d49f7..55d0007c9 100644 --- a/minix/commands/fetch/fetch.c +++ b/minix/commands/fetch/fetch.c @@ -316,7 +316,7 @@ read_password(const char *prompt, char *pwbuf, size_t pwbuf_len) tcflag_t saved_flags; int nopwd; - fprintf(stderr, prompt); + fprintf(stderr, "%s", prompt); if (tcgetattr(STDIN_FILENO, &tios) != 0) return (fgets(pwbuf, pwbuf_len, stdin) == NULL); diff --git a/minix/commands/format/format.c b/minix/commands/format/format.c index 8cb8a4c93..ccc57afb9 100644 --- a/minix/commands/format/format.c +++ b/minix/commands/format/format.c @@ -122,7 +122,7 @@ void format_track(int ffd, unsigned type, unsigned cyl, unsigned head) track_pos= (off_t) (cyl * NR_HEADS + head) * nr_sectors * SECTOR_SIZE; if (lseek(ffd, track_pos, SEEK_SET) == -1) { fprintf(stderr, - "format: seeking to cyl %u, head %u (pos %d) failed: %s\n", + "format: seeking to cyl %u, head %u (pos %lld) failed: %s\n", cyl, head, track_pos, strerror(errno)); exit(1); } @@ -154,7 +154,7 @@ void verify_track(int vfd, unsigned type, unsigned cyl, unsigned head) track_pos= (off_t) (cyl * NR_HEADS + head) * nr_sectors * SECTOR_SIZE; if (lseek(vfd, track_pos, SEEK_SET) == -1) { fprintf(stderr, - "format: seeking to cyl %u, head %u (pos %d) failed: %s\n", + "format: seeking to cyl %u, head %u (pos %lld) failed: %s\n", cyl, head, track_pos, strerror(errno)); exit(1); } @@ -167,7 +167,7 @@ void verify_track(int vfd, unsigned type, unsigned cyl, unsigned head) for (sector= 0; sector < nr_sectors; sector++) { if (lseek(vfd, track_pos, SEEK_SET) == -1) { fprintf(stderr, - "format: seeking to cyl %u, head %u, sector %u (pos %d) failed: %s\n", + "format: seeking to cyl %u, head %u, sector %u (pos %lld) failed: %s\n", cyl, head, sector, track_pos, strerror(errno)); exit(1); } @@ -175,7 +175,7 @@ void verify_track(int vfd, unsigned type, unsigned cyl, unsigned head) switch (read(vfd, buf, SECTOR_SIZE)) { case -1: fprintf(stderr, - "format: bad sector at cyl %u, head %u, sector %u (pos %d)\n", + "format: bad sector at cyl %u, head %u, sector %u (pos %lld)\n", cyl, head, sector, track_pos); bad_count++; break; @@ -183,7 +183,7 @@ void verify_track(int vfd, unsigned type, unsigned cyl, unsigned head) /* Fine. */ break; default: - fprintf(stderr, "format: short read at pos %d\n", + fprintf(stderr, "format: short read at pos %lld\n", track_pos); bad_count++; } diff --git a/minix/commands/fsck.mfs/fsck.c b/minix/commands/fsck.mfs/fsck.c index e68e5d98b..fbffc8314 100644 --- a/minix/commands/fsck.mfs/fsck.c +++ b/minix/commands/fsck.mfs/fsck.c @@ -645,7 +645,7 @@ void chksuper() if(maxsize <= 0) maxsize = LONG_MAX; if (sb.s_max_size != maxsize) { - printf("warning: expected max size to be %d ", maxsize); + printf("warning: expected max size to be %lld ", maxsize); printf("instead of %d\n", sb.s_max_size); } @@ -681,7 +681,7 @@ char **clist; ino = bit; do { devread(inoblock(ino), inooff(ino), (char *) ip, INODE_SIZE); - printf("inode %u:\n", ino); + printf("inode %llu:\n", ino); printf(" mode = %6o", ip->i_mode); if (input(buf, 80)) ip->i_mode = atoo(buf); printf(" nlinks = %6u", ip->i_nlinks); @@ -798,11 +798,12 @@ bit_nr phys; (!repair || automatic || yes("stop this listing"))) *report = 0; else { - if (*report) + if (*report) { if ((w1 & 1) && !(w2 & 1)) printf("%s %d is missing\n", type, bit); else if (!(w1 & 1) && (w2 & 1)) printf("%s %d is not free\n", type, bit); + } } } @@ -853,7 +854,7 @@ void chkilist() devread(inoblock(ino), inooff(ino), (char *) &mode, sizeof(mode)); if (mode != I_NOT_ALLOC) { - printf("mode inode %u not cleared", ino); + printf("mode inode %llu not cleared", ino); if (yes(". clear")) devwrite(inoblock(ino), inooff(ino), nullbuf, INODE_SIZE); } @@ -879,7 +880,7 @@ void counterror(ino_t ino) } devread(inoblock(ino), inooff(ino), (char *) &inode, INODE_SIZE); count[ino] += inode.i_nlinks; /* it was already subtracted; add it back */ - printf("%5u %5u %5u", ino, (unsigned) inode.i_nlinks, count[ino]); + printf("%5llu %5u %5u", ino, (unsigned) inode.i_nlinks, count[ino]); if (yes(" adjust")) { if ((inode.i_nlinks = count[ino]) == 0) { fatal("internal error (counterror)"); @@ -939,7 +940,7 @@ void list(ino_t ino, d_inode *ip) firstlist = 0; printf(" inode permission link size name\n"); } - printf("%6u ", ino); + printf("%6llu ", ino); switch (ip->i_mode & I_TYPE) { case I_REGULAR: putchar('-'); break; case I_DIRECTORY: putchar('d'); break; @@ -1023,11 +1024,12 @@ int chkdots(ino_t ino, off_t pos, dir_struct *dp, ino_t exp) char printable_name[4 * MFS_NAME_MAX + 1]; if (dp->d_inum != exp) { - make_printable_name(printable_name, dp->mfs_d_name, sizeof(dp->mfs_d_name)); + make_printable_name(printable_name, dp->mfs_d_name, + sizeof(dp->mfs_d_name)); printf("bad %s in ", printable_name); printpath(1, 0); printf("%s is linked to %u ", printable_name, dp->d_inum); - printf("instead of %u)", exp); + printf("instead of %llu)", exp); setbit(spec_imap, (bit_nr) ino); setbit(spec_imap, (bit_nr) dp->d_inum); setbit(spec_imap, (bit_nr) exp); @@ -1038,8 +1040,9 @@ int chkdots(ino_t ino, off_t pos, dir_struct *dp, ino_t exp) return(0); } } else if (pos != (dp->mfs_d_name[1] ? DIR_ENTRY_SIZE : 0)) { - make_printable_name(printable_name, dp->mfs_d_name, sizeof(dp->mfs_d_name)); - printf("warning: %s has offset %d in ", printable_name, pos); + make_printable_name(printable_name, dp->mfs_d_name, + sizeof(dp->mfs_d_name)); + printf("warning: %s has offset %lld in ", printable_name, pos); printpath(1, 0); printf("%s is linked to %u)\n", printable_name, dp->d_inum); setbit(spec_imap, (bit_nr) ino); @@ -1206,7 +1209,7 @@ off_t pos; case 2: printf("DOUBLE INDIRECT"); break; default: printf("VERY INDIRECT"); } - printf(", pos = %d)\n", pos); + printf(", pos = %lld)\n", pos); } /* Found the given zone in the given inode. Check it, and if ok, mark it @@ -1425,7 +1428,7 @@ int chkinode(ino_t ino, d_inode *ip) { if (ino == ROOT_INODE && (ip->i_mode & I_TYPE) != I_DIRECTORY) { printf("root inode is not a directory "); - printf("(ino = %u, mode = %o)\n", ino, ip->i_mode); + printf("(ino = %llu, mode = %o)\n", ino, ip->i_mode); fatal(""); } if (ip->i_nlinks == 0) { @@ -1460,7 +1463,7 @@ dir_struct *dp; stk.st_next = ftop; ftop = &stk; if (bitset(spec_imap, (bit_nr) ino)) { - printf("found inode %u: ", ino); + printf("found inode %llu: ", ino); printpath(0, 1); } visited = bitset(imap, (bit_nr) ino); diff --git a/minix/commands/host/host.c b/minix/commands/host/host.c index d70a1947f..47295813b 100644 --- a/minix/commands/host/host.c +++ b/minix/commands/host/host.c @@ -16,6 +16,7 @@ * that copyright notice. */ +#include #include #include #include @@ -30,12 +31,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include extern int h_errno; @@ -387,7 +390,7 @@ gethostinfo(name) cp[-1] = '.'; return (hp); } - if (n == 0 && (cp = __hostalias(name))) { + if (n == 0 && (cp = (char *)__hostalias(name))) { if (verbose) printf("Aliased to \"%s\"\n", cp); _res.options |= RES_DEFNAMES; @@ -432,6 +435,7 @@ getdomaininfo(name, domain) static int getinfo(name, domain, type) char *name, *domain; + int type; { HEADER *hp; @@ -605,13 +609,14 @@ pr_rr(cp, msg, file, filter) else doprint = 0; - if (doprint) + if (doprint) { if (verbose) fprintf(file,"%s\t%d%s\t%s", name, ttl, pr_class(class), pr_type(type)); else { fprintf(file,"%s%s %s",name, pr_class(class), pr_type(type)); } + } if (verbose) punc = '\t'; else @@ -742,14 +747,14 @@ pr_rr(cp, msg, file, filter) cp += sizeof(u_long); proto = *cp++; protop = getprotobynumber(proto); - if (doprint) + if (doprint) { if (protop) fprintf(file,"%c%s %s", punc, inet_ntoa(inaddr), protop->p_name); else fprintf(file,"%c%s %d", punc, inet_ntoa(inaddr), proto); - + } n = 0; while (cp < cp1 + dlen) { c = *cp++; @@ -759,11 +764,12 @@ pr_rr(cp, msg, file, filter) if (protop) servp = getservbyport (htons(n), protop->p_name); - if (doprint) + if (doprint) { if (servp) fprintf(file, " %s", servp->s_name); else fprintf(file, " %d", n); + } } c <<= 1; } while (++n & 07); @@ -776,7 +782,7 @@ pr_rr(cp, msg, file, filter) cp += dlen; } if (cp != cp1 + dlen) - fprintf(file,"packet size error (%#x != %#x)\n", cp, cp1+dlen); + fprintf(file,"packet size error (%p != %p)\n", cp, cp1+dlen); if (doprint) fprintf(file,"\n"); return (cp); @@ -985,7 +991,7 @@ ListHosts(namePtr, queryType) */ msglen = res_mkquery(QUERY, namePtr, C_IN, T_NS, - (char *)0, 0, (struct rrec *)0, + (char *)0, 0, 0, (char *)&buf, sizeof(buf)); if (msglen < 0) { @@ -1133,7 +1139,7 @@ again: * */ msglen = res_mkquery(QUERY, namePtr, getclass, T_AXFR, - (char *)0, 0, (struct rrec *)0, + (char *)0, 0, 0, (char *) &buf, sizeof(buf)); if (msglen < 0) { if (_res.options & RES_DEBUG) { @@ -1172,7 +1178,8 @@ again: return ERROR; } if (_res.options & RES_DEBUG || verbose) - printf("Trying %s\n", inet_ntoa(tcpconf.nwtc_remaddr)); + printf("Trying %s\n", inet_ntoa(*(struct in_addr *) + &tcpconf.nwtc_remaddr)); clopt.nwtcl_flags= 0; result= ioctl(tcp_fd, NWIOTCPCONN, &clopt); if (result == 0) diff --git a/minix/commands/hostaddr/hostaddr.c b/minix/commands/hostaddr/hostaddr.c index 362a2d512..91d51f5ad 100644 --- a/minix/commands/hostaddr/hostaddr.c +++ b/minix/commands/hostaddr/hostaddr.c @@ -29,6 +29,7 @@ Created: Jan 27, 1992 by Philip Homburg #include #include +#include #include #include #include @@ -181,7 +182,7 @@ char *argv[]; if (do_ip) { printf("%s%s", first_print ? "" : " ", - inet_ntoa(nwio_ipconf.nwic_ipaddr)); + inet_ntoa(*(struct in_addr *)&nwio_ipconf.nwic_ipaddr)); first_print= 0; } if (do_asc_ip || do_hostname) @@ -256,7 +257,8 @@ char *argv[]; else { /* No host name anywhere. Use the IP address. */ - hostname= inet_ntoa(nwio_ipconf.nwic_ipaddr); + hostname= inet_ntoa(*(struct in_addr *) + &nwio_ipconf.nwic_ipaddr); domain= NULL; } diff --git a/minix/commands/ifconfig/ifconfig.c b/minix/commands/ifconfig/ifconfig.c index 4568dbfec..4b3f3f513 100644 --- a/minix/commands/ifconfig/ifconfig.c +++ b/minix/commands/ifconfig/ifconfig.c @@ -17,6 +17,7 @@ ifconfig.c #include #include #include +#include #if __STDC__ #define PROTO(x,y) x y @@ -36,6 +37,7 @@ PROTO (int main, (int argc, char *argv[]) ); char *prog_name; +int main(argc, argv) int argc; char *argv[]; @@ -167,12 +169,14 @@ char *argv[]; else { printf("%s: address %s", device_s, - inet_ntoa(ipconf.nwic_ipaddr)); + inet_ntoa(*(struct in_addr *) + &ipconf.nwic_ipaddr)); if (ipconf.nwic_flags & NWIC_NETMASK_SET) { printf(" netmask %s", - inet_ntoa(ipconf.nwic_netmask)); + inet_ntoa(*(struct in_addr *) + &ipconf.nwic_netmask)); } #ifdef NWIC_MTU_SET if (ipconf.nwic_mtu) diff --git a/minix/commands/ifdef/ifdef.c b/minix/commands/ifdef/ifdef.c index 23abc930d..1c39d21a9 100644 --- a/minix/commands/ifdef/ifdef.c +++ b/minix/commands/ifdef/ifdef.c @@ -331,7 +331,7 @@ void parse() /* Scan through the file looking for starting lines */ if ((ch = fgetc(zin)) == EOF) stop(); /* Get first char on the line */ - if (ch != '#') + if (ch != '#') { if (proc) { /* If not # and we're processing */ (void)putchar(ch); /* then print the line */ Print; @@ -340,6 +340,7 @@ void parse() Goto; /* else just skip the line */ continue; } + } ch = fgetarg(zin, word); /* Get the word after the # */ diff --git a/minix/commands/ipcs/ipcs.c b/minix/commands/ipcs/ipcs.c index 126a18cc8..94ea9ae15 100644 --- a/minix/commands/ipcs/ipcs.c +++ b/minix/commands/ipcs/ipcs.c @@ -32,6 +32,7 @@ #include #include #include +#include /* remove _() stuff */ #define _(a) a @@ -343,7 +344,7 @@ void do_shm (char format) break; default: - printf("0x%08x ",ipcp->KEY ); + printf("0x%08lx ",ipcp->KEY ); if (pw) printf ("%-10d %-10.10s", shmid, pw->pw_name); else @@ -450,7 +451,7 @@ void do_sem (char format) break; default: - printf("0x%08x ", ipcp->KEY); + printf("0x%08lx ", ipcp->KEY); if (pw) printf ("%-10d %-10.10s", semid, pw->pw_name); else diff --git a/minix/commands/irdpd/irdpd.c b/minix/commands/irdpd/irdpd.c index 4caf62b9a..fbd88c585 100644 --- a/minix/commands/irdpd/irdpd.c +++ b/minix/commands/irdpd/irdpd.c @@ -33,6 +33,7 @@ #include #include #include +#include #define MAX_SOLICITATIONS 3 /* # router solicitations. */ #define SOLICITATION_INTERVAL 3 /* Secs between solicitate retries. */ @@ -127,7 +128,7 @@ char *addr2name(ipaddr_t host) return hostent == nil ? inet_ntoa(host) : hostent->h_name; } #else -#define addr2name(host) inet_ntoa(host) +#define addr2name(host) inet_ntoa(*(struct in_addr *)&(host)) #endif void print_table(void) diff --git a/minix/commands/isoread/isoread.c b/minix/commands/isoread/isoread.c index 749e166f7..a2e863b1a 100644 --- a/minix/commands/isoread/isoread.c +++ b/minix/commands/isoread/isoread.c @@ -374,9 +374,10 @@ char *path; dir_ptr = (struct dir_entry *) Hs_Vol_Desc->root_dir_entry; /* If we look for the root we already have the right entry */ - if (path[0] == '/') + if (path[0] == '/') { if (strlen(path) == 1) return dir_ptr; else name_index = 1; /* first name in path */ + } /* Keep searching for the path elements until all are found */ while (!last_in_path) diff --git a/minix/commands/lpd/lpd.c b/minix/commands/lpd/lpd.c index 81d72f717..59fe937b5 100644 --- a/minix/commands/lpd/lpd.c +++ b/minix/commands/lpd/lpd.c @@ -142,7 +142,7 @@ int lp; char buf[BUFSIZ]; int count, column, line, ncols = 80, nlines = 66; -int flush(void) +void flush(void) /* Copy the characters in the output buffer to the printer, with retries if * out of paper. */ diff --git a/minix/commands/mt/mt.c b/minix/commands/mt/mt.c index c107450fa..bf96d1581 100644 --- a/minix/commands/mt/mt.c +++ b/minix/commands/mt/mt.c @@ -199,8 +199,8 @@ SCSI tape drive %s:\n\ (long) mtget.mt_fileno, (long) mtget.mt_blkno, (long) mtget.mt_resid); - printf(mtget.mt_blksiz == 0 ? "variable\n" : "%d\n", - mtget.mt_blksiz); + if (mtget.mt_blksiz == 0) printf("variable\n"); + else printf("%d\n", mtget.mt_blksiz); } } if (r < 0) { diff --git a/minix/commands/nonamed/nonamed.c b/minix/commands/nonamed/nonamed.c index aeeb5803e..5c8fe4c99 100644 --- a/minix/commands/nonamed/nonamed.c +++ b/minix/commands/nonamed/nonamed.c @@ -42,6 +42,7 @@ static const char version[] = "2.7"; #include #include #include +#include #include #include @@ -133,6 +134,11 @@ static char *nowgmt(void) return timegmt(now); } +static char *my_ntoa(ipaddr_t addr) +{ + return inet_ntoa(*(struct in_addr *)&addr); +} + #define PC(n) ((void) sizeof(char [sizeof(*(n)) == 1]), (char *) (n)) #define namecpy(n1, n2) strcpy(PC(n1), PC(n2)) #define namecat(n1, n2) strcat(PC(n1), PC(n2)) @@ -306,7 +312,7 @@ static int print_qrr(dns_t *dp, size_t size, u8_t *cp0, int q) switch (*ep++) { case 'i': if (cp + sizeof(u32_t) > rlim) return -1; - printf(" %s", inet_ntoa(upack32(cp))); + printf(" %s", my_ntoa(upack32(cp))); cp += sizeof(u32_t); break; case 'l': @@ -820,7 +826,7 @@ static void init_config(ipaddr_t ifip) if (debug >= 2) { printf("%s: I am nonamed %s at %s:%u\n", - nowgmt(), version, inet_ntoa(my_ip), ntohs(my_port)); + nowgmt(), version, my_ntoa(my_ip), ntohs(my_port)); } httl= HTONL(HTTL); @@ -1090,7 +1096,7 @@ static int query_chaos(u8_t *qname, unsigned type, dns_t *dp, size_t *pdlen) /* pack16(cp, htonl(RDLENGTH)) */ cp += sizeof(u16_t); sprintf((char *) cp + 1, "nonamed %s at %s:%u", - version, inet_ntoa(my_ip), ntohs(my_port)); + version, my_ntoa(my_ip), ntohs(my_port)); r= strlen((char *) cp + 1) + 1; pack16(cp - sizeof(u16_t), htons(r)); *cp= r-1; @@ -1347,7 +1353,7 @@ static void refresh_cache(void) if (debug >= 1) { printf("Refresh to %s:%u:\n", - inet_ntoa(current_named()), ntohs(named_port)); + my_ntoa(current_named()), ntohs(named_port)); dns_tell(0, &udp.dns, dlen); } ulen= offsetof(udp_dns_t, dns) + dlen; @@ -1389,7 +1395,7 @@ static int job_read_udp(void *data, int expired) if (ulen < (ssize_t) (sizeof(udp_io_hdr_t) + sizeof(HEADER))) return 1; if (debug >= 1) { - printf("%s:%u UDP ", inet_ntoa(udp.hdr.uih_src_addr), + printf("%s:%u UDP ", my_ntoa(udp.hdr.uih_src_addr), ntohs(udp.hdr.uih_src_port)); dns_tell(0, &udp.dns, dlen); } @@ -1414,7 +1420,7 @@ static int job_read_udp(void *data, int expired) i_named= i; if (debug >= 1) { printf("Current named = %s\n", - inet_ntoa(current_named())); + my_ntoa(current_named())); } stop_searching(); force_expire(job_find_named); @@ -1442,7 +1448,7 @@ static int job_read_udp(void *data, int expired) udp.dns.hdr.id= id; udp.hdr.uih_dst_addr= ip; udp.hdr.uih_dst_port= port; - if (debug >= 1) printf("To client %s:%u\n", inet_ntoa(ip), ntohs(port)); + if (debug >= 1) printf("To client %s:%u\n", my_ntoa(ip), ntohs(port)); } else { /* A query. */ if (udp.dns.hdr.qdcount != HTONS(1)) return 1; @@ -1450,8 +1456,8 @@ static int job_read_udp(void *data, int expired) if(localonly) { /* Check if it's a local query. */ if(ntohl(udp.hdr.uih_src_addr) != LOCALHOST) { - syslog(LOG_WARNING, "nonamed: dropped query from %s", - inet_ntoa(udp.hdr.uih_src_addr)); + syslog(LOG_WARNING, "nonamed: dropped query from %s", + my_ntoa(udp.hdr.uih_src_addr)); return 1; } } @@ -1466,7 +1472,7 @@ static int job_read_udp(void *data, int expired) /* Send an UDP DNS reply. */ if (debug >= 1) { - printf("%s:%u UDP ", inet_ntoa(udp.hdr.uih_dst_addr), + printf("%s:%u UDP ", my_ntoa(udp.hdr.uih_dst_addr), ntohs(udp.hdr.uih_dst_port)); dns_tell(0, &udp.dns, dlen); } @@ -1482,7 +1488,7 @@ static int job_read_udp(void *data, int expired) } if (debug >= 1) { printf("To named %s:%u\n", - inet_ntoa(current_named()), ntohs(named_port)); + my_ntoa(current_named()), ntohs(named_port)); } } } @@ -1703,7 +1709,7 @@ static void tcp_dns_tell(int fd, u8_t *buf) if (ioctl(fd, NWIOGTCPCONF, &tcpconf) < 0) { printf("??\?:?? TCP "); } else { - printf("%s:%u TCP ", inet_ntoa(tcpconf.nwtc_remaddr), + printf("%s:%u TCP ", my_ntoa(tcpconf.nwtc_remaddr), ntohs(tcpconf.nwtc_remport)); } dns_tell(0, oct2dns(buf + sizeof(u16_t)), ntohs(upack16(buf))); @@ -1975,7 +1981,7 @@ static void named_probe(ipaddr_t ip) pack16(udp.dns.data+1, HTONS(T_NS)); pack16(udp.dns.data+3, HTONS(C_IN)); if (debug >= 1) { - printf("PROBE %s ", inet_ntoa(ip)); + printf("PROBE %s ", my_ntoa(ip)); dns_tell(0, &udp.dns, dlen); } diff --git a/minix/commands/part/part.c b/minix/commands/part/part.c index 66c60b0d5..b130b5237 100644 --- a/minix/commands/part/part.c +++ b/minix/commands/part/part.c @@ -1806,7 +1806,7 @@ void m_dump(int ev, object_t *op) pe->sysind, chs[0], chs[1], chs[2]); dos2chs(&pe->last_head, chs); - printf("%6d%5d%4d%10lu%10ld%9lu", + printf("%6d%5d%4d%10u%10u%9u", chs[0], chs[1], chs[2], pe->lowsec, howend == SIZE ? pe->size : pe->size + pe->lowsec - 1, diff --git a/minix/commands/partition/partition.c b/minix/commands/partition/partition.c index c012d3b2f..cfad73112 100644 --- a/minix/commands/partition/partition.c +++ b/minix/commands/partition/partition.c @@ -191,7 +191,7 @@ void show_part(struct part_entry *p) printf("%3d ", (n-1) / 2); show_chs(p->lowsec); show_chs(p->lowsec + p->size - 1); - printf(" %8lu %8lu %7lu\n", p->lowsec, p->size, p->size / 2); + printf(" %8u %8u %7u\n", p->lowsec, p->size, p->size / 2); } void usage(void) @@ -373,7 +373,7 @@ void distribute(void) if (pe->bootind & EXIST_FLAG) { if (base > pe->lowsec) { fprintf(stderr, - "%s: fixed partition %ld is preceded by too big partitions/holes\n", + "%s: fixed partition %u is preceded by too big partitions/holes\n", arg0, ((pe - table) - 1) / 2); exit(1); } diff --git a/minix/commands/pr_routes/pr_routes.c b/minix/commands/pr_routes/pr_routes.c index 6826a5325..864c16e3c 100644 --- a/minix/commands/pr_routes/pr_routes.c +++ b/minix/commands/pr_routes/pr_routes.c @@ -2,8 +2,6 @@ vmd/cmd/simple/pr_routes.c */ -#define _POSIX_C_SOURCE 2 - #include #include #include @@ -21,6 +19,7 @@ vmd/cmd/simple/pr_routes.c #include #include #include +#include #define N_IF 64 /* More than enough? */ @@ -192,9 +191,10 @@ static char *cidr2a(ipaddr_t addr, ipaddr_t mask) testmask= (testmask << 1) & 0xFFFFFFFF; } - sprintf(result, "%s/%-2d", inet_ntoa(addr), n); + sprintf(result, "%s/%-2d", inet_ntoa(*(struct in_addr *)&addr), n); if (n == -1) - strcpy(strchr(result, '/')+1, inet_ntoa(mask)); + strcpy(strchr(result, '/')+1, + inet_ntoa(*(struct in_addr *)&mask)); return result; } @@ -207,7 +207,8 @@ static void print_route(nwio_route_t *route) printf("%*s ", if_width, ifname ? ifname : get_ifname(route->nwr_ifaddr)); printf("%*s ", dest_width, cidr2a(route->nwr_dest, route->nwr_netmask)); - printf("%*s ", gateway_width, inet_ntoa(route->nwr_gateway)); + printf("%*s ", gateway_width, + inet_ntoa(*(struct in_addr *)&route->nwr_gateway)); printf("%*lu ", dist_width, (unsigned long) route->nwr_dist); printf("%*ld ", pref_width, (long) route->nwr_pref); printf("%*lu", mtu_width, (long) route->nwr_mtu); @@ -259,7 +260,8 @@ static void fill_iftab(void) if (iftab[j] == iftab[i]) { fatal("duplicate address in ip%d and ip%d: %s", - i, j, inet_ntoa(iftab[i])); + i, j, + inet_ntoa(*(struct in_addr *)&iftab[i])); } } @@ -280,7 +282,7 @@ static char *get_ifname(ipaddr_t addr) return name; } - return inet_ntoa(addr); + return inet_ntoa(*(struct in_addr *)&addr); } static void fatal(char *fmt, ...) diff --git a/minix/commands/ramdisk/ramdisk.c b/minix/commands/ramdisk/ramdisk.c index 139baf2bc..d629e5b01 100644 --- a/minix/commands/ramdisk/ramdisk.c +++ b/minix/commands/ramdisk/ramdisk.c @@ -1,7 +1,7 @@ #include -#include +#include #include #include #include diff --git a/minix/commands/rarpd/rarpd.c b/minix/commands/rarpd/rarpd.c index cf4962651..8fcfa192c 100644 --- a/minix/commands/rarpd/rarpd.c +++ b/minix/commands/rarpd/rarpd.c @@ -36,6 +36,7 @@ Changed: Dec 11, 2000 by Kees J. Bot #include #include #include +#include #define MAX_RARP_RETRIES 5 #define RARP_TIMEOUT 5 @@ -143,7 +144,8 @@ static void rarp_reply(ethernet_t *ep, char *hostname, ipaddr_t ip_addr, if (debug >= 1) { printf("%s: Replying %s (%s) to %s\n", - ethdev(ep->n), inet_ntoa(ip_addr), hostname, ether_ntoa(ð_addr)); + ethdev(ep->n), inet_ntoa(*(struct in_addr *)&ip_addr), hostname, + ether_ntoa(ð_addr)); } (void) write(ep->eth_fd, &rarp46, sizeof(rarp46)); } @@ -290,8 +292,8 @@ int main(int argc, char **argv) close(fd); if (debug >= 1) { printf("%s: IP address is %s / ", - ipdev(ep->n), inet_ntoa(ep->ip_addr)); - printf("%s\n", inet_ntoa(ep->ip_mask)); + ipdev(ep->n), inet_ntoa(*(struct in_addr *)&ep->ip_addr)); + printf("%s\n", inet_ntoa(*(struct in_addr *)&ep->ip_mask)); } } diff --git a/minix/commands/rawspeed/rawspeed.c b/minix/commands/rawspeed/rawspeed.c index 256f536fa..d7009e608 100644 --- a/minix/commands/rawspeed/rawspeed.c +++ b/minix/commands/rawspeed/rawspeed.c @@ -220,7 +220,7 @@ int main(int argc, char **argv) if (nbytes > 0) { off_t kBpts; - fprintf(stderr, "%d kB / %ld.%ld s = ", + fprintf(stderr, "%lld kB / %ld.%ld s = ", (nbytes + 512) / 1024, tenthsec / 10, tenthsec % 10); if (tenthsec < 5) @@ -230,12 +230,12 @@ int main(int argc, char **argv) seconds = (tenthsec + 5) / 10; kBpts= (nbytes + 512L * seconds) / (1024L * seconds); - fprintf(stderr, "%d kB/s\n", kBpts); + fprintf(stderr, "%lld kB/s\n", kBpts); } else { kBpts= (100 * nbytes + 512L * tenthsec) / (1024L * tenthsec); - fprintf(stderr, "%d.%d kB/s\n", - kBpts/10, kBpts%10); + fprintf(stderr, "%lld.%d kB/s\n", + kBpts/10, (int)(kBpts%10)); } } } @@ -246,10 +246,10 @@ int main(int argc, char **argv) tenthms= (tenthsec * 1000 + nseeks/2) / nseeks; fprintf(stderr, - "%d seeks / %ld.%ld s = %ld seeks/s = %d.%d ms/seek\n", + "%lld seeks / %ld.%ld s = %lld seeks/s = %lld.%d ms/seek\n", nseeks, tenthsec / 10, tenthsec % 10, (nseeks * 10 + tenthsec/2) / tenthsec, - tenthms / 10, tenthms % 10); + tenthms / 10, (int)(tenthms % 10)); for (rpm= 3600; rpm <= 7200; rpm+= 1800) { int rotms = (10000L / 2 * 60 + rpm/2) / rpm; @@ -263,8 +263,9 @@ int main(int argc, char **argv) } else { fprintf(stderr, ", "); } - fprintf(stderr, "%d.%d ms (%d rpm)", - (tenthms - rotms) / 10, (tenthms - rotms) % 10, + fprintf(stderr, "%lld.%d ms (%d rpm)", + (tenthms - rotms) / 10, + (int)((tenthms - rotms) % 10), rpm); } if (disc) fputc('\n', stdout); diff --git a/minix/commands/remsync/remsync.c b/minix/commands/remsync/remsync.c index 5bfbe68d6..1480a1eda 100644 --- a/minix/commands/remsync/remsync.c +++ b/minix/commands/remsync/remsync.c @@ -1208,8 +1208,10 @@ void apply_mkold(const char *file, const char *err) return; } fprintf(stderr, "made %s look old", file); - fprintf(stderr, err == nil ? "\n" : " due to a remote problem: %s\n", - err); + if (err != nil) + fprintf(stderr, " due to a remote problem: %s\n", err); + else + fprintf(stderr, "\n"); } void apply_chmod(const char *file, mode_t mode, uid_t uid, gid_t gid, int talk) diff --git a/minix/commands/swifi/extra.c b/minix/commands/swifi/extra.c index a71a53a25..1b2135e4f 100644 --- a/minix/commands/swifi/extra.c +++ b/minix/commands/swifi/extra.c @@ -152,7 +152,7 @@ unsigned char text_read_ub(void *addr) vaddr= (unsigned long)addr; vaddr &= ~TRAP_BIT; - v= ptrace(T_READB_INS, victim_pid, vaddr, 0); + v= ptrace(T_READB_INS, victim_pid, (void *)vaddr, 0); if (v < 0) { fprintf(stderr, @@ -180,7 +180,7 @@ void text_write_ub(void *addr, unsigned char value) vaddr= (unsigned long)addr; vaddr &= ~TRAP_BIT; - v= ptrace(T_WRITEB_INS, victim_pid, vaddr, value); + v= ptrace(T_WRITEB_INS, victim_pid, (void *)vaddr, value); if (v < 0) { fprintf(stderr, diff --git a/minix/commands/synctree/synctree.c b/minix/commands/synctree/synctree.c index 7d1a98c9c..e5fff703a 100644 --- a/minix/commands/synctree/synctree.c +++ b/minix/commands/synctree/synctree.c @@ -1429,7 +1429,7 @@ int main(int argc, char **argv) startprocess(slave, s_mach, s_dir, 0); } else { /* synctree machine1:dir1 machine2:dir2 */ - if (pipe(m2m) < 0) perrx(pipe); + if (pipe(m2m) < 0) perrx("pipe"); switch (s_pid= fork()) { case -1: diff --git a/minix/commands/tcpd/tcpd.c b/minix/commands/tcpd/tcpd.c index ad7d3785a..9e00d60dc 100644 --- a/minix/commands/tcpd/tcpd.c +++ b/minix/commands/tcpd/tcpd.c @@ -22,6 +22,8 @@ tcpd.c #include #include #include +#include +#include /* This program can be compiled to be paranoid, i.e. check incoming connection * according to an access file, or to trust anyone. The much smaller "trust @@ -285,7 +287,7 @@ int main(int argc, char **argv) if (debug && ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0) { fprintf(stderr, "%s %s: Connection from %s:%u\n", arg0, service, - inet_ntoa(tcpconf.nwtc_remaddr), + inet_ntoa(*(struct in_addr *)&tcpconf.nwtc_remaddr), ntohs(tcpconf.nwtc_remport)); } /* All is well, no need to stall. */ diff --git a/minix/commands/tcpdp/Makefile b/minix/commands/tcpdp/Makefile index 0e8bb9c47..957bd5c7d 100644 --- a/minix/commands/tcpdp/Makefile +++ b/minix/commands/tcpdp/Makefile @@ -1,10 +1,9 @@ .include PROG= tcpdp +.PATH: ${NETBSDSRCDIR}/minix/commands/tcpd SRCS= tcpd.c CPPFLAGS+= -DPARANOID=1 MAN= -.PATH: ${NETBSDSRCDIR}/commands/tcpd - .include diff --git a/minix/commands/tcpdp/tcpd.c b/minix/commands/tcpdp/tcpd.c deleted file mode 100644 index 9d1d32d7f..000000000 --- a/minix/commands/tcpdp/tcpd.c +++ /dev/null @@ -1,312 +0,0 @@ -/* -tcpd.c -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* This program can be compiled to be paranoid, i.e. check incoming connection - * according to an access file, or to trust anyone. The much smaller "trust - * 'em" binary will call the paranoid version if the access file exists. - */ - -static char *arg0, *service; -static unsigned nchildren; - -static void report(const char *label) -{ - int err= errno; - - fprintf(stderr, "%s %s: %s: %s\n", arg0, service, label, strerror(err)); - errno= err; -} - -static void sigchld(int sig) -{ - while (waitpid(0, NULL, WNOHANG) > 0) { - if (nchildren > 0) nchildren--; - } -} - -static void release(int *fd) -{ - if (*fd != -1) { - close(*fd); - *fd= -1; - } -} - -static void usage(void) -{ - fprintf(stderr, - "Usage: %s [-d] [-m maxclients] service program [arg ...]\n", - arg0); - exit(1); -} - -int main(int argc, char **argv) -{ - tcpport_t port; - int last_failed = 0; - struct nwio_tcpcl tcplistenopt; - struct nwio_tcpconf tcpconf; - struct nwio_tcpopt tcpopt; - char *tcp_device; - struct servent *servent; - int tcp_fd, client_fd, r; - int pfd[2]; - unsigned stall= 0; - struct sigaction sa; - sigset_t chldmask, chldunmask, oldmask; - char **progv; - -#if !PARANOID -# define debug 0 -# define max_children ((unsigned) -1) - arg0= argv[0]; - - /* Switch to the paranoid version of me if there are flags, or if - * there is an access file. - */ - if (argv[1][0] == '-' || access(_PATH_SERVACCES, F_OK) == 0) { - execv("/usr/bin/tcpdp", argv); - report("tcpdp"); - exit(1); - } - if (argc < 3) usage(); - service= argv[1]; - progv= argv+2; - -#else /* PARANOID */ - int debug, i; - unsigned max_children; - - arg0= argv[0]; - debug= 0; - max_children= -1; - i= 1; - while (i < argc && argv[i][0] == '-') { - char *opt= argv[i++] + 1; - unsigned long m; - char *end; - - if (*opt == '-' && opt[1] == 0) break; /* -- */ - - while (*opt != 0) switch (*opt++) { - case 'd': - debug= 1; - break; - case 'm': - if (*opt == 0) { - if (i == argc) usage(); - opt= argv[i++]; - } - m= strtoul(opt, &end, 10); - if (m <= 0 || m > UINT_MAX || *end != 0) usage(); - max_children= m; - opt= ""; - break; - default: - usage(); - } - } - service= argv[i++]; - progv= argv+i; - if (i >= argc) usage(); -#endif - - /* The interface to start the service on. */ - if ((tcp_device= getenv("TCP_DEVICE")) == NULL) tcp_device= TCP_DEVICE; - - /* Let SIGCHLD interrupt whatever I'm doing. */ - sigemptyset(&chldmask); - sigaddset(&chldmask, SIGCHLD); - sigprocmask(SIG_BLOCK, &chldmask, &oldmask); - chldunmask= oldmask; - sigdelset(&chldunmask, SIGCHLD); - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sa.sa_handler = sigchld; - sigaction(SIGCHLD, &sa, NULL); - - /* Open a socket to the service I'm to serve. */ - if ((servent= getservbyname(service, "tcp")) == NULL) { - unsigned long p; - char *end; - - p= strtoul(service, &end, 0); - if (p <= 0 || p > 0xFFFF || *end != 0) { - fprintf(stderr, "%s: %s: Unknown service\n", - arg0, service); - exit(1); - } - port= htons((tcpport_t) p); - } else { - port= servent->s_port; - - if (debug) - { - fprintf(stderr, "%s %s: listening to port %u\n", - arg0, service, ntohs(port)); - } - } - - /* No client yet. */ - client_fd= -1; - - while (1) { - if ((tcp_fd= open(tcp_device, O_RDWR)) < 0) { - report(tcp_device); -#if 0 - if (errno == ENOENT || errno == ENODEV - || errno == ENXIO) { - exit(1); - } -#endif - last_failed = 1; - goto bad; - } - if(last_failed) - fprintf(stderr, "%s %s: %s: Ok\n", - arg0, service, tcp_device); - last_failed = 0; - - tcpconf.nwtc_flags= NWTC_LP_SET | NWTC_UNSET_RA | NWTC_UNSET_RP; - tcpconf.nwtc_locport= port; - - if (ioctl(tcp_fd, NWIOSTCPCONF, &tcpconf) < 0) { - report("Can't configure TCP channel"); - exit(1); - } - - tcpopt.nwto_flags= NWTO_DEL_RST; - - if (ioctl(tcp_fd, NWIOSTCPOPT, &tcpopt) < 0) { - report("Can't set TCP options"); - exit(1); - } - - if (client_fd != -1) { - /* We have a client, so start a server for it. */ - - tcpopt.nwto_flags= 0; - (void) ioctl(client_fd, NWIOSTCPOPT, &tcpopt); - - fflush(NULL); - - /* Create a pipe to serve as an error indicator. */ - if (pipe(pfd) < 0) { - report("pipe"); - goto bad; - } - (void) fcntl(pfd[1], F_SETFD, - fcntl(pfd[1], F_GETFD) | FD_CLOEXEC); - - /* Fork and exec. */ - switch (fork()) { - case -1: - report("fork"); - close(pfd[0]); - close(pfd[1]); - goto bad; - case 0: - close(tcp_fd); - close(pfd[0]); -#if PARANOID - /* Check if access to this service allowed. */ - if (ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0 - && tcpconf.nwtc_remaddr != tcpconf.nwtc_locaddr - && !servxcheck(tcpconf.nwtc_remaddr, service, NULL) - ) { - exit(1); - } -#endif - sigprocmask(SIG_SETMASK, &oldmask, NULL); - dup2(client_fd, 0); - dup2(client_fd, 1); - close(client_fd); - execvp(progv[0], progv); - report(progv[0]); - write(pfd[1], &errno, sizeof(errno)); - exit(1); - default: - nchildren++; - release(&client_fd); - close(pfd[1]); - r= read(pfd[0], &errno, sizeof(errno)); - close(pfd[0]); - if (r != 0) goto bad; - break; - } - } - - while (nchildren >= max_children) { - /* Too many clients, wait for one to die off. */ - sigsuspend(&chldunmask); - } - - /* Wait for a new connection. */ - sigprocmask(SIG_UNBLOCK, &chldmask, NULL); - - tcplistenopt.nwtcl_flags= 0; - while (ioctl(tcp_fd, NWIOTCPLISTEN, &tcplistenopt) < 0) { - if (errno != EINTR) { - if (errno != EAGAIN || debug) { - report("Unable to listen"); - } - goto bad; - } - } - sigprocmask(SIG_BLOCK, &chldmask, NULL); - - /* We got a connection. */ - client_fd= tcp_fd; - tcp_fd= -1; - - if (debug && ioctl(client_fd, NWIOGTCPCONF, &tcpconf) == 0) { - fprintf(stderr, "%s %s: Connection from %s:%u\n", - arg0, service, - inet_ntoa(tcpconf.nwtc_remaddr), - ntohs(tcpconf.nwtc_remport)); - } - /* All is well, no need to stall. */ - stall= 0; - continue; - - bad: - /* All is not well, release resources. */ - release(&tcp_fd); - release(&client_fd); - - /* Wait a bit if this happens more than once. */ - if (stall != 0) { - if (debug) { - fprintf(stderr, "%s %s: stalling %u second%s\n", - arg0, service, - stall, stall == 1 ? "" : "s"); - } - sleep(stall); - stall <<= 1; - } else { - stall= 1; - } - } -} diff --git a/minix/commands/tcpstat/tcpstat.c b/minix/commands/tcpstat/tcpstat.c index 2ea8e4fca..2fa35f855 100644 --- a/minix/commands/tcpstat/tcpstat.c +++ b/minix/commands/tcpstat/tcpstat.c @@ -31,6 +31,7 @@ Created: June 1995 by Philip Homburg #include #include #include +#include u32_t system_hz; char *prog_name; @@ -179,7 +180,7 @@ void print_conn(int i, clock_t now) addr_str= hostent->h_name; } else - addr_str= inet_ntoa(a1); + addr_str= inet_ntoa(*(struct in_addr *)&a1); printf(" %s:", addr_str); if (p1 == 0) @@ -205,7 +206,7 @@ void print_conn(int i, clock_t now) addr_str= hostent->h_name; } else - addr_str= inet_ntoa(a2); + addr_str= inet_ntoa(*(struct in_addr *)&a2); printf("%s:", addr_str); if (p2 == 0) @@ -225,7 +226,7 @@ void print_conn(int i, clock_t now) case TCS_CLOSED: printf("CLOSED"); if (tcp_conn->tc_senddis >= now) { - printf("(time wait %d s)", + printf("(time wait %lu s)", (tcp_conn->tc_senddis-now)/system_hz); } no_verbose= 1; diff --git a/minix/commands/telnet/ttn.c b/minix/commands/telnet/ttn.c index 7ba56590c..d40b1a1af 100644 --- a/minix/commands/telnet/ttn.c +++ b/minix/commands/telnet/ttn.c @@ -21,6 +21,7 @@ ttn.c #include #include #include +#include #include "ttn.h" #if __STDC__ @@ -122,7 +123,7 @@ int main(int argc, char *argv[]) } fprintf(stderr, "Connecting to %s:%u...\n", - inet_ntoa(host), ntohs(port)); + inet_ntoa(*(struct in_addr *)&host), ntohs(port)); tcp_device= getenv("TCP_DEVICE"); if (tcp_device == NULL) diff --git a/minix/commands/telnetd/main.c b/minix/commands/telnetd/main.c index a4ded56aa..ccf39a0cb 100644 --- a/minix/commands/telnetd/main.c +++ b/minix/commands/telnetd/main.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "telnetd.h" #if 0 @@ -92,7 +93,7 @@ char *hostname; sizeof(tcpconf.nwtc_remaddr), AF_INET)) != NULL) { hostname = hostent->h_name; } else { - hostname = inet_ntoa(tcpconf.nwtc_remaddr); + hostname = inet_ntoa(*(struct in_addr *)&tcpconf.nwtc_remaddr); } /* Try allocating a PTY. */ diff --git a/minix/commands/udpstat/udpstat.c b/minix/commands/udpstat/udpstat.c index e893b6c73..882152245 100644 --- a/minix/commands/udpstat/udpstat.c +++ b/minix/commands/udpstat/udpstat.c @@ -30,6 +30,7 @@ Created: March 2001 by Philip Homburg #include #include #include +#include char *prog_name; udp_fd_t udp_fd_table[UDP_FD_NR]; @@ -265,7 +266,8 @@ void print_fd(int i, clock_t now) locaddr_str= hostent->h_name; } else - locaddr_str= inet_ntoa(udp_port->up_ipaddr); + locaddr_str= + inet_ntoa(*(struct in_addr *)&udp_port->up_ipaddr); } else if (nwuo_flags & NWUO_EN_BROAD) locaddr_str= "255.255.255.255"; @@ -298,7 +300,8 @@ void print_fd(int i, clock_t now) remaddr_str= hostent->h_name; } else - remaddr_str= inet_ntoa(uf_udpopt.nwuo_remaddr); + remaddr_str= + inet_ntoa(*(struct in_addr *)&uf_udpopt.nwuo_remaddr); printf("%s:", remaddr_str); if (!(nwuo_flags & NWUO_RP_SET)) diff --git a/minix/commands/zmodem/rz.c b/minix/commands/zmodem/rz.c index e137c7bf9..946be48fb 100644 --- a/minix/commands/zmodem/rz.c +++ b/minix/commands/zmodem/rz.c @@ -1042,7 +1042,7 @@ void canit() raw_wbuf(strlen(canistr), canistr); purgeline(); #else - printf(canistr); + printf("%s", canistr); Lleft=0; /* Do read next time ... */ fflush(stdout); #endif diff --git a/minix/commands/zmodem/sz.c b/minix/commands/zmodem/sz.c index 2724388ab..3691e59af 100644 --- a/minix/commands/zmodem/sz.c +++ b/minix/commands/zmodem/sz.c @@ -630,7 +630,7 @@ int wctxpn(char *name) while (q < (txbuf + 1024)) *q++ = 0; if (!Ascii && (in!=stdin) && *name && fstat(fileno(in), &f)!= -1) - sprintf(p, "%llu %o %o 0 %d %ld", f.st_size, f.st_mtime, + sprintf(p, "%llu %llo %o 0 %d %ld", f.st_size, f.st_mtime, f.st_mode, Filesleft, Totalleft); Totalleft -= f.st_size; if (--Filesleft <= 0) @@ -1010,7 +1010,7 @@ void canit() raw_wbuf(strlen(canistr), canistr); purgeline(); #else - printf(canistr); + printf("%s", canistr); fflush(stdout); #endif } @@ -1379,7 +1379,7 @@ gotack: if (Test) { if ( --tleft) while (tcount < 20000) { - printf(qbf); fflush(stdout); + printf("%s", qbf); fflush(stdout); tcount += strlen(qbf); #ifdef READCHECK while (rdchk(iofd)) { diff --git a/minix/man/man2/ptrace.2 b/minix/man/man2/ptrace.2 index efb27259c..458c4b84c 100644 --- a/minix/man/man2/ptrace.2 +++ b/minix/man/man2/ptrace.2 @@ -8,7 +8,7 @@ ptrace \- process trace #include #include -long ptrace(int \fIreq\fP, pid_t \fIpid\fP, long \fIaddr\fP, long \fIdata\fP) +long ptrace(int \fIreq\fP, pid_t \fIpid\fP, void *\fIaddr\fP, long \fIdata\fP) .ft R .fi .SH DESCRIPTION