From 570fc119c68f56f4f3c82bad05fd5957109d49b3 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 10 Feb 2024 02:32:16 -0600 Subject: [PATCH] Whitespace cleanup. Remove trailing spaces and leading tabs that crept in. --- lib/deflate.c | 2 +- lib/hash.c | 2 +- lib/utf8.c | 2 +- toys/android/sendevent.c | 2 +- toys/lsb/mount.c | 2 +- toys/lsb/seq.c | 2 +- toys/lsb/umount.c | 4 +- toys/net/host.c | 4 +- toys/net/ifconfig.c | 4 +- toys/net/ping.c | 4 +- toys/net/sntp.c | 2 +- toys/net/tunctl.c | 2 +- toys/other/acpi.c | 2 +- toys/other/fsfreeze.c | 2 +- toys/other/hwclock.c | 2 +- toys/other/inotifyd.c | 2 +- toys/other/lsusb.c | 2 +- toys/other/makedevs.c | 2 +- toys/other/mkpasswd.c | 2 +- toys/other/partprobe.c | 2 +- toys/other/pwdx.c | 2 +- toys/other/switch_root.c | 2 +- toys/other/sysctl.c | 2 +- toys/other/watch.c | 4 +- toys/pending/arp.c | 16 +++--- toys/pending/arping.c | 42 +++++++-------- toys/pending/bootchartd.c | 18 +++---- toys/pending/brctl.c | 38 +++++++------- toys/pending/crond.c | 2 +- toys/pending/crontab.c | 2 +- toys/pending/dhcp.c | 14 ++--- toys/pending/dhcp6.c | 108 +++++++++++++++++++------------------- toys/pending/dhcpd.c | 16 +++--- toys/pending/diff.c | 2 +- toys/pending/dumpleases.c | 12 ++--- toys/pending/expr.c | 4 +- toys/pending/fdisk.c | 96 ++++++++++++++++----------------- toys/pending/fsck.c | 36 ++++++------- toys/pending/git.c | 2 +- toys/pending/groupadd.c | 2 +- toys/pending/init.c | 14 ++--- toys/pending/ip.c | 98 +++++++++++++++++----------------- toys/pending/ipcrm.c | 2 +- toys/pending/ipcs.c | 2 +- toys/pending/klogd.c | 4 +- toys/pending/last.c | 24 ++++----- toys/pending/modprobe.c | 16 +++--- toys/pending/route.c | 2 +- toys/pending/sh.c | 6 +-- toys/pending/strace.c | 4 +- toys/pending/sulogin.c | 12 ++--- toys/pending/syslogd.c | 4 +- toys/pending/tcpsvd.c | 40 +++++++------- toys/pending/telnetd.c | 34 ++++++------ toys/pending/tftp.c | 8 +-- toys/pending/traceroute.c | 64 +++++++++++----------- toys/pending/useradd.c | 8 +-- toys/pending/userdel.c | 6 +-- toys/pending/xzcat.c | 10 ++-- toys/posix/kill.c | 2 +- toys/posix/od.c | 2 +- toys/posix/paste.c | 2 +- toys/posix/ps.c | 8 +-- toys/posix/sed.c | 10 ++-- toys/posix/tail.c | 2 +- toys/posix/tar.c | 4 +- toys/posix/ulimit.c | 2 +- toys/posix/uname.c | 4 +- toys/posix/uuencode.c | 4 +- 69 files changed, 433 insertions(+), 433 deletions(-) diff --git a/lib/deflate.c b/lib/deflate.c index 12263f7a..c1800750 100644 --- a/lib/deflate.c +++ b/lib/deflate.c @@ -466,7 +466,7 @@ long long gzip_fd(int infd, int outfd) // 2 ID bytes (1F, 8b), gzip method byte (8=deflate), FLAG byte (none), // 4 byte MTIME (zeroed), Extra Flags (2=maximum compression), // Operating System (FF=unknown) - + dd->infd = infd; xwrite(bb->fd, "\x1f\x8b\x08\0\0\0\0\0\x02\xff", 10); diff --git a/lib/hash.c b/lib/hash.c index f4b80c0b..95241d94 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -389,6 +389,6 @@ void hash_by_name(int fd, char *name, char *result) // by looping on a volatile pointer. for (pp = (void *)hash; pp-(unsigned *)hash=0 && len>width) str += utf8skip(str, len-width); if (len>width) len = width; - // Left pad if right justified + // Left pad if right justified if (padto>0 && apad>len) printf("%*s", apad-len, ""); crunch_str(&str, len, stdout, 0, crunch_rev_escape); if (padto<0 && apad>len) printf("%*s", apad-len, ""); diff --git a/toys/android/sendevent.c b/toys/android/sendevent.c index 8e982e0b..b952d192 100644 --- a/toys/android/sendevent.c +++ b/toys/android/sendevent.c @@ -27,7 +27,7 @@ void sendevent_main(void) if (ioctl(fd, EVIOCGVERSION, &version)) perror_exit("EVIOCGVERSION failed for %s", *toys.optargs); - + memset(&ev, 0, sizeof(ev)); // TODO: error checking and support for named constants. ev.type = atoi(toys.optargs[1]); diff --git a/toys/lsb/mount.c b/toys/lsb/mount.c index 109f6e19..9fbd432c 100644 --- a/toys/lsb/mount.c +++ b/toys/lsb/mount.c @@ -349,7 +349,7 @@ void mount_main(void) for (mmm = mtl2; mmm; mmm = mmm->next) if (!strcmp(mm->dir, mmm->dir) && !strcmp(mm->device, mmm->device)) break; - + // user only counts from fstab, not opts. if (!mmm) { TT.okuser = comma_scan(mm->opts, "user", 1); diff --git a/toys/lsb/seq.c b/toys/lsb/seq.c index b44d05c6..e73d70fc 100644 --- a/toys/lsb/seq.c +++ b/toys/lsb/seq.c @@ -55,7 +55,7 @@ static double parsef(char *s) static char *flush_toybuf(char *ss) { if (ss-toybufdir, dir)) while ((s = comma_iterate(&mt->opts, &len))) { if (len == 4 && strncmp(s, "user", 4)) user = 1; - else if (len == 6 && strncmp(s, "nouser", 6)) user = 0; + else if (len == 6 && strncmp(s, "nouser", 6)) user = 0; } mt = mt->next; @@ -125,7 +125,7 @@ void umount_main(void) if (toys.optflags & FLAG_a) { char *typestr = 0; struct arg_list *tal; - + for (tal = TT.t; tal; tal = tal->next) comma_collate(&typestr, tal->arg); for (ml = mlrev; ml; ml = ml->prev) if (mountlist_istype(ml, typestr)) do_umount(ml->dir, ml->device, flags); diff --git a/toys/net/host.c b/toys/net/host.c index f8e54dcc..4082a8f3 100644 --- a/toys/net/host.c +++ b/toys/net/host.c @@ -142,7 +142,7 @@ void host_main(void) qlen = 0; for (sec = 0; sec<(2<0 && sec>1) + if (verbose && count>0 && sec>1) puts(sec==2 ? "For authoritative answers, see:" : "Additional information:"); @@ -162,7 +162,7 @@ void host_main(void) else if (type==2 || type==5) xdn_expand(abuf, abuf+alen, p, t2, t2len); else if (type==13 || type==16) sprintf(t2, "\"%.*s\"", minof(pllen, t2len), p); - else if (type==6) { + else if (type==6) { ss = p+xdn_expand(abuf, abuf+alen, p, t2, t2len-1); j = strlen(t2); t2[j++] = ' '; diff --git a/toys/net/ifconfig.c b/toys/net/ifconfig.c index 63e7a0ae..632d15dd 100644 --- a/toys/net/ifconfig.c +++ b/toys/net/ifconfig.c @@ -210,7 +210,7 @@ static void display_ifconfig(char *name, int always, unsigned long long val[]) char *ptr = ipv6_addr+sizeof(ipv6_addr)-1; // convert giant hex string into colon-spearated ipv6 address by - // inserting ':' every 4 characters. + // inserting ':' every 4 characters. for (i = 32; i; i--) if ((*(ptr--) = ipv6_addr[i])) if (!(i&3)) *(ptr--) = ':'; @@ -447,7 +447,7 @@ void ifconfig_main(void) if (*hw_addr == ':') hw_addr++; sscanf(hw_addr, "%2x%n", &val, &len); - if (!len || len > 2) break; // 1 nibble can be set e.g. C2:79:38:95:D:A + if (!len || len > 2) break; // 1 nibble can be set e.g. C2:79:38:95:D:A hw_addr += len; *p++ = val; } diff --git a/toys/net/ping.c b/toys/net/ping.c index e7b296db..4237d8a9 100644 --- a/toys/net/ping.c +++ b/toys/net/ping.c @@ -13,7 +13,7 @@ // -s > 4064 = sizeof(toybuf)-sizeof(struct icmphdr)-CMSG_SPACE(sizeof(uint8_t)), then kernel adds 20 bytes USE_PING(NEWTOY(ping, "<1>1m#t#<0>255=64c#<0=3s#<0>4064=56i%W#<0=3w#<0qf46I:[-46]", TOYFLAG_USR|TOYFLAG_BIN)) USE_PING(OLDTOY(ping6, ping, TOYFLAG_USR|TOYFLAG_BIN)) - + config PING bool "ping" default y @@ -40,7 +40,7 @@ config PING -w SEC Exit after this many seconds */ -#define FOR_ping +#define FOR_ping #include "toys.h" #include diff --git a/toys/net/sntp.c b/toys/net/sntp.c index 4a216df4..2f9822b4 100644 --- a/toys/net/sntp.c +++ b/toys/net/sntp.c @@ -184,7 +184,7 @@ void sntp_main(void) // generating second request. (We know this time is in the past // because transmission took time, but it's a start. And if time is // miraculously exact, don't loop.) - + lunchtime(&tv2, diff); diff = nanodiff(&tv, &tv2); if (unset && diff) break; diff --git a/toys/net/tunctl.c b/toys/net/tunctl.c index 12855708..b18306f0 100644 --- a/toys/net/tunctl.c +++ b/toys/net/tunctl.c @@ -7,7 +7,7 @@ * This is useful for things like "kvm -netdev tap" and containers. * See https://landley.net/lxc/02-networking.html for example usage. * - * TODO: bridge mode + * TODO: bridge mode * -b bridge daemon (forwards packets between NAME and NAME2 interfaces) diff --git a/toys/other/acpi.c b/toys/other/acpi.c index 193ac28a..63553ce0 100644 --- a/toys/other/acpi.c +++ b/toys/other/acpi.c @@ -11,7 +11,7 @@ config ACPI default y help usage: acpi [-abctV] - + Show status of power sources and thermal devices. -a Show power adapters diff --git a/toys/other/fsfreeze.c b/toys/other/fsfreeze.c index ee7bd530..84188d34 100644 --- a/toys/other/fsfreeze.c +++ b/toys/other/fsfreeze.c @@ -22,7 +22,7 @@ config FSFREEZE void fsfreeze_main(void) { - int fd = xopenro(*toys.optargs); + int fd = xopenro(*toys.optargs); long p = 1; xioctl(fd, FLAG(f) ? FIFREEZE : FITHAW, &p); diff --git a/toys/other/hwclock.c b/toys/other/hwclock.c index eaec842e..4087ec93 100644 --- a/toys/other/hwclock.c +++ b/toys/other/hwclock.c @@ -63,7 +63,7 @@ void hwclock_main() if (FLAG(w)) { /* The value of tm_isdst is positive if daylight saving time is in effect, - * zero if it is not and negative if the information is not available. + * zero if it is not and negative if the information is not available. * TODO: so why isn't this negative...? */ tm.tm_isdst = 0; xioctl(fd, RTC_SET_TIME, &tm); diff --git a/toys/other/inotifyd.c b/toys/other/inotifyd.c index 42d1d76e..3dc66025 100644 --- a/toys/other/inotifyd.c +++ b/toys/other/inotifyd.c @@ -1,4 +1,4 @@ -/* inotifyd.c - inotify daemon. +/* inotifyd.c - inotify daemon. * * Copyright 2013 Ashwini Kumar * Copyright 2013 Kyungwan Han diff --git a/toys/other/lsusb.c b/toys/other/lsusb.c index 600858bb..6bbfe0df 100644 --- a/toys/other/lsusb.c +++ b/toys/other/lsusb.c @@ -128,7 +128,7 @@ struct dev_ids *parse_dev_ids(char *name, struct dev_ids **and) else if (s) fd = xopen(s, O_RDONLY); llist_traverse(sl, free); if (fd == -1) return 0; - + for (fp = fdopen(fd, "r"); (s = ss = xgetline(fp)); free(s)) { // TODO parse and use third level instead of skipping it here if (s[strspn(s, " \t")]=='#' || strstart(&ss, "\t\t")) continue; diff --git a/toys/other/makedevs.c b/toys/other/makedevs.c index 4edd0737..009b3ed9 100644 --- a/toys/other/makedevs.c +++ b/toys/other/makedevs.c @@ -4,7 +4,7 @@ * Copyright 2014 Kyungwan Han * * No Standard - + USE_MAKEDEVS(NEWTOY(makedevs, "<1>1d:", TOYFLAG_USR|TOYFLAG_BIN)) config MAKEDEVS diff --git a/toys/other/mkpasswd.c b/toys/other/mkpasswd.c index 66d05a7d..9f895075 100644 --- a/toys/other/mkpasswd.c +++ b/toys/other/mkpasswd.c @@ -65,7 +65,7 @@ void mkpasswd_main(void) if (!*toys.optargs) { // Prompt and read interactively? if (isatty(0)) { - if (read_password(toybuf, sizeof(toybuf), "Password: ")) + if (read_password(toybuf, sizeof(toybuf), "Password: ")) perror_exit("password read failed"); } else { for (ii = 0; ii diff --git a/toys/other/switch_root.c b/toys/other/switch_root.c index d3fd3728..1c750608 100644 --- a/toys/other/switch_root.c +++ b/toys/other/switch_root.c @@ -93,7 +93,7 @@ void switch_root_main(void) perror_msg("bad console '%s'", TT.c); goto panic; } - + // Ok, enough safety checks: wipe root partition. dirtree_read("/", del_node); diff --git a/toys/other/sysctl.c b/toys/other/sysctl.c index 37735942..2d79176f 100644 --- a/toys/other/sysctl.c +++ b/toys/other/sysctl.c @@ -4,7 +4,7 @@ * Copyright 2014 Kyungwan Han * * No Standard - + USE_SYSCTL(NEWTOY(sysctl, "^neNqwpaA[!ap][!aq][!aw][+aA]", TOYFLAG_SBIN)) config SYSCTL diff --git a/toys/other/watch.c b/toys/other/watch.c index f8f3dfb1..14048d85 100644 --- a/toys/other/watch.c +++ b/toys/other/watch.c @@ -106,8 +106,8 @@ void watch_main(void) // Get and measure time string, trimming gratuitous \n ctimelen = strlen(ss = ctime(&t)); if (ss[ctimelen-1]=='\n') ss[--ctimelen] = 0; - - // print cmdline, then * or ' ' (showing truncation), then ctime + + // print cmdline, then * or ' ' (showing truncation), then ctime pad = width-++ctimelen; if (pad>0) draw_trim(cmd, -pad, pad); printf("%c", pad 4 && !strcmp(*argv, "dev")) { if (!*++argv) error_exit("NULL dev"); TT.device = *argv; @@ -129,10 +129,10 @@ static void check_flags(int *i, char** argv) *i = flag; } -static int set_entry(void) +static int set_entry(void) { int flags = 0; - + if (!toys.optargs[1]) error_exit("bad syntax"); if (!FLAG(D)) { @@ -173,11 +173,11 @@ static int set_entry(void) static int ip_to_host(struct sockaddr *sa, int flag) { int status = 0; - char hbuf[NI_MAXHOST] = {0,}, sbuf[NI_MAXSERV] = {0,}; + char hbuf[NI_MAXHOST] = {0,}, sbuf[NI_MAXSERV] = {0,}; socklen_t len = sizeof(struct sockaddr_in6); - + *toybuf = 0; - if (!(status = getnameinfo(sa, len, hbuf, sizeof(hbuf), sbuf, + if (!(status = getnameinfo(sa, len, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), flag))) { strcpy(toybuf, hbuf); return 0; diff --git a/toys/pending/arping.c b/toys/pending/arping.c index 68ee5eac..aae7161d 100644 --- a/toys/pending/arping.c +++ b/toys/pending/arping.c @@ -44,12 +44,12 @@ GLOBALS( unicast_flag; ) -struct sockaddr_ll src_pk, dst_pk; +struct sockaddr_ll src_pk, dst_pk; struct in_addr src_addr, dest_addr; extern void *mempcpy(void *dest, const void *src, size_t n); // Gets information of INTERFACE and updates IFINDEX, MAC and IP. -static void get_interface(char *interface, int *ifindex, uint32_t *oip, +static void get_interface(char *interface, int *ifindex, uint32_t *oip, uint8_t *mac) { struct ifreq req; @@ -84,16 +84,16 @@ static void done(int sig) { if (!(toys.optflags & FLAG_q)) { xprintf("Sent %u probe(s) (%u broadcast(s))\n", TT.sent_nr, TT.brd_sent); - xprintf("Received %u repl%s (%u request(s), %u broadcast(s))\n", + xprintf("Received %u repl%s (%u request(s), %u broadcast(s))\n", TT.rcvd_nr, TT.rcvd_nr == 1 ? "y":"ies", TT.rcvd_req, TT.brd_rcv); } if (toys.optflags & FLAG_D) exit(!!TT.rcvd_nr); //In -U mode, No reply is expected. - if (toys.optflags & FLAG_U) exit(EXIT_SUCCESS); + if (toys.optflags & FLAG_U) exit(EXIT_SUCCESS); exit(!TT.rcvd_nr); } -// Create and Send Packet +// Create and Send Packet static void send_packet() { int ret; @@ -104,8 +104,8 @@ static void send_packet() arp_h->ar_hrd = htons(ARPHRD_ETHER); arp_h->ar_pro = htons(ETH_P_IP); arp_h->ar_hln = src_pk.sll_halen; - arp_h->ar_pln = 4; - arp_h->ar_op = (toys.optflags & FLAG_A) ? htons(ARPOP_REPLY) + arp_h->ar_pln = 4; + arp_h->ar_op = (toys.optflags & FLAG_A) ? htons(ARPOP_REPLY) : htons(ARPOP_REQUEST); ptr = mempcpy(ptr, &src_pk.sll_addr, src_pk.sll_halen); @@ -115,7 +115,7 @@ static void send_packet() src_pk.sll_halen); ptr = mempcpy(ptr, &dest_addr, 4); - ret = sendto(TT.sockfd, sbuf, ptr - sbuf, 0, + ret = sendto(TT.sockfd, sbuf, ptr - sbuf, 0, (struct sockaddr *)&dst_pk, sizeof(dst_pk)); if (ret == ptr - sbuf) { struct timeval tval; @@ -134,19 +134,19 @@ static void recv_from(struct sockaddr_ll *from, int *recv_len) struct arphdr *arp_hdr = (struct arphdr *)toybuf; unsigned char *p = (unsigned char *)(arp_hdr + 1); - if (arp_hdr->ar_op != htons(ARPOP_REQUEST) && - arp_hdr->ar_op != htons(ARPOP_REPLY)) return; + if (arp_hdr->ar_op != htons(ARPOP_REQUEST) && + arp_hdr->ar_op != htons(ARPOP_REPLY)) return; if (from->sll_pkttype != PACKET_HOST && from->sll_pkttype != PACKET_BROADCAST - && from->sll_pkttype != PACKET_MULTICAST) return; + && from->sll_pkttype != PACKET_MULTICAST) return; - if (arp_hdr->ar_pro != htons(ETH_P_IP) || (arp_hdr->ar_pln != 4) - || (arp_hdr->ar_hln != src_pk.sll_halen) + if (arp_hdr->ar_pro != htons(ETH_P_IP) || (arp_hdr->ar_pln != 4) + || (arp_hdr->ar_hln != src_pk.sll_halen) || (*recv_len < (int)(sizeof(*arp_hdr) + 2 * (4 + arp_hdr->ar_hln)))) - return; + return; memcpy(&s_ip.s_addr, p + arp_hdr->ar_hln, 4); - memcpy(&d_ip.s_addr, p + arp_hdr->ar_hln + 4 + arp_hdr->ar_hln, 4); + memcpy(&d_ip.s_addr, p + arp_hdr->ar_hln + 4 + arp_hdr->ar_hln, 4); if (dest_addr.s_addr != s_ip.s_addr) return; if (toys.optflags & FLAG_D) { @@ -159,7 +159,7 @@ static void recv_from(struct sockaddr_ll *from, int *recv_len) from->sll_pkttype == PACKET_HOST ? "Uni" : "Broad", arp_hdr->ar_op == htons(ARPOP_REPLY) ? "ply" : "quest", inet_ntoa(s_ip), ether_ntoa((struct ether_addr *) p)); - if (TT.sent_at) { + if (TT.sent_at) { unsigned delta; struct timeval tval; @@ -184,14 +184,14 @@ static void send_signal(int sig) struct timeval start; gettimeofday(&start, NULL); - if (!TT.start) + if (!TT.start) TT.end = TT.start = start.tv_sec * 1000 + start.tv_usec / 1000; else TT.end = start.tv_sec*1000 + start.tv_usec / 1000; if (toys.optflags & FLAG_c) { if (!TT.count) done(0); - TT.count--; + TT.count--; } - if ((toys.optflags & FLAG_w) && ((TT.end - TT.start) > + if ((toys.optflags & FLAG_w) && ((TT.end - TT.start) > ((TT.time_out)*1000))) done(0); send_packet(); alarm(1); @@ -227,9 +227,9 @@ void arping_main(void) if (!hp) perror_exit("bad address '%s'", *toys.optargs); memcpy(&dest_addr, hp->h_addr, 4); } - if ((toys.optflags & FLAG_s) && !(inet_aton(TT.src_ip, &src_addr))) + if ((toys.optflags & FLAG_s) && !(inet_aton(TT.src_ip, &src_addr))) perror_exit("invalid source address '%s'",TT.src_ip); - if (!(toys.optflags & FLAG_D) && (toys.optflags & FLAG_U) + if (!(toys.optflags & FLAG_D) && (toys.optflags & FLAG_U) && !src_addr.s_addr) src_addr = dest_addr; if (!(toys.optflags & FLAG_D) || src_addr.s_addr) { struct sockaddr_in saddr; diff --git a/toys/pending/bootchartd.c b/toys/pending/bootchartd.c index 49be5c48..bbb06b42 100644 --- a/toys/pending/bootchartd.c +++ b/toys/pending/bootchartd.c @@ -1,10 +1,10 @@ /* bootchartd.c - bootchartd is commonly used to profile the boot process. * * Copyright 2014 Bilal Qureshi - * Copyright 2014 Kyungwan Han + * Copyright 2014 Kyungwan Han * * No Standard - + USE_BOOTCHARTD(NEWTOY(bootchartd, 0, TOYFLAG_STAYROOT|TOYFLAG_USR|TOYFLAG_BIN)) config BOOTCHARTD @@ -152,7 +152,7 @@ static void start_logging() (int) (ts.tv_nsec/10000000)); dump_data_in_file("/proc/stat", sfd); dump_data_in_file("/proc/diskstats", dfd); - // stop proc dumping in 2 secs if getty or gdm, kdm, xdm found + // stop proc dumping in 2 secs if getty or gdm, kdm, xdm found if (dump_proc_data(proc_ps_fp)) if (tcnt > 2 * 1000 / TT.msec) tcnt = 2 * 1000 / TT.msec; fflush(0); @@ -198,7 +198,7 @@ static void stop_logging(char *tmp_dir, char *prog) close(kcmd_line_fd); fclose(hdr_fp); memset(toybuf, 0, sizeof(toybuf)); - snprintf(toybuf, sizeof(toybuf), "tar -zcf /var/log/bootlog.tgz header %s *.log", + snprintf(toybuf, sizeof(toybuf), "tar -zcf /var/log/bootlog.tgz header %s *.log", TT.proc_accounting ? "kernel_procs_acct" : ""); system(toybuf); @@ -241,7 +241,7 @@ void bootchartd_main() } } else if (TT.pid != 1) error_exit("not PID 1"); - // Execute the code below for start or init or PID1 + // Execute the code below for start or init or PID1 if (!parse_config_file("bootchartd.conf")) parse_config_file("/etc/bootchartd.conf"); @@ -251,23 +251,23 @@ void bootchartd_main() sigatexit(generic_signal); raise(SIGSTOP); - if (!bchartd_opt && !getenv("PATH")) + if (!bchartd_opt && !getenv("PATH")) putenv("PATH=/sbin:/usr/sbin:/bin:/usr/bin"); start_logging(); stop_logging(tmp_dir, bchartd_opt == 1 ? toys.optargs[1] : NULL); return; - } + } waitpid(lgr_pid, NULL, WUNTRACED); kill(lgr_pid, SIGCONT); - if (!bchartd_opt) { + if (!bchartd_opt) { char *pbchart_init = getenv("bootchart_init"); if (pbchart_init) execl(pbchart_init, pbchart_init, NULL); execl("/init", "init", (void *)0); execl("/sbin/init", "init", (void *)0); } - if (bchartd_opt == 1 && toys.optargs[1]) { + if (bchartd_opt == 1 && toys.optargs[1]) { pid_t prog_pid; if (!(prog_pid = xfork())) xexec(toys.optargs+1); diff --git a/toys/pending/brctl.c b/toys/pending/brctl.c index c007618f..1ff13729 100644 --- a/toys/pending/brctl.c +++ b/toys/pending/brctl.c @@ -42,7 +42,7 @@ GLOBALS( static void get_ports(char *bridge, int *indices) { - struct ifreq ifr; + struct ifreq ifr; int ifindices[MAX_BRIDGES]; unsigned long args[4] = { BRCTL_GET_PORT_LIST, (unsigned long) ifindices, MAX_BRIDGES, 0 }; @@ -90,7 +90,7 @@ void br_show(char **argv) get_br_info(br, &info); id = (unsigned char*)&(info.bridge_id); printf("%s\t\t",br); - printf("%.2x%.2x.%.2x%.2x%.2x%.2x%.2x%.2x", id[0], id[1], + printf("%.2x%.2x.%.2x%.2x%.2x%.2x%.2x%.2x", id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]); printf("\t%s\t\t",(info.stp_enabled)?"yes" : "no"); @@ -112,13 +112,13 @@ void br_show(char **argv) void br_addbr(char **argv) { - char br[IFNAMSIZ]; + char br[IFNAMSIZ]; unsigned long args[4] = {BRCTL_ADD_BRIDGE, (unsigned long) br, 0, 0}; #ifdef SIOCBRADDBR xioctl(TT.sockfd, SIOCBRADDBR, argv[0]); -#else - xstrncpy(br, argv[0], IFNAMSIZ); +#else + xstrncpy(br, argv[0], IFNAMSIZ); xioctl(TT.sockfd, SIOCSIFBR, args); #endif } @@ -156,8 +156,8 @@ void br_addif(char **argv) void br_delif(char **argv) { - int index; - struct ifreq ifr; + int index; + struct ifreq ifr; unsigned long args[4] = {BRCTL_DEL_IF, 0, 0, 0}; if (!(index = if_nametoindex(argv[1]))) perror_exit("interface %s",argv[1]); @@ -166,8 +166,8 @@ void br_delif(char **argv) ifr.ifr_ifindex = index; xioctl(TT.sockfd, SIOCBRDELIF, &ifr); #else - args[1] = index; - ifr.ifr_data = (char *)args; + args[1] = index; + ifr.ifr_data = (char *)args; xioctl(TT.sockfd, SIOCDEVPRIVATE, &ifr); #endif } @@ -182,12 +182,12 @@ static void strtotimeval(struct timeval *tv, char *time) } static unsigned long tv_to_jify(struct timeval *tv) -{ +{ unsigned long long jify; jify = 1000000ULL * tv->tv_sec + tv->tv_usec; return (jify/10000); -} +} void set_time(char *br, unsigned long cmd, unsigned long val) { @@ -199,7 +199,7 @@ void set_time(char *br, unsigned long cmd, unsigned long val) xioctl(TT.sockfd, SIOCDEVPRIVATE, &ifr); } -void br_set_ageing_time(char **argv) +void br_set_ageing_time(char **argv) { struct timeval tv; @@ -217,17 +217,17 @@ void br_set_fwd_delay(char **argv) void br_set_hello_time(char **argv) { - struct timeval tv; + struct timeval tv; - strtotimeval(&tv, argv[1]); + strtotimeval(&tv, argv[1]); set_time(argv[0], BRCTL_SET_BRIDGE_HELLO_TIME, tv_to_jify(&tv)); } void br_set_max_age(char **argv) { - struct timeval tv; + struct timeval tv; - strtotimeval(&tv, argv[1]); + strtotimeval(&tv, argv[1]); set_time(argv[0], BRCTL_SET_BRIDGE_MAX_AGE, tv_to_jify(&tv)); } @@ -260,9 +260,9 @@ void set_cost_prio(char *br, char *port, unsigned long cmd, unsigned long val) struct ifreq ifr; int i, index, pindices[MAX_BRIDGES]; unsigned long args[4] = {cmd, 0, val, 0}; - + if (!(index = if_nametoindex(port))) error_exit("invalid port"); - + memset(pindices, 0, sizeof(pindices)); get_ports(br, pindices); for (i = 0; i < MAX_BRIDGES; i++) { @@ -284,7 +284,7 @@ void br_set_path_cost(char **argv) } void br_set_port_prio(char **argv) -{ +{ int prio; prio = atolx_range(argv[2], 0, INT_MAX); diff --git a/toys/pending/crond.c b/toys/pending/crond.c index 81cc8448..ac96061d 100644 --- a/toys/pending/crond.c +++ b/toys/pending/crond.c @@ -570,7 +570,7 @@ static void execute_jobs(void) free(mailfile); } } - loginfo(LOG_LEVEL8, "USER %s pid %3d cmd %s", + loginfo(LOG_LEVEL8, "USER %s pid %3d cmd %s", cfile->username, job->pid, job->cmd); if (job->pid < 0) job->needstart = 1; else job->isrunning = 1; diff --git a/toys/pending/crontab.c b/toys/pending/crontab.c index 6c1c65a2..575398f2 100644 --- a/toys/pending/crontab.c +++ b/toys/pending/crontab.c @@ -349,7 +349,7 @@ void crontab_main(void) if (!toys.optc) { if (!FLAG_elr) { - if (toys.optflags & FLAG_u) + if (toys.optflags & FLAG_u) help_exit("file name must be specified for replace"); do_replace(pwd->pw_name); } diff --git a/toys/pending/dhcp.c b/toys/pending/dhcp.c index dd54ee36..d90f9a2b 100644 --- a/toys/pending/dhcp.c +++ b/toys/pending/dhcp.c @@ -248,7 +248,7 @@ static struct sock_filter filter_instr[] = { }; static struct sock_fprog filter_prog = { - .len = ARRAY_LEN(filter_instr), + .len = ARRAY_LEN(filter_instr), .filter = (struct sock_filter *) filter_instr, }; @@ -465,7 +465,7 @@ static int strtoopt( char *str, uint8_t optonly) valstr = strtok(NULL," \t"); } break; - case DHCP_STRLST: + case DHCP_STRLST: case DHCP_IPPLST: break; case DHCP_STCRTS: @@ -668,7 +668,7 @@ static int read_raw(void) } // ignore any extra garbage bytes bytes = ntohs(packet.iph.tot_len); - // make sure its the right packet for us, and that it passes sanity checks + // make sure its the right packet for us, and that it passes sanity checks if (packet.iph.protocol != IPPROTO_UDP || packet.iph.version != IPVERSION || packet.iph.ihl != (sizeof(packet.iph) >> 2) || packet.udph.dest != htons(DHCPC_CLIENT_PORT) @@ -1199,14 +1199,14 @@ static void renew(void) break; case STATE_BOUND: mode_raw(); - case STATE_RENEWING: // FALLTHROUGH - case STATE_REBINDING: // FALLTHROUGH + case STATE_RENEWING: // FALLTHROUGH + case STATE_REBINDING: // FALLTHROUGH state->status = STATE_RENEW_REQUESTED; break; case STATE_RENEW_REQUESTED: run_script(NULL, "deconfig"); - case STATE_REQUESTING: // FALLTHROUGH - case STATE_RELEASED: // FALLTHROUGH + case STATE_REQUESTING: // FALLTHROUGH + case STATE_RELEASED: // FALLTHROUGH mode_raw(); state->status = STATE_INIT; break; diff --git a/toys/pending/dhcp6.c b/toys/pending/dhcp6.c index 72cda4f8..72affff6 100644 --- a/toys/pending/dhcp6.c +++ b/toys/pending/dhcp6.c @@ -34,7 +34,7 @@ config DHCP6 */ #define FOR_dhcp6 #include "toys.h" -#include +#include #include #include #include @@ -89,11 +89,11 @@ GLOBALS( #define DHCPC_SERVER_PORT 547 #define DHCPC_CLIENT_PORT 546 - + #define LOG_SILENT 0x0 #define LOG_CONSOLE 0x1 #define LOG_SYSTEM 0x2 - + typedef struct __attribute__((packed)) dhcp6_msg_s { uint8_t msgtype, transaction_id[3], options[524]; } dhcp6_msg_t; @@ -138,7 +138,7 @@ static void logit(char *format, ...) char *msg; va_list p, t; uint8_t infomode = LOG_SILENT; - + if (toys.optflags & FLAG_S) infomode |= LOG_SYSTEM; if(toys.optflags & FLAG_v) infomode |= LOG_CONSOLE; va_start(p, format); @@ -161,7 +161,7 @@ static void get_mac(uint8_t *mac, char *interface) { int fd; struct ifreq req; - + if (!mac) return; fd = xsocket(AF_INET6, SOCK_RAW, IPPROTO_RAW); req.ifr_addr.sa_family = AF_INET6; @@ -174,17 +174,17 @@ static void get_mac(uint8_t *mac, char *interface) static void fill_option(uint16_t option_id, uint16_t option_len, uint8_t **dhmesg) { uint8_t *tmp = *dhmesg; - + *((uint16_t*)tmp) = htons(option_id); *(uint16_t*)(tmp+2) = htons(option_len); *dhmesg += 4; TT.length += 4; } -static void fill_clientID() -{ +static void fill_clientID() +{ uint8_t *tmp = &mesg.options[TT.length]; - + if(!duid) { uint8_t mac[7] = {0,}; duid = (DUID*)malloc(sizeof(DUID)); @@ -204,10 +204,10 @@ static void fill_clientID() } // TODO: make it generic for multiple options. -static void fill_optionRequest() +static void fill_optionRequest() { uint8_t *tmp = &mesg.options[TT.length]; - + fill_option(DHCP6_OPT_ORO,4,&tmp); *(uint16_t*)(tmp+4) = htons(23); *(uint16_t*)(tmp+6) = htons(24); @@ -217,17 +217,17 @@ static void fill_optionRequest() static void fill_elapsedTime() { uint8_t *tmp = &mesg.options[TT.length]; - + fill_option(DHCP6_OPT_ELAPSED_TIME, 2, &tmp); *(uint16_t*)(tmp+6) = htons(0); TT.length += 2; } -static void fill_iaid() +static void fill_iaid() { IA_NA iana; uint8_t *tmp = &mesg.options[TT.length]; - + fill_option(DHCP6_OPT_IA_NA, 12, &tmp); iana.iaid = rand(); iana.t1 = 0xffffffff; @@ -241,10 +241,10 @@ static void mode_raw() { int constone = 1; struct sockaddr_ll sockll; - + if (TT.sock > 0) xclose(TT.sock); TT.sock = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6)); - + memset(&sockll, 0, sizeof(sockll)); sockll.sll_family = AF_PACKET; sockll.sll_protocol = htons(ETH_P_IPV6); @@ -255,17 +255,17 @@ static void mode_raw() } } -static void generate_transection_id() +static void generate_transection_id() { int i, r = rand() % 0xffffff; - + for (i=0; i<3; i++) { TT.transction_id[i] = r%0xff; r = r/10; - } + } } -static void set_timeout(int seconds) +static void set_timeout(int seconds) { TT.tv.tv_sec = seconds; TT.tv.tv_usec = 100000; @@ -275,7 +275,7 @@ static void send_msg(int type) { struct sockaddr_in6 addr6; int sendlength = 0; - + memset(&addr6, 0, sizeof(addr6)); addr6.sin6_family = AF_INET6; addr6.sin6_port = htons(DHCPC_SERVER_PORT); //SERVER_PORT @@ -283,7 +283,7 @@ static void send_msg(int type) mesg.msgtype = type; generate_transection_id(); memcpy(mesg.transaction_id, TT.transction_id, 3); - + if (type == DHCP6SOLICIT) { TT.length = 0; fill_clientID(); @@ -291,7 +291,7 @@ static void send_msg(int type) fill_elapsedTime(); fill_iaid(); sendlength = sizeof(dhcp6_msg_t) - 524 + TT.length; - } else if (type == DHCP6REQUEST || type == DHCP6RELEASE || type == DHCP6RENEW) + } else if (type == DHCP6REQUEST || type == DHCP6RELEASE || type == DHCP6RENEW) sendlength = TT.request_length; dbg("Sending message type: %d\n", type); sendlength = sendto(TT.sock1, &mesg, sendlength , 0,(struct sockaddr *)&addr6, @@ -302,7 +302,7 @@ static void send_msg(int type) uint8_t *get_msg_ptr(uint8_t *data, int data_length, int msgtype) { uint16_t type = *((uint16_t*)data), length = *((uint16_t*)(data+2)); - + type = ntohs(type); if (type == msgtype) return data; length = ntohs(length); @@ -327,20 +327,20 @@ static int check_client_id(uint8_t *data, int data_length) if ((data = get_msg_ptr(data, data_length, DHCP6_OPT_CLIENTID))) { DUID one = *((DUID*)(data+4)); DUID two = *((DUID*)&mesg.options[4]); - + if (!memcmp(&one, &two, sizeof(DUID))) return 1; } return 0; } -static int validate_ids() +static int validate_ids() { - if (!check_server_id(mymsg->dhcp6.options, + if (!check_server_id(mymsg->dhcp6.options, TT.status - ((char*)&mymsg->dhcp6.options[0] - (char*)mymsg) )) { dbg("Invalid server id: %d\n"); return 0; } - if (!check_client_id(mymsg->dhcp6.options, + if (!check_client_id(mymsg->dhcp6.options, TT.status - ((char*)&mymsg->dhcp6.options[0] - (char*)mymsg) )) { dbg("Invalid client id: %d\n"); return 0; @@ -348,24 +348,24 @@ static int validate_ids() return 1; } -static void parse_ia_na(uint8_t *data, int data_length) +static void parse_ia_na(uint8_t *data, int data_length) { uint8_t *t = get_msg_ptr(data, data_length, DHCP6_OPT_IA_NA); uint16_t iana_len, content_len = 0; - + memset(&dhcp_data,0,sizeof(dhcp_data)); if (!t) return; - + iana_len = ntohs(*((uint16_t*)(t+2))); dhcp_data.iaid = ntohl(*((uint32_t*)(t+4))); dhcp_data.t1 = ntohl(*((uint32_t*)(t+8))); dhcp_data.t2 = ntohl(*((uint32_t*)(t+12))); t += 16; iana_len -= 12; - + while(iana_len > 0) { uint16_t sub_type = ntohs(*((uint16_t*)(t))); - + switch (sub_type) { case DHCP6_OPT_IA_ADDR: content_len = ntohs(*((uint16_t*)(t+2))); @@ -373,7 +373,7 @@ static void parse_ia_na(uint8_t *data, int data_length) if (TT.state == DHCP6SOLICIT) { if (TT.req_ip) { struct addrinfo *res = NULL; - + if(!getaddrinfo(TT.req_ip, NULL, NULL,&res)) { dbg("Requesting IP: %s\n", TT.req_ip); memcpy (&TT.input_socket6, res->ai_addr, res->ai_addrlen); @@ -405,7 +405,7 @@ static void parse_ia_na(uint8_t *data, int data_length) static void write_pid(char *path) { int pidfile = open(path, O_CREAT | O_WRONLY | O_TRUNC, 0666); - + if (pidfile > 0) { char pidbuf[12]; @@ -419,7 +419,7 @@ static void write_pid(char *path) static int fill_envp(DHCP_DATA *res) { int ret = setenv("interface", TT.interface_name, 1); - + if (ret) return ret; inet_ntop(AF_INET6, res->ipaddr, toybuf, INET6_ADDRSTRLEN); ret = setenv("ip",(const char*)toybuf , 1); @@ -432,7 +432,7 @@ static void run_script(DHCP_DATA *res, char *name) volatile int error = 0; struct stat sts; pid_t pid; - char *argv[3]; + char *argv[3]; char *script = (toys.optflags & FLAG_s) ? TT.script : "/usr/share/dhcp/default.script"; @@ -537,12 +537,12 @@ void dhcp6_main(void) struct sockaddr_in6 sinaddr6; int constone = 1; fd_set rfds; - - srand(time(NULL)); + + srand(time(NULL)); setlinebuf(stdout); dbg = dummy; TT.state = DHCP6SOLICIT; - + if (toys.optflags & FLAG_v) dbg = logit; if (!TT.interface_name) TT.interface_name = "eth0"; if (toys.optflags & FLAG_p) write_pid(TT.pidfile); @@ -553,34 +553,34 @@ void dhcp6_main(void) openlog("DHCP6 :", LOG_PID, LOG_DAEMON); dbg = logit; } - + dbg("Interface: %s\n", TT.interface_name); dbg("pid file: %s\n", TT.pidfile); dbg("Retry count: %d\n", TT.retry); dbg("Timeout : %d\n", TT.timeout); dbg("Error timeout: %d\n", TT.errortimeout); - - - + + + setup_signal(); - TT.sock1 = xsocket(PF_INET6, SOCK_DGRAM, 0); + TT.sock1 = xsocket(PF_INET6, SOCK_DGRAM, 0); memset(&sinaddr6, 0, sizeof(sinaddr6)); sinaddr6.sin6_family = AF_INET6; sinaddr6.sin6_port = htons(DHCPC_CLIENT_PORT); sinaddr6.sin6_scope_id = if_nametoindex(TT.interface_name); sinaddr6.sin6_addr = in6addr_any ; - + xsetsockopt(TT.sock1, SOL_SOCKET, SO_REUSEADDR, &constone, sizeof(constone)); - + xbind(TT.sock1, (struct sockaddr *)&sinaddr6, sizeof(sinaddr6)); - + mode_raw(); set_timeout(0); for (;;) { int maxfd = TT.sock; - + if (TT.sock >= 0) FD_SET(TT.sock, &rfds); - TT.retval = 0; + TT.retval = 0; if ((TT.retval = select(maxfd + 1, &rfds, NULL, NULL, &TT.tv)) < 0) { if(errno == EINTR) continue; perror_exit("Error in select"); @@ -599,7 +599,7 @@ void dhcp6_main(void) set_timeout(TT.errortimeout); } else set_timeout(TT.timeout); continue; - } else if (TT.state == DHCP6REQUEST || TT.state == DHCP6RENEW || + } else if (TT.state == DHCP6REQUEST || TT.state == DHCP6RENEW || TT.state == DHCP6RELEASE) { dbg("State is %d , sending packet\n", TT.state); send_msg(TT.state); @@ -614,7 +614,7 @@ void dhcp6_main(void) } else if (FD_ISSET(TT.sock, &rfds)) { if ((TT.status = read(TT.sock, toybuf, sizeof(toybuf))) <= 0) continue; mymsg = (dhcp6_raw_t*)toybuf; - if (ntohs(mymsg->udph.dest) == 546 && + if (ntohs(mymsg->udph.dest) == 546 && !memcmp(mymsg->dhcp6.transaction_id, TT.transction_id, 3)) { if (TT.state == DHCP6SOLICIT) { if (mymsg->dhcp6.msgtype == DHCP6ADVERTISE ) { @@ -672,7 +672,7 @@ void dhcp6_main(void) } else { dbg("Invalid reply.\n"); continue; - } + } } else if (TT.state == DHCP6RELEASE) { dbg("Got reply to release.\n"); run_script(NULL, "release"); @@ -680,7 +680,7 @@ void dhcp6_main(void) } } } - } + } xclose(TT.sock1); xclose(TT.sock); } diff --git a/toys/pending/dhcpd.c b/toys/pending/dhcpd.c index f6d063d6..5b5c63ef 100644 --- a/toys/pending/dhcpd.c +++ b/toys/pending/dhcpd.c @@ -36,7 +36,7 @@ config DEBUG_DHCP #define FOR_dhcpd #include "toys.h" -#include +#include #include // Todo: headers not in posix @@ -1292,7 +1292,7 @@ static int verifyip6_in_lease(uint8_t *nip6, uint8_t *duid, uint16_t ia_type, ui return -1; if (!memcmp(((dyn_lease6*) listdls->arg)->duid, duid, ((dyn_lease6*) listdls->arg)->duid_len) - && ((dyn_lease6*) listdls->arg)->ia_type == ia_type) + && ((dyn_lease6*) listdls->arg)->ia_type == ia_type) return -1; } for (sls6 = gstate.leases.sleases6; sls6; sls6 = sls6->next) @@ -1376,12 +1376,12 @@ static int addip6_to_lease(uint8_t *assigned_nip, uint8_t *duid, uint16_t duid_l } dls6 = xzalloc(sizeof(dyn_lease6)); - dls6->duid_len = duid_len; + dls6->duid_len = duid_len; memcpy(dls6->duid, duid, duid_len); dls6->ia_type = ia_type; dls6->iaid = iaid; memcpy(dls6->lease_nip6, assigned_nip, sizeof(uint32_t)*4); - + if (update) *lifetime = get_lease(*lifetime + now); dls6->expires = *lifetime + now; @@ -1667,7 +1667,7 @@ void dhcpd_main(void) dbg("Error in select wait again...\n"); continue; } - if (!retval) { // Timed out + if (!retval) { // Timed out dbg("select wait Timed Out...\n"); waited = 0; (addr_version == AF_INET6)? write_lease6file() : write_leasefile(); @@ -1680,7 +1680,7 @@ void dhcpd_main(void) } continue; } - if (FD_ISSET(sigfd.rd, &rfds)) { // Some Activity on RDFDs : is signal + if (FD_ISSET(sigfd.rd, &rfds)) { // Some Activity on RDFDs : is signal unsigned char sig; if (read(sigfd.rd, &sig, 1) != 1) { dbg("signal read failed.\n"); @@ -1951,7 +1951,7 @@ void dhcpd_main(void) dbg("Message Type : %u\n", gstate.rqcode); break; } - + } else { if(read_packet() < 0) { open_listensock(); @@ -1961,7 +1961,7 @@ void dhcpd_main(void) get_optval((uint8_t*)&gstate.rcvd.rcvd_pkt.options, DHCP_OPT_MESSAGE_TYPE, &gstate.rqcode); - if (gstate.rqcode == 0 || gstate.rqcode < DHCPDISCOVER + if (gstate.rqcode == 0 || gstate.rqcode < DHCPDISCOVER || gstate.rqcode > DHCPINFORM) { dbg("no or bad message type option, ignoring packet.\n"); continue; diff --git a/toys/pending/diff.c b/toys/pending/diff.c index f12b4a3c..5d5ea3d6 100644 --- a/toys/pending/diff.c +++ b/toys/pending/diff.c @@ -586,7 +586,7 @@ static void do_diff(char **files) struct arg_list *llist = TT.L; int *J; regex_t reg; - + TT.offset[0] = TT.offset[1] = NULL; J = diff(files); diff --git a/toys/pending/dumpleases.c b/toys/pending/dumpleases.c index ef17aab4..a20c6b8d 100644 --- a/toys/pending/dumpleases.c +++ b/toys/pending/dumpleases.c @@ -26,7 +26,7 @@ GLOBALS( ) //lease structure -struct lease { +struct lease { uint32_t expires; uint32_t lease_nip; uint8_t lease_mac[6]; @@ -39,8 +39,8 @@ void dumpleases_main(void) struct in_addr addr; struct lease lease_struct; int64_t written_time , current_time, exp; - int i, fd; - + int i, fd; + if(!(toys.optflags & FLAG_f)) TT.file = "/var/lib/misc/dhcpd.leases"; //DEF_LEASE_FILE fd = xopenro(TT.file); xprintf("Mac Address IP Address Host Name Expires %s\n", (toys.optflags & FLAG_a) ? "at" : "in"); @@ -49,10 +49,10 @@ void dumpleases_main(void) written_time = SWAP_BE64(written_time); if(current_time < written_time) written_time = current_time; - while(sizeof(lease_struct) == + while(sizeof(lease_struct) == (readall(fd, &lease_struct, sizeof(lease_struct)))) { for (i = 0; i < 6; i++) printf(":%02x"+ !i, lease_struct.lease_mac[i]); - + addr.s_addr = lease_struct.lease_nip; lease_struct.hostname[19] = '\0'; xprintf(" %-16s%-20s", inet_ntoa(addr), lease_struct.hostname ); @@ -61,7 +61,7 @@ void dumpleases_main(void) xputs("expired"); continue; } - if (!(toys.optflags & FLAG_a)) { + if (!(toys.optflags & FLAG_a)) { unsigned dt, hr, m; unsigned expires = exp - current_time; dt = expires / (24*60*60); expires %= (24*60*60); diff --git a/toys/pending/expr.c b/toys/pending/expr.c index 54ebd14b..e56a75b7 100644 --- a/toys/pending/expr.c +++ b/toys/pending/expr.c @@ -135,7 +135,7 @@ static struct op_def { // comparison ops, precedence 3, signature SI_TO_I {"=", 3, SI_TO_I, EQ }, {"==", 3, SI_TO_I, EQ }, {"!=", 3, SI_TO_I, NE }, {">", 3, SI_TO_I, GT }, {">=", 3, SI_TO_I, GTE }, - {"<", 3, SI_TO_I, LT }, {"<=", 3, SI_TO_I, LTE }, + {"<", 3, SI_TO_I, LT }, {"<=", 3, SI_TO_I, LTE }, // arithmetic ops, precedence 4 and 5, signature I_TO_I {"+", 4, I_TO_I, ADD }, {"-", 4, I_TO_I, SUB }, {"*", 5, I_TO_I, MUL }, {"/", 5, I_TO_I, DIVI }, {"%", 5, I_TO_I, MOD }, @@ -156,7 +156,7 @@ void eval_op(struct op_def *o, struct value *ret, struct value *rhs) case OR: if (is_false(ret)) *ret = *rhs; break; case AND: if (is_false(ret) || is_false(rhs)) assign_int(ret, 0); break; } - break; + break; case SI_TO_I: if (get_int(ret, &a) && get_int(rhs, &b)) { // both are ints diff --git a/toys/pending/fdisk.c b/toys/pending/fdisk.c index c29a49ee..fd8db258 100644 --- a/toys/pending/fdisk.c +++ b/toys/pending/fdisk.c @@ -34,7 +34,7 @@ GLOBALS( long cylinders; ) -#define EXTENDED 0x05 +#define EXTENDED 0x05 #define WIN98_EXTENDED 0x0f #define LINUX_NATIVE 0x83 #define LINUX_EXTENDED 0x85 @@ -136,7 +136,7 @@ static int chs_warn(void) static void list_types(void) { int i, adjust = 0, size = ARRAY_LEN(sys_types); - + if(size % 2) adjust = 1; for (i = 0; i < (size - adjust); i+=2) xprintf("%2x %-22s\t\t%2x %-22.22s\n", sys_types[i].id, sys_types[i].type, @@ -147,7 +147,7 @@ static void list_types(void) static void read_sec_sz() { - int arg; + int arg; if (ioctl(dev_fd, BLKSSZGET, &arg) == 0) g_sect_size = arg; if (FLAG(b)) { if (TT.sect_sz != 512 && TT.sect_sz != 1024 && TT.sect_sz != 2048 && @@ -200,17 +200,17 @@ static uint32_t swap_le32toh(unsigned char *cp) return le32toh(val); } -static int check_order(void) -{ +static int check_order(void) +{ sector_t first[num_parts], last_seen_val = 0; int i; - struct part_entry *pe; + struct part_entry *pe; struct partition *px; for (i = 0; i < num_parts; i++) { if (i == 4) last_seen_val = 0; - pe = &partitions[i]; - px = pe->part; + pe = &partitions[i]; + px = pe->part; if (px->sys_ind) { first[i] = swap_le32toh(px->start4) + pe->start_offset; if (last_seen_val > first[i]) return 1; @@ -229,7 +229,7 @@ static void read_geometry(struct hd_geometry *disk) disk->sectors = geometry.sectors; } -/* Read the extended boot record for the +/* Read the extended boot record for the * logical partion details. */ static void read_ebr(int idx) @@ -269,7 +269,7 @@ static void read_ebr(int idx) } static void physical_HS(int* h, int *s) -{ +{ struct partition *p; int i, end_h, end_s, e_hh = 0, e_ss = 0, ini = 1, dirty = 0; const unsigned char *bufp = (const unsigned char *)MBRbuf; @@ -336,7 +336,7 @@ static void create_empty_doslabel(void) reset_boot(1); } -/* Read the Master Boot sector of the device for the +/* Read the Master Boot sector of the device for the * partition table entries/details. * If any extended partition is found then read the EBR * for logical partition details @@ -405,21 +405,21 @@ static char* get_type(int sys_ind) } static void consistency_check(const struct partition *p, int partition) -{ +{ unsigned physbc, physbh, physbs, physec, physeh, physes; unsigned lbc, lbh, lbs, lec, leh, les; sector_t start, end; if (!g_heads || !g_sectors || (partition >= 4)) return; - // physical beginning c, h, s + // physical beginning c, h, s physbc = cylinder(p->sector,p->cyl); physbh = p->head; physbs = sector(p->sector); - // physical ending c, h, s + // physical ending c, h, s physec = cylinder(p->end_sector, p->end_cyl); physeh = p->end_head; physes = sector(p->end_sector); - // logical begin and end CHS values + // logical begin and end CHS values start = swap_le32toh((unsigned char*)(p->start4)); end = start + swap_le32toh((unsigned char*)(p->size4)) -1; @@ -431,7 +431,7 @@ static void consistency_check(const struct partition *p, int partition) leh = (end/g_sectors) % g_heads; les = (end % g_sectors) + 1; - //Logical and Physical diff + //Logical and Physical diff if (g_cylinders <= ONE_K && (physbc != lbc || physbh != lbh || physbs != lbs)) { xprintf("Partition %u has different physical/logical beginnings (Non-Linux?): \n", partition+1); xprintf("phys = (%u %u %u) ",physbc, physbh, physbs); @@ -442,7 +442,7 @@ static void consistency_check(const struct partition *p, int partition) xprintf("phys = (%u %u %u) ",physec, physeh, physes); xprintf("logical = (%u %u %u)\n", lec, leh, les); } - // Ending on cylinder boundary? + // Ending on cylinder boundary? if (physeh != (g_heads - 1) || physes != g_sectors) xprintf("Partition %u does not end on cylinder boundary\n", partition + 1); } @@ -536,7 +536,7 @@ static int read_input(char *mesg, char *outp) do { xprintf("%s", mesg); p = fgets(toybuf, 80, stdin); - + if (!p || !(size = strlen(p))) exit(0); if (p[size-1] == '\n') p[--size] = '\0'; } while (!size); @@ -574,7 +574,7 @@ void delete_partition(int i) struct partition *p, *q, *ext_p, *ext_q; sector_t new_start; struct part_entry *pe = &partitions[i]; - + if (chs_warn()) return; p = pe->part; sys_id = p->sys_ind; @@ -588,7 +588,7 @@ void delete_partition(int i) pe->modified = 1; for (looper = 4; looper < num_parts; looper++) { pe = &partitions[looper]; - p = pe->part; + p = pe->part; if (is_partition_clear(p)) break; else { memset(p, 0, sizeof(struct partition)); //clear_partition @@ -608,7 +608,7 @@ void delete_partition(int i) ext_p = part_offset(partitions[i].sec_buffer, 1); ext_q = part_offset(partitions[i + 1].sec_buffer, 1); *ext_p = *ext_q; //copy the extended info pointer - // change the start of the 4th partiton. + // change the start of the 4th partiton. new_start = partitions[i + 1].start_offset + swap_le32toh(q->start4) - extended_offset; new_start = SWAP_LE32(new_start); memcpy(p->start4, (void *)&new_start, 4); @@ -648,7 +648,7 @@ static void toggle_active_flag(int i) { struct partition *p = partitions[i].part; if (is_partition_clear(p)) xprintf("Partition %u is empty\n", i+1); - + if (IS_EXTENDED(p->sys_ind) && !p->boot_ind) xprintf("WARNING: Partition %u is an extended partition\n", i + 1); p->boot_ind = p->boot_ind == 0x80?0 : 0x80; @@ -687,7 +687,7 @@ void write_table(void) * one, then select the same, else ask from USER */ static int get_non_free_partition(int max) -{ +{ int num = -1, i = 0; for (i = 0; i < max; i++) { @@ -723,7 +723,7 @@ static int get_free_partition(int max) //taking user input for partition start/end sectors/cyinders static uint32_t ask_value(char *mesg, sector_t left, sector_t right, sector_t defalt) -{ +{ char *str = toybuf; uint32_t val; int use_default = 1; @@ -820,7 +820,7 @@ static sector_t ask_start_sector(int idx, sector_t* begin, sector_t* end, int ex if (disp_unit_cyl) limit = (sector_t)g_sectors * g_heads * g_cylinders - 1; else limit = total_number_sectors - 1; - if (disp_unit_cyl) //make the begin of every partition to cylnder boundary + if (disp_unit_cyl) //make the begin of every partition to cylnder boundary for (i = 0; i < num_parts; i++) begin[i] = (begin[i]/(g_heads* g_sectors)) * (g_heads* g_sectors); @@ -835,7 +835,7 @@ static sector_t ask_start_sector(int idx, sector_t* begin, sector_t* end, int ex if (valid) break; do { - for (i = start_index; i < num_parts; i++) + for (i = start_index; i < num_parts; i++) if (start >= begin[i] && start <= end[i]) start = end[i] + 1 + ((idx >= 4)? offset : 0); } while (!validate(start_index, begin, end, start, 0)); @@ -845,10 +845,10 @@ static sector_t ask_start_sector(int idx, sector_t* begin, sector_t* end, int ex if (start > limit) break; sprintf(mesg, "First %s (%lld - %lld, default %lld): ", disp_unit_cyl? "cylinder" : "sector", - (long long int)(disp_unit_cyl? start_cyl : start), + (long long int)(disp_unit_cyl? start_cyl : start), (long long int)(disp_unit_cyl? limit_cyl : limit), (long long int)(disp_unit_cyl? start_cyl : start)); - temp = ask_value(mesg, disp_unit_cyl? start_cyl : start, + temp = ask_value(mesg, disp_unit_cyl? start_cyl : start, disp_unit_cyl? limit_cyl : limit, disp_unit_cyl? start_cyl : start); asked = 1; @@ -893,10 +893,10 @@ static sector_t ask_end_sector(int idx, sector_t* begin, sector_t* end, int ext_ } sprintf(mesg, "Last %s or +size or +sizeM or +sizeK (%lld - %lld, default %lld): ", disp_unit_cyl? "cylinder" : "sector", - (long long int)(disp_unit_cyl? start_cyl : start), + (long long int)(disp_unit_cyl? start_cyl : start), (long long int)(disp_unit_cyl? limit_cyl : limit), (long long int)(disp_unit_cyl? limit_cyl : limit)); - temp = ask_value(mesg, disp_unit_cyl? start_cyl : start, + temp = ask_value(mesg, disp_unit_cyl? start_cyl : start, disp_unit_cyl? limit_cyl : limit, disp_unit_cyl? limit_cyl : limit); if (disp_unit_cyl) { // point to the cylinder start sector @@ -947,7 +947,7 @@ static int add_partition(int idx, int sys_id) if (pe->start_offset == extended_offset) pe->start_offset++; if (!dos_flag) start++; } - + set_levalue(p->start4, start - pe->start_offset); set_levalue(p->size4, end - start + 1); set_hsc(p, start, end); @@ -960,13 +960,13 @@ static int add_partition(int idx, int sys_id) set_levalue(p->start4, pe->start_offset - extended_offset); set_levalue(p->size4, end - start + 1 + (dos_flag? g_sectors: 1)); set_hsc(p, pe->start_offset, end); - p->boot_ind = 0; + p->boot_ind = 0; p->sys_ind = EXTENDED; - partitions[idx-1].modified = 1; + partitions[idx-1].modified = 1; } if (IS_EXTENDED(sys_id)) { pe = &partitions[4]; - pe->modified = 1; + pe->modified = 1; pe->sec_buffer = xzalloc(g_sect_size); pe->part = part_offset(pe->sec_buffer, 0); pe->start_offset = extended_offset = start; @@ -989,7 +989,7 @@ static void add_logical_partition(void) num_parts--; free(pe->sec_buffer); } - } + } else add_partition(num_parts -1, LINUX_NATIVE); } @@ -1000,13 +1000,13 @@ static void add_new_partition(void) { int choice, idx, i, free_part = 0; char *msg = NULL; - + if (chs_warn()) return; for (i = 0; i < 4; i++) if(is_partition_clear(partitions[i].part)) free_part++; if (!free_part && num_parts >= 60) { xprintf("The maximum number of partitions has been created\n"); - return; + return; } if (!free_part) { if (extended_offset) add_logical_partition(); @@ -1030,7 +1030,7 @@ static void add_new_partition(void) return; } if (choice == 'e' && !extended_offset) { - idx = get_free_partition(4); + idx = get_free_partition(4); if (idx >= 0) add_partition(idx, EXTENDED); return; } @@ -1062,7 +1062,7 @@ static void change_systype(void ) } static void check(int n, unsigned h, unsigned s, unsigned c, sector_t start) -{ +{ sector_t total, real_s, real_c; real_s = sector(s) - 1; @@ -1116,7 +1116,7 @@ static void verify_table(void) } } } - } + } if (extended_offset) { struct part_entry *pex = &partitions[ext_idx]; sector_t e_last = swap_le32toh(pex->part->start4) + @@ -1187,7 +1187,7 @@ static void print_raw_sectors() static void print_partitions_list(int ext) { - int i; + int i; struct part_entry *pe; struct partition *p; @@ -1204,7 +1204,7 @@ static void print_partitions_list(int ext) xprintf("%2u %02x%4u%4u%5u%4u%4u%5u%11u%11u %02x\n", i+1, p->boot_ind, p->head, sector(p->sector), cylinder(p->sector, p->cyl), - p->end_head, + p->end_head, sector(p->end_sector), cylinder(p->end_sector, p->end_cyl), swap_le32toh(p->start4), swap_le32toh(p->size4), @@ -1228,7 +1228,7 @@ static void fix_order(void) if (is_partition_clear(px)) first[i] = 0xffffffff; else first[i] = swap_le32toh(px->start4) + pe->start_offset; } - + if (!check_order()) { xprintf("Ordering is already correct\n\n"); return; @@ -1278,10 +1278,10 @@ static void fix_order(void) *pjj = tmp; set_levalue(pj->start4, ojj+sjj-oj); set_levalue(pjj->start4, oj+sj-ojj); - } - } + } + } } - // If anything changed + // If anything changed for (j = 4; j < num_parts; j++) partitions[j].modified = 1; xprintf("Done!\n"); } @@ -1311,7 +1311,7 @@ static void print_xmenu(void) "c\tchange number of cylinders\n" "d\tprint the raw data in the partition table\n" "e\tlist extended partitions\n" - "f\tfix partition order\n" + "f\tfix partition order\n" "h\tchange number of heads\n" "p\tprint the partition table\n" "q\tquit without saving changes\n" @@ -1450,7 +1450,7 @@ static void read_and_print_parts() memset(name, 0, sizeof(*name)); if (sscanf(buffer, " %u %u %u %[^\n ]", &ma, &mi, &sz, name) != 4) continue; - + sprintf(device,"/dev/%s",name); if (disk_proper(device)) { if (read_mbr(device, 0)) continue; diff --git a/toys/pending/fsck.c b/toys/pending/fsck.c index ea7c59cd..e93409ea 100644 --- a/toys/pending/fsck.c +++ b/toys/pending/fsck.c @@ -61,11 +61,11 @@ struct child_list { static struct f_sys_info *filesys_info = NULL; //fstab entry list static struct child_list *c_list = NULL; //fsck.type child list. -static void kill_all(void) +static void kill_all(void) { struct child_list *child; - for (child = c_list; child; child = child->next) + for (child = c_list; child; child = child->next) kill(child->pid, SIGTERM); _exit(0); } @@ -107,7 +107,7 @@ static int is_no_prefix(char **p) { int no = 0; - if ((*p[0] == 'n' && *(*p + 1) == 'o')) no = 2; + if ((*p[0] == 'n' && *(*p + 1) == 'o')) no = 2; else if (*p[0] == '!') no = 1; *p += no; return ((no) ? 1 :0); @@ -161,7 +161,7 @@ static int ignore_type(char *type) } // return true if has to ignore the filesystem. -static int to_be_ignored(struct f_sys_info *finfo) +static int to_be_ignored(struct f_sys_info *finfo) { int i, ret = 0, type_present = 0; @@ -185,7 +185,7 @@ static int to_be_ignored(struct f_sys_info *finfo) } // find type and execute corresponding fsck.type prog. -static void do_fsck(struct f_sys_info *finfo) +static void do_fsck(struct f_sys_info *finfo) { struct child_list *child; char **args; @@ -201,7 +201,7 @@ static void do_fsck(struct f_sys_info *finfo) args = xzalloc((toys.optc + 2 + 1 + 1) * sizeof(char*)); //+1, for NULL, +1 if -C args[0] = xmprintf("fsck.%s", type); - + if(toys.optflags & FLAG_C) args[i++] = xmprintf("%s %d","-C", TT.fd_num); while(toys.optargs[j]) { if(*toys.optargs[j]) args[i++] = xstrdup(toys.optargs[j]); @@ -221,15 +221,15 @@ static void do_fsck(struct f_sys_info *finfo) for (j=0;jdev_name = xstrdup(finfo->device); @@ -275,18 +275,18 @@ static int wait_for(int for_all) } if (child_exited) { if (WIFEXITED(status)) TT.sum_status |= WEXITSTATUS(status); - else if (WIFSIGNALED(status)) { + else if (WIFSIGNALED(status)) { TT.sum_status |= 4; //Uncorrected. if (WTERMSIG(status) != SIGINT) perror_msg("child Term. by sig: %d\n",(WTERMSIG(status))); TT.sum_status |= 8; //Operatinal error - } else { + } else { TT.sum_status |= 4; //Uncorrected. - perror_msg("%s %s: status is %x, should never happen\n", + perror_msg("%s %s: status is %x, should never happen\n", temp->prog_name, temp->dev_name, status); } TT.nr_run--; - if (prev == temp) c_list = c_list->next; //first node + if (prev == temp) c_list = c_list->next; //first node else prev->next = temp->next; free(temp->prog_name); free(temp->dev_name); @@ -334,7 +334,7 @@ static int scan_all(void) } passno = 1; while (1) { - for (finfo = filesys_info; finfo; finfo = finfo->next) + for (finfo = filesys_info; finfo; finfo = finfo->next) if (!finfo->flag) break; if (!finfo) break; @@ -343,7 +343,7 @@ static int scan_all(void) if (finfo->passno == passno) { do_fsck(finfo); finfo->flag |= FLAG_DONE; - if ((toys.optflags & FLAG_s) || (TT.nr_run + if ((toys.optflags & FLAG_s) || (TT.nr_run && (TT.nr_run >= TT.max_nr_run))) ret |= wait_for(0); } } @@ -354,7 +354,7 @@ static int scan_all(void) return ret; } -void record_sig_num(int sig) +void record_sig_num(int sig) { TT.sig_num = sig; } @@ -395,7 +395,7 @@ void fsck_main(void) dev->prev->next = NULL; //break double list to traverse. for (; dev; dev = dev->next) { for (finfo = filesys_info; finfo; finfo = finfo->next) - if (!strcmp(finfo->device, dev->data) + if (!strcmp(finfo->device, dev->data) || !strcmp(finfo->mountpt, dev->data)) break; if (!finfo) { //if not present, fill def values. mt.mnt_fsname = dev->data; @@ -407,7 +407,7 @@ void fsck_main(void) } do_fsck(finfo); finfo->flag |= FLAG_DONE; - if ((toys.optflags & FLAG_s) || (TT.nr_run && (TT.nr_run >= TT.max_nr_run))) + if ((toys.optflags & FLAG_s) || (TT.nr_run && (TT.nr_run >= TT.max_nr_run))) toys.exitval |= wait_for(0); } if (TT.sig_num) kill_all(); diff --git a/toys/pending/git.c b/toys/pending/git.c index 4ea8a4ac..ffe72f02 100644 --- a/toys/pending/git.c +++ b/toys/pending/git.c @@ -220,7 +220,7 @@ int inf(FILE *source, char *dest) //modified signature to ease use } have = CHUNK - strm.avail_out; - memcpy(position, out, have); //added to original + memcpy(position, out, have); //added to original position += have; //added to original //if (fwrite(out, 1, have, dest) != have || ferror(dest)) { // (void)inflateEnd(&strm); diff --git a/toys/pending/groupadd.c b/toys/pending/groupadd.c index efb3f941..67c0e929 100644 --- a/toys/pending/groupadd.c +++ b/toys/pending/groupadd.c @@ -15,7 +15,7 @@ config GROUPADD usage: groupadd [-S] [-g GID] [USER] GROUP Add a user to a group, or create a new group. - + -g GID Group id -R Operate within chroot -S Create a system group diff --git a/toys/pending/init.c b/toys/pending/init.c index 9f4e7ba6..84077b4b 100644 --- a/toys/pending/init.c +++ b/toys/pending/init.c @@ -69,7 +69,7 @@ static void initialize_console(void) static void reset_term(int fd) { struct termios terminal; - + tcgetattr(fd, &terminal); terminal.c_cc[VINTR] = 3; //ctrl-c terminal.c_cc[VQUIT] = 28; /*ctrl-\*/ @@ -255,7 +255,7 @@ static pid_t final_run(struct action_list_seed *x) sigfillset(&signal_set); sigprocmask(SIG_UNBLOCK, &signal_set, NULL); - return pid; + return pid; } else if (pid < 0) { perror_msg("fork fail"); sleep(1); @@ -358,7 +358,7 @@ static void halt_poweroff_reboot_handler(int sig_no) error_msg("Requesting system poweroff"); reboot_magic_no=RB_POWER_OFF; break; - case SIGTERM: + case SIGTERM: error_msg("Requesting system reboot"); reboot_magic_no=RB_AUTOBOOT; break; @@ -461,8 +461,8 @@ void init_main(void) { struct sigaction sig_act; - if (getpid() != 1) error_exit("Already running"); - printf("Started init\n"); + if (getpid() != 1) error_exit("Already running"); + printf("Started init\n"); initialize_console(); reset_term(0); @@ -486,8 +486,8 @@ void init_main(void) sigaction(SIGTSTP, &sig_act, NULL); memset(&sig_act, 0, sizeof(sig_act)); sig_act.sa_handler = catch_signal; - sigaction(SIGINT, &sig_act, NULL); - sigaction(SIGHUP, &sig_act, NULL); + sigaction(SIGINT, &sig_act, NULL); + sigaction(SIGHUP, &sig_act, NULL); run_action_from_list(SYSINIT); check_if_pending_signals(); run_action_from_list(WAIT); diff --git a/toys/pending/ip.c b/toys/pending/ip.c index e9b5dd0e..52deec4e 100644 --- a/toys/pending/ip.c +++ b/toys/pending/ip.c @@ -52,7 +52,7 @@ struct arglist { int idx; }; -static struct +static struct { int ifindex, scope, scopemask, up, to; char *label, *addr; @@ -290,7 +290,7 @@ static struct arglist **getlist(u_int8_t whichDB) parseRPDB("/etc/iproute2/rt_tables", alist, ARRAY_LEN(rt_tables)); } break; - default: + default: error_exit("wrong database"); break; // Unreachable code. } @@ -370,7 +370,7 @@ static int get_prefix(uint32_t *addr, uint8_t *af, char *name, int family) if (strchr(name, ':')) { *af = AF_INET6; if (family != AF_UNSPEC && family != AF_INET6) return 1; - if (inet_pton(AF_INET6, name, (void *)addr) != 1) + if (inet_pton(AF_INET6, name, (void *)addr) != 1) return 1; } else { // for IPv4. char *ptr = name; @@ -508,8 +508,8 @@ static uint32_t get_ifaceindex(char *name, int ext) if (!if_ni) perror_exit("if_nameindex"); for (i = if_ni; i->if_index && i->if_name; i++) - if (!strcmp(name, i->if_name)) { - index = i->if_index; + if (!strcmp(name, i->if_name)) { + index = i->if_index; break; } if_freenameindex(if_ni); @@ -553,7 +553,7 @@ static char *get_flag_string(struct arglist *aflags, int flags, int ismulti) static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size) { - struct arglist vlan_optlist[] = {{"id", 0}, {"protocol", 1}, + struct arglist vlan_optlist[] = {{"id", 0}, {"protocol", 1}, {"reorder_hdr", 2}, {"gvrp", 3}, {NULL,-1}}; struct arglist vlan_protolist[] = {{"802.1q", 0}, {"802.1ad", 1}, {NULL,-1}}; struct arglist on_off[] = { {"on", 0}, {"off", 1}, {NULL,-1}}; @@ -583,13 +583,13 @@ static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size) case 3: // ARG_gvrp if ((param = substring_to_idx(*argv, on_off)) == -1) help_exit(0); - flags.mask |= (idx -1); // VLAN FLAG REORDER Header - flags.flags &= ~(idx -1); // VLAN FLAG REORDER Header + flags.mask |= (idx -1); // VLAN FLAG REORDER Header + flags.flags &= ~(idx -1); // VLAN FLAG REORDER Header if (!param) flags.flags |= (idx -1); // VLAN FLAG REORDER Header break; } } - if (flags.mask) + if (flags.mask) add_string_to_rtattr(n, size, IFLA_VLAN_FLAGS, &flags, sizeof(flags)); } @@ -599,14 +599,14 @@ static int linkupdate(char **argv) struct nlmsghdr mhdr; struct ifinfomsg info; char buf[1024]; - } request; + } request; char *name, *dev, *type, *link, *addr; struct rtattr *attr = NULL; int len = 0, add = (*argv[-1] == 'a') ? 1 : 0; name = dev = type = link = addr = NULL; for (; *argv; argv++) { - struct arglist objectlist[] = { {"type", 0}, {"name", 1}, {"link", 2}, + struct arglist objectlist[] = { {"type", 0}, {"name", 1}, {"link", 2}, {"address", 3}, {NULL,-1}}; uint8_t idx = substring_to_idx(*argv, objectlist); @@ -644,7 +644,7 @@ static int linkupdate(char **argv) IFLA_INFO_KIND, type, strlen(type)); if (!strcmp(type, "vlan")) { struct rtattr *data = NLMSG_TAIL(&request.mhdr); - add_string_to_rtattr(&request.mhdr, sizeof(request), + add_string_to_rtattr(&request.mhdr, sizeof(request), IFLA_INFO_DATA, NULL, 0); vlan_parse_opt(++argv, &request.mhdr, sizeof(request)); data->rta_len = (void *)NLMSG_TAIL(&request.mhdr) - (void *)data; @@ -654,14 +654,14 @@ static int linkupdate(char **argv) if (link) { uint32_t idx = get_ifaceindex(link, 1); - add_string_to_rtattr(&request.mhdr, sizeof(request), + add_string_to_rtattr(&request.mhdr, sizeof(request), IFLA_LINK, &idx, sizeof(uint32_t)); } if (addr) { char abuf[IF_NAMESIZE] = {0,}; fill_hwaddr(addr, IF_NAMESIZE, (unsigned char *)abuf); - add_string_to_rtattr(&request.mhdr, sizeof(request), + add_string_to_rtattr(&request.mhdr, sizeof(request), IFLA_ADDRESS, abuf, strlen(abuf)); } if (!name) { @@ -682,8 +682,8 @@ static int linkupdate(char **argv) static int link_set(char **argv) { - struct arglist cmd_objectlist[] = {{"up", 0}, {"down", 1}, {"arp", 2}, - {"multicast", 3}, {"dynamic", 4}, {"name", 5}, {"txqueuelen", 6}, + struct arglist cmd_objectlist[] = {{"up", 0}, {"down", 1}, {"arp", 2}, + {"multicast", 3}, {"dynamic", 4}, {"name", 5}, {"txqueuelen", 6}, {"mtu", 7},{"address", 8}, {"broadcast", 9}, {"dev", 10}, {NULL,-1}}; int case_flags[] = {IFF_NOARP,IFF_MULTICAST,IFF_DYNAMIC}; struct ifreq req; @@ -822,7 +822,7 @@ static void print_stats(struct rtnl_link_stats *rtstat) xprintf(" TX: errors aborted fifo window " "heartbeat%s%-10u %-8u %-7u %-8u %-8u\n", line_feed, rtstat->tx_errors, rtstat->tx_aborted_errors, - rtstat->tx_fifo_errors, rtstat->tx_window_errors, + rtstat->tx_fifo_errors, rtstat->tx_window_errors, rtstat->tx_heartbeat_errors); } } @@ -831,7 +831,7 @@ static void print_stats(struct rtnl_link_stats *rtstat) static int print_link_output(struct linkdata *link) { char *line_feed = " ", *flags,*peer = "brd"; - struct arglist iface_flags[] = {{"",0},{"UP", IFF_UP}, + struct arglist iface_flags[] = {{"",0},{"UP", IFF_UP}, {"BROADCAST", IFF_BROADCAST}, {"DEBUG", IFF_DEBUG}, {"LOOPBACK", IFF_LOOPBACK}, {"POINTOPOINT", IFF_POINTOPOINT}, {"NOTRAILERS", IFF_NOTRAILERS}, {"RUNNING", IFF_RUNNING}, @@ -859,7 +859,7 @@ static int print_link_output(struct linkdata *link) if (!(flags = get_flag_string(iface_flags, link->flags, 1))) - error_exit("Invalid data."); + error_exit("Invalid data."); if (!TT.singleline) line_feed="\n "; if (link->parent != -1) { char iface[IF_NAMESIZE]; @@ -970,10 +970,10 @@ static int get_link_info(struct nlmsghdr* h,struct linkdata* link,char **argv) case IFLA_TXQLEN: link->txqueuelen = *((int*)(RTA_DATA(attr))); break; - case IFLA_OPERSTATE: + case IFLA_OPERSTATE: { - struct arglist flags[]={{"UNKNOWN", 0}, {"NOTPRESENT", 1}, - {"DOWN", 2}, {"LOWERLAYERDOWN", 3}, {"TESTING", 4}, + struct arglist flags[]={{"UNKNOWN", 0}, {"NOTPRESENT", 1}, + {"DOWN", 2}, {"LOWERLAYERDOWN", 3}, {"TESTING", 4}, {"DORMANT", 5}, {"UP", 6}, {NULL, -1}}; if (!(lname = get_flag_string(flags, *((int*)(RTA_DATA(attr))), 0))) error_exit("Invalid state."); @@ -1337,7 +1337,7 @@ static int ipaddr_listflush(char **argv) addrinfo.scope = -1; while (*argv) { switch (idx = substring_to_idx(*argv, cmd_objectlist)) { - case 0: + case 0: {// ADDR_TO if (!*++argv) error_exit("Incomplete Command line"); else if (!strcmp(*argv, "0")) return 0; @@ -1374,10 +1374,10 @@ static int ipaddr_listflush(char **argv) free(name); addrinfo.scope = scope; } - break; + break; case 2: // ADDR_UP addrinfo.up = 1; - break; + break; case 3: // ADDR_LABEL if (!*++argv) error_exit("Incomplete Command line"); addrinfo.label = *argv; @@ -1385,7 +1385,7 @@ static int ipaddr_listflush(char **argv) case 4: // ADDR_DEV if (!*++argv) error_exit("Incomplete Command line"); - default: + default: if (TT.filter_dev) error_exit("Either \"dev\" is duplicate or %s is garbage", *argv); @@ -1396,7 +1396,7 @@ static int ipaddr_listflush(char **argv) } link_show(&tmp); - while ( linfo && (dlist = dlist_pop(&linfo))){ + while ( linfo && (dlist = dlist_pop(&linfo))){ struct linkdata *tmp = (struct linkdata*) dlist; char *temp = &tmp->iface[0]; @@ -1412,7 +1412,7 @@ static int ipaddr_listflush(char **argv) if ( fnmatch(addrinfo.label, temp, 0)) { ipaddr_print(tmp, 1); continue; - } + } } if (!TT.addressfamily && ! TT.flush ) print_link_output(tmp); @@ -1456,7 +1456,7 @@ static int ipaddr_print( struct linkdata *link, int flag_l) if (addrinfo.ifindex && addrinfo.ifindex != addressInfo->ifa_index) continue; - if (addrinfo.to) { + if (addrinfo.to) { memset(rta_tb, 0, sizeof(rta_tb)); int rt_len = IFA_PAYLOAD(addr_ptr); for (rta = IFA_RTA(addressInfo); RTA_OK(rta, rt_len); rta=RTA_NEXT(rta, rt_len)) { @@ -1499,7 +1499,7 @@ static int ipaddr_print( struct linkdata *link, int flag_l) if ((addr_ptr->nlmsg_type == NLMSG_DONE) || (addr_ptr->nlmsg_type == NLMSG_ERROR) || (TT.flush && addrinfo.to)) - goto ret_stop; + goto ret_stop; } if ((addr_ptr->nlmsg_type == NLMSG_DONE) || (addr_ptr->nlmsg_type == NLMSG_ERROR)) @@ -1703,7 +1703,7 @@ static int display_route_info(struct nlmsghdr *mhdr, char **argv) if (attr[RTA_OIF]) { if (gfilter.odev !=0 && gfilter.odev != *(int*)RTA_DATA(attr[RTA_OIF])) return 0; - sprintf(out, "%s dev %s ", out, + sprintf(out, "%s dev %s ", out, if_indextoname(*(int*)RTA_DATA(attr[RTA_OIF]), toybuf)); } @@ -1741,13 +1741,13 @@ static int display_route_info(struct nlmsghdr *mhdr, char **argv) sprintf(out, "%s error %d", out, ci->rta_error); } if (attr[RTA_IIF] && !gfilter.idev) - sprintf(out, "%s iif %s", out, + sprintf(out, "%s iif %s", out, if_indextoname(*(int*)RTA_DATA(attr[RTA_IIF]), toybuf)); if (attr[RTA_METRICS]) print_rta_metrics(out, attr[RTA_METRICS]); - if (TT.flush || (TT.connected && !TT.from_ok)) + if (TT.flush || (TT.connected && !TT.from_ok)) memcpy(toybuf, (void*)mhdr,mhdr->nlmsg_len); if (TT.flush) { @@ -1824,7 +1824,7 @@ static int display_route_info(struct nlmsghdr *mhdr, char **argv) static int route_get(char **argv) { int idx, flag; - struct arglist cmd_objectlist[] = {{"from", 0}, {"iif", 1}, {"oif", 2}, + struct arglist cmd_objectlist[] = {{"from", 0}, {"iif", 1}, {"oif", 2}, {"dev", 3}, {"notify", 4}, {"connected", 5}, {"to", 6}, {NULL, -1}}; char *idev = NULL, *odev = NULL; struct { @@ -1843,7 +1843,7 @@ static int route_get(char **argv) switch(idx = substring_to_idx(*argv, cmd_objectlist)) { case 0: TT.from_ok = 1; // dst address case 6: argv++; //fallthrough - default: + default: { uint32_t addr[8] = {0,}, netmask = 0; uint8_t len = 0; @@ -1876,7 +1876,7 @@ static int route_get(char **argv) break; } } - if (!request.msg.rtm_dst_len) + if (!request.msg.rtm_dst_len) error_exit("need at least destination address"); send_nlmesg(0, 0, 0, &request, sizeof(request)); @@ -1917,8 +1917,8 @@ static int route_get(char **argv) static int route_show_flush(char **argv) { struct arglist cmd_objectlist[] = {{"protocol", 0}, {"dev", 1}, {"oif", 2}, - {"iif", 3}, {"via", 4}, {"table", 5}, {"cache", 6}, {"from", 7}, - {"to", 8}, {"all", 9}, {"root", 10}, {"match", 11}, {"exact", 12}, + {"iif", 3}, {"via", 4}, {"table", 5}, {"cache", 6}, {"from", 7}, + {"to", 8}, {"all", 9}, {"root", 10}, {"match", 11}, {"exact", 12}, {"main", 13}, {NULL,-1}}; int family = TT.addressfamily, idx; struct { @@ -1946,7 +1946,7 @@ static int route_show_flush(char **argv) int dev = get_ifaceindex(*argv, 1); if (idx == 3) gfilter.idev = dev; - else gfilter.odev = dev; + else gfilter.odev = dev; } break; case 4: @@ -2121,7 +2121,7 @@ static int route_update(char **argv, unsigned int route_flags) char* ptr; if (!*++argv) show_iproute_help(); metric = strtoul(*argv, &ptr, 0); - if (!(!*ptr && metric <= 0xFFFFFFFFUL)) + if (!(!*ptr && metric <= 0xFFFFFFFFUL)) error_exit("Invalid argument metric %s.",*argv); else res = metric; @@ -2252,7 +2252,7 @@ static int ruleupdate(char **argv) for (; *argv; argv++) { switch ((idx = substring_to_idx(*argv, options))) { case 0: - case 1: + case 1: { // e.g. from IP/Netmask and to IP/Netmask. uint32_t addr[4] = {0,}, netmask = 0; uint8_t len = 0, *tmp; @@ -2269,7 +2269,7 @@ static int ruleupdate(char **argv) } break; case 2: - case 4: + case 4: { // e.g. Preference p# and fwmark MARK uint32_t pref; char *ptr; @@ -2352,10 +2352,10 @@ static int ruleupdate(char **argv) request.msg.rtm_type = rtmtype_str2idx(*argv); } break; - case 10: + case 10: show_iprule_help(); break; // Unreachable code. - default: + default: error_exit("Invalid argument '%s'", *argv); break; // Unreachable code. } @@ -2578,7 +2578,7 @@ static int read_tunnel(struct ip_tunnel_parm *ptnl) return 0; } -static void parse_iptunnel_args(struct ip_tunnel_parm *ptnl, char **argv, +static void parse_iptunnel_args(struct ip_tunnel_parm *ptnl, char **argv, int ipt_opt_idx) { int idx; @@ -2588,7 +2588,7 @@ static void parse_iptunnel_args(struct ip_tunnel_parm *ptnl, char **argv, {"okey", 3}, {"seq", 4}, {"iseq", 5}, {"oseq", 6}, {"csum", 7}, {"icsum", 8}, {"ocsum", 9}, {"nopmtudisc", 10}, {"pmtudisc", 11}, {"remote", 12}, {"local", 13},{"dev", 14}, {"ttl", 15}, {"tos", 16}, - {"dsfield", 17}, {"name", 18}, {NULL, -1} + {"dsfield", 17}, {"name", 18}, {NULL, -1} }; ptnl->iph.version = 4; // The value indicates the version of IP (4 or 6) @@ -2764,11 +2764,11 @@ static int tunnellist(char **argv) memset(&iptnl, 0, sizeof(iptnl)); parse_iptunnel_args(&iptnl, argv, 3); - if (iptnl.iph.protocol == IPPROTO_IPIP) + if (iptnl.iph.protocol == IPPROTO_IPIP) ret = tnl_ioctl(*iptnl.name ? iptnl.name : "tunl0", SIOCGETTUNNEL, &iptnl); - else if (iptnl.iph.protocol == IPPROTO_GRE) + else if (iptnl.iph.protocol == IPPROTO_GRE) ret = tnl_ioctl(*iptnl.name ? iptnl.name : "gre0", SIOCGETTUNNEL, &iptnl); - else if (iptnl.iph.protocol == IPPROTO_IPV6) + else if (iptnl.iph.protocol == IPPROTO_IPV6) ret = tnl_ioctl(*iptnl.name ? iptnl.name : "sit0", SIOCGETTUNNEL, &iptnl); else return read_tunnel(&iptnl); diff --git a/toys/pending/ipcrm.c b/toys/pending/ipcrm.c index cec1b12f..6febfa4d 100644 --- a/toys/pending/ipcrm.c +++ b/toys/pending/ipcrm.c @@ -73,7 +73,7 @@ void ipcrm_main(void) !strcmp(*toys.argv, "sem") || !strcmp(*toys.argv, "msg"))) { int t = (toys.argv[0][1] == 'h')? 1 : (toys.argv[0][1] == 's')? 2:3; - while (*(++toys.argv)) do_ipcrm(0, t, *toys.argv); + while (*(++toys.argv)) do_ipcrm(0, t, *toys.argv); } else { struct arg_list *tmp; diff --git a/toys/pending/ipcs.c b/toys/pending/ipcs.c index b5986af7..af3ff31e 100644 --- a/toys/pending/ipcs.c +++ b/toys/pending/ipcs.c @@ -268,7 +268,7 @@ static void sem_array(void) "allocated semaphores = %d\n", info_buf.semusz, info_buf.semaem); return; - } + } if (flag(l)) { printf("------ Semaphore Limits --------\n"); u.array = (unsigned short *)&info_buf; diff --git a/toys/pending/klogd.c b/toys/pending/klogd.c index 517edafd..c888e9e7 100644 --- a/toys/pending/klogd.c +++ b/toys/pending/klogd.c @@ -33,7 +33,7 @@ GLOBALS( ) static void set_log_level(int level) -{ +{ if (CFG_KLOGD_SOURCE_RING_BUFFER) klogctl(8, NULL, level); else { @@ -47,7 +47,7 @@ static void set_log_level(int level) static void handle_signal(int sig) { if (CFG_KLOGD_SOURCE_RING_BUFFER) { - klogctl(7, NULL, 0); + klogctl(7, NULL, 0); klogctl(0, NULL, 0); } else { set_log_level(7); diff --git a/toys/pending/last.c b/toys/pending/last.c index fd33ad53..4730a675 100644 --- a/toys/pending/last.c +++ b/toys/pending/last.c @@ -44,7 +44,7 @@ static void free_list() static void llist_add_node(struct arg_list **old, void *data) { struct arg_list *new = xmalloc(sizeof(struct arg_list)); - + new->arg = (char*)data; new->next = *old; *old = new; @@ -54,7 +54,7 @@ static void llist_add_node(struct arg_list **old, void *data) static struct arg_list *find_and_dlink(struct arg_list **list, char *devname) { struct arg_list *l = *list; - + while (*list) { struct utmp *ut = (struct utmp *)l->arg; @@ -73,7 +73,7 @@ static void seize_duration(time_t tm0, time_t tm1) { unsigned days, hours, mins; double diff = difftime(tm1, tm0); - + diff = (diff > 0) ? (tm1 - tm0) : 0; toybuf[0] = toybuf[18] = toybuf[28] = '\0'; strncpy(toybuf, ctime(&tm0), 16); // Login Time. @@ -117,13 +117,13 @@ void last_main(void) && strcmp(ut.ut_user, "LOGIN")) ut.ut_type = USER_PROCESS; /* The pair of terminal names '|' / '}' logs the * old/new system time when date changes it. - */ + */ if (!strcmp(ut.ut_user, "date")) { if (ut.ut_line[0] == '|') ut.ut_type = OLD_TIME; if (ut.ut_line[0] == '{') ut.ut_type = NEW_TIME; } - if ((ut.ut_type == SHUTDOWN_TIME) || ((ut.ut_type == RUN_LVL) && + if ((ut.ut_type == SHUTDOWN_TIME) || ((ut.ut_type == RUN_LVL) && (((ut.ut_pid & 255) == '0') || ((ut.ut_pid & 255) == '6')))) { tm[1] = tm[2] = (time_t)ut.ut_tv.tv_sec; @@ -133,8 +133,8 @@ void last_main(void) seize_duration(tm[0], tm[1]); strcpy(ut.ut_line, "system boot"); free_list(); - printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, - ut.ut_line, pwidth, pwidth, ut.ut_host, + printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, + ut.ut_line, pwidth, pwidth, ut.ut_host, toybuf, toybuf+18, toybuf+28); curlog_type = BOOT_TIME; tm[2] = (time_t)ut.ut_tv.tv_sec; @@ -144,8 +144,8 @@ void last_main(void) if (l) { struct utmp *u = (struct utmp *)l->arg; seize_duration(tm[0], u->ut_tv.tv_sec); - printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, - ut.ut_line, pwidth, pwidth, ut.ut_host, + printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, + ut.ut_line, pwidth, pwidth, ut.ut_host, toybuf, toybuf+18, toybuf+28); free(l->arg); free(l); @@ -159,7 +159,7 @@ void last_main(void) switch (type) { case EMPTY: strcpy(toybuf+18, " still"); - strcpy(toybuf+28, "logged in"); + strcpy(toybuf+28, "logged in"); break; case RUN_LVL: strcpy(toybuf+18, "- down "); @@ -174,8 +174,8 @@ void last_main(void) default: break; } - printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, - ut.ut_line, pwidth, pwidth, ut.ut_host, + printf("%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n", ut.ut_user, + ut.ut_line, pwidth, pwidth, ut.ut_host, toybuf, toybuf+18, toybuf+28); } llist_add_node(&TT.list, memcpy(xmalloc(sizeof(ut)), &ut, sizeof(ut))); diff --git a/toys/pending/modprobe.c b/toys/pending/modprobe.c index 133d8785..4db3ddef 100644 --- a/toys/pending/modprobe.c +++ b/toys/pending/modprobe.c @@ -61,7 +61,7 @@ static char *path2mod(char *file, char *mod) if (!mod) mod = xmalloc(MODNAME_LEN); from = getbasename(file); - + for (i = 0; i < (MODNAME_LEN-1) && from[i] && from[i] != '.'; i++) mod[i] = (from[i] == '-') ? '_' : from[i]; mod[i] = '\0'; @@ -177,11 +177,11 @@ static int read_line(FILE *fl, char **li) } for (;;) { if (line[len - 1] == '\n') len--; - if (!len) { + if (!len) { free(line); return len; } else if (line[len - 1] != '\\') break; - + len--; nxtlen = getline(&nxtline, &nxtlinelen, fl); if (nxtlen <= 0) break; @@ -223,7 +223,7 @@ static int config_action(struct dirtree *node) free(line), free(linecp), line = linecp = NULL) { char *tk = NULL; - if (!strlen(line)) continue; + if (!strlen(line)) continue; linecp = xstrdup(line); for (tk = strtok(linecp, "# \t"), tcount = 0; tk; tk = strtok(NULL, "# \t"), tcount++) { @@ -317,7 +317,7 @@ static void find_dep(void) mod = get_mod(line, 0); if (!mod) continue; if ((mod->flags & MOD_ALOADED) && !(FLAG(r)|FLAG(D))) continue; - + mod->flags |= MOD_FNDDEPMOD; if ((mod->flags & MOD_NDDEPS) && !mod->dep) { TT.nudeps--; @@ -404,7 +404,7 @@ static void go_probe(struct module_s *m) } if (FLAG(v)) printf("go_prob'ing %s\n", m->name); if (!FLAG(r)) m->dep = llist_rev(m->dep); - + while (m->dep) { struct module_s *m2; char *fn, *options; @@ -534,11 +534,11 @@ void modprobe_main(void) do { // Probe all real names for the alias. char *real = ((struct arg_list *)llist_pop(&module->rnames))->arg; struct module_s *m2 = get_mod(real, 0); - + if (FLAG(v)) printf("probing alias %s by realname %s\n", module->name, real); if (!m2) continue; - if (!(m2->flags & MOD_BLACKLIST) + if (!(m2->flags & MOD_BLACKLIST) && (!(m2->flags & MOD_ALOADED) || FLAG(r) || FLAG(D))) go_probe(m2); free(real); diff --git a/toys/pending/route.c b/toys/pending/route.c index 36089ae3..3b0e5be2 100644 --- a/toys/pending/route.c +++ b/toys/pending/route.c @@ -191,7 +191,7 @@ static void display_routes(sa_family_t f) metric_len = RTA_PAYLOAD(rteattr); for (metric = RTA_DATA(rteattr); RTA_OK(metric, metric_len); metric = RTA_NEXT(metric, metric_len)) - if (metric->rta_type == RTAX_ADVMSS) + if (metric->rta_type == RTAX_ADVMSS) mss = *(unsigned *)RTA_DATA(metric); else if (metric->rta_type == RTAX_WINDOW) win = *(unsigned *)RTA_DATA(metric); diff --git a/toys/pending/sh.c b/toys/pending/sh.c index dffa514c..2ca2aa01 100644 --- a/toys/pending/sh.c +++ b/toys/pending/sh.c @@ -1053,7 +1053,7 @@ static char *declarep(struct sh_vars *var) } *out = 0; - return ss; + return ss; } // Skip past valid prefix that could go before redirect @@ -1621,7 +1621,7 @@ int do_wildcard_files(struct dirtree *node) lvl = ll; patend = wildcard_path(TT.wcpat, pattern-TT.wcpat, TT.wcdeck, &ll, 1); - // Don't include . entries unless explicitly asked for them + // Don't include . entries unless explicitly asked for them if (*node->name=='.' && *pattern!='.') return 0; // Don't descend into non-directory (was called with DIRTREE_SYMFOLLOW) @@ -4693,7 +4693,7 @@ void local_main(void) if (ff->vars) break; } - // list existing vars (todo: + // list existing vars (todo: if (!toys.optc) { for (var = ff->vars; var; var++) xputs(var->str); // TODO escape return; diff --git a/toys/pending/strace.c b/toys/pending/strace.c index 24ec52a8..b5047851 100644 --- a/toys/pending/strace.c +++ b/toys/pending/strace.c @@ -288,8 +288,8 @@ static void print_struct(long addr) fprintf(stderr, ", st_nlink=%ld, st_uid=%d, st_gid=%d, " "st_blksize=%ld, st_blocks=%ld, st_size=%lld, st_atime=%ld, " "st_mtime=%ld, st_ctime=%ld}", (long) sb.st_nlink, sb.st_uid, - sb.st_gid, (long) sb.st_blksize, sb.st_blocks, (long long)sb.st_size, - sb.st_atime, sb.st_mtime, sb.st_ctime); + sb.st_gid, (long) sb.st_blksize, sb.st_blocks, (long long)sb.st_size, + sb.st_atime, sb.st_mtime, sb.st_ctime); } else { fprintf(stderr, "{st_mode="); print_mode(sb.st_mode); diff --git a/toys/pending/sulogin.c b/toys/pending/sulogin.c index f58754bc..4c26f351 100644 --- a/toys/pending/sulogin.c +++ b/toys/pending/sulogin.c @@ -3,8 +3,8 @@ * Copyright 2014 Ashish Kumar Gupta * Copyright 2014 Kyungwan Han * - * - * Relies on libcrypt for hash calculation. + * + * Relies on libcrypt for hash calculation. * No support for PAM/securetty/selinux/login script/issue/utmp @@ -27,7 +27,7 @@ GLOBALS( struct termios crntio; ) -static void timeout_handle(int signo) +static void timeout_handle(int signo) { tcsetattr(0, TCSANOW, &(TT.crntio)); fflush(stdout); @@ -54,7 +54,7 @@ static int validate_password(char *pwd) ret = read_password(toybuf, sizeof(toybuf), s); if(TT.timeout) alarm(0); - if ( ret && !toybuf[0]) { + if ( ret && !toybuf[0]) { xprintf("Normal startup.\n"); return -1; } @@ -66,7 +66,7 @@ static int validate_password(char *pwd) return ret; } -static void run_shell(char *shell) +static void run_shell(char *shell) { snprintf(toybuf,sizeof(toybuf), "-%s", shell); execl(shell, toybuf, NULL); @@ -92,7 +92,7 @@ void sulogin_main(void) dup2( fd, 1); dup2( fd, 2); if (fd > 2) close(fd); - } + } for (temp = forbid; *temp; temp++) unsetenv(*temp); diff --git a/toys/pending/syslogd.c b/toys/pending/syslogd.c index 8c60dcd8..d80bea0e 100644 --- a/toys/pending/syslogd.c +++ b/toys/pending/syslogd.c @@ -84,7 +84,7 @@ int logger_lookup(int where, char *key) //search the given name and return its value static char *dec(int val, CODE *clist, char *buf) { - for (; clist->c_name; clist++) + for (; clist->c_name; clist++) if (val == clist->c_val) return clist->c_name; sprintf(buf, "%u", val); @@ -258,7 +258,7 @@ static void open_logfiles(void) rp.ai_socktype = SOCK_DGRAM; rp.ai_protocol = IPPROTO_UDP; - if (getaddrinfo(tmpfile, NULL, &rp, &info) || !info) + if (getaddrinfo(tmpfile, NULL, &rp, &info) || !info) perror_exit("BAD ADDRESS: can't find : %s ", tmpfile); ((struct sockaddr_in*)info->ai_addr)->sin_port = htons(port); memcpy(&tfd->saddr, info->ai_addr, info->ai_addrlen); diff --git a/toys/pending/tcpsvd.c b/toys/pending/tcpsvd.c index fb0aa77d..ef614c65 100644 --- a/toys/pending/tcpsvd.c +++ b/toys/pending/tcpsvd.c @@ -1,9 +1,9 @@ -/* tcpsvd.c - TCP(UDP)/IP service daemon +/* tcpsvd.c - TCP(UDP)/IP service daemon * * Copyright 2013 Ashwini Kumar * Copyright 2013 Sandeep Sharma * Copyright 2013 Kyungwan Han - * + * * No Standard. USE_TCPSVD(NEWTOY(tcpsvd, "^<3c#=30<1b#=20<0C:u:l:hEv", TOYFLAG_USR|TOYFLAG_BIN)) @@ -16,8 +16,8 @@ config TCPSVD help usage: tcpsvd [-hEv] [-c N] [-C N[:MSG]] [-b N] [-u User] [-l Name] IP Port Prog usage: udpsvd [-hEv] [-c N] [-u User] [-l Name] IP Port Prog - - Create TCP/UDP socket, bind to IP:PORT and listen for incoming connection. + + Create TCP/UDP socket, bind to IP:PORT and listen for incoming connection. Run PROG for each connection. IP IP to listen on, 0 = all @@ -49,7 +49,7 @@ GLOBALS( struct list_pid { struct list_pid *next; - char *ip; + char *ip; int pid; }; @@ -71,11 +71,11 @@ struct list_pid *pids = NULL; static char *sock_to_address(struct sockaddr *sock, int flags) { char hbuf[NI_MAXHOST] = {0,}; - char sbuf[NI_MAXSERV] = {0,}; + char sbuf[NI_MAXSERV] = {0,}; int status = 0; socklen_t len = sizeof(struct sockaddr_in6); - if (!(status = getnameinfo(sock, len, hbuf, sizeof(hbuf), sbuf, + if (!(status = getnameinfo(sock, len, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), flags))) { if (flags & NI_NUMERICSERV) return xmprintf("%s:%s",hbuf, sbuf); return xmprintf("%s",hbuf); @@ -119,9 +119,9 @@ static int haship(char *addr) // Remove a node from the list. static char *delete(struct list_pid **pids, int pid) { - struct list_pid *prev, *free_node, *head = *pids; + struct list_pid *prev, *free_node, *head = *pids; char *ip = NULL; - + if (!head) return NULL; prev = free_node = NULL; while (head) { @@ -182,7 +182,7 @@ static void handle_exit(int sig) } } -// Grab uid and gid +// Grab uid and gid static void get_uidgid(uid_t *uid, gid_t *gid, char *ug) { struct passwd *pass = NULL; @@ -207,7 +207,7 @@ static void get_uidgid(uid_t *uid, gid_t *gid, char *ug) if (!(grp = getgrnam(group))) { n = atolx_range(group, 0, INT_MAX); if (!(grp = getgrgid(n))) perror_exit("Invalid group '%s'",group); - } + } } if (grp) *gid = grp->gr_gid; } @@ -221,8 +221,8 @@ static int create_bind_sock(char *host, struct sockaddr *haddr) unsigned long port; errno = 0; - port = strtoul(toys.optargs[1], &ptr, 10); - if (errno || port > 65535) + port = strtoul(toys.optargs[1], &ptr, 10); + if (errno || port > 65535) error_exit("Invalid port, Range is [0-65535]"); if (*ptr) ptr = toys.optargs[1]; else { @@ -231,12 +231,12 @@ static int create_bind_sock(char *host, struct sockaddr *haddr) } memset(&hints, 0, sizeof hints); - hints.ai_family = AF_UNSPEC; + hints.ai_family = AF_UNSPEC; hints.ai_socktype = (TT.udp ? SOCK_DGRAM : SOCK_STREAM); - if ((ret = getaddrinfo(host, ptr, &hints, &res))) + if ((ret = getaddrinfo(host, ptr, &hints, &res))) perror_exit("%s", gai_strerror(ret)); - for (rp = res; rp; rp = rp->ai_next) + for (rp = res; rp; rp = rp->ai_next) if ( (rp->ai_family == AF_INET) || (rp->ai_family == AF_INET6)) break; if (!rp) error_exit("Invalid IP %s", host); @@ -255,7 +255,7 @@ static void handle_signal(int sig) if (FLAG(v)) xprintf("got signal %d, exit\n", sig); raise(sig); _exit(sig + 128); //should not reach here -} +} void tcpsvd_main(void) { @@ -275,7 +275,7 @@ void tcpsvd_main(void) if ((ptr = strchr(TT.C, ':'))) *ptr++ = 0; TT.maxc = atolx_range(TT.C, 1, INT_MAX); } - + fd = create_bind_sock(toys.optargs[0], (struct sockaddr*)&haddr); if (FLAG(u)) { get_uidgid(&uid, &gid, TT.u); @@ -289,11 +289,11 @@ void tcpsvd_main(void) if (FLAG(u)) xprintf("%s: listening on %s, starting, uid %u, gid %u\n", toys.which->name, server, uid, gid); - else + else xprintf("%s: listening on %s, starting\n", toys.which->name, server); } for (j = 0; j < HASH_NR; j++) h[j].head = 0; - sigatexit(handle_signal); + sigatexit(handle_signal); signal(SIGCHLD, handle_exit); while (1) { diff --git a/toys/pending/telnetd.c b/toys/pending/telnetd.c index 235bd174..47107dcc 100644 --- a/toys/pending/telnetd.c +++ b/toys/pending/telnetd.c @@ -1,4 +1,4 @@ -/* telnetd.c - Telnet Server +/* telnetd.c - Telnet Server * * Copyright 2013 Sandeep Sharma * Copyright 2013 Kyungwan Han @@ -177,7 +177,7 @@ static int handle_iacs(struct term_session *tm, int c, int fd) char *curr ,*start,*end; int i = 0; - curr = start = tm->buff2+tm->buff2_avail; + curr = start = tm->buff2+tm->buff2_avail; end = tm->buff2 + c -1; tm->rem = 0; while (curr <= end) { @@ -189,7 +189,7 @@ static int handle_iacs(struct term_session *tm, int c, int fd) } else { toybuf[i++] = *curr++; curr++; - if (curr < end && (*curr == '\n' || *curr == '\0')) + if (curr < end && (*curr == '\n' || *curr == '\0')) curr++; continue; } @@ -197,7 +197,7 @@ static int handle_iacs(struct term_session *tm, int c, int fd) if ((curr + 1) > end) { tm->rem = 1; - break; + break; } if (*(curr+1) == IAC) { //IAC as data --> IAC IAC toybuf[i++] = *(curr+1); @@ -213,8 +213,8 @@ static int handle_iacs(struct term_session *tm, int c, int fd) if (*(curr+2) == TELOPT_NAWS) { struct winsize ws; if ((curr+8) >= end) { //ensure we have data to process. - tm->rem = end - curr; - break; + tm->rem = end - curr; + break; } ws.ws_col = (curr[3] << 8) | curr[4]; ws.ws_row = (curr[5] << 8) | curr[6]; @@ -226,7 +226,7 @@ static int handle_iacs(struct term_session *tm, int c, int fd) while (*curr != IAC && curr <= end) { curr++; tm->rem++; - } + } if (*curr == IAC) { tm->rem = 0; continue; @@ -259,7 +259,7 @@ static int dup_iacs(char *start, int fd, int len) if (needle) c = needle - start; else c = len; count = writeall(fd, start, c); - if (count < 0) break; + if (count < 0) break; len -= count; ret += count; start += count; @@ -287,11 +287,11 @@ void telnetd_main(void) if (pty_fd > TT.gmax_fd) TT.gmax_fd = pty_fd; tm = xzalloc(sizeof(struct term_session)); tm->child_pid = TT.fork_pid; - tm->new_fd = 0; - tm->pty_fd = pty_fd; - if (session_list) { + tm->new_fd = 0; + tm->pty_fd = pty_fd; + if (session_list) { tm->next = session_list; - session_list = tm; + session_list = tm; } else session_list = tm; } @@ -299,7 +299,7 @@ void telnetd_main(void) tv.tv_sec = TT.w_sec; tv.tv_usec = 0; tv_ptr = &tv; - } + } signal(SIGCHLD, generic_signal); for (;;) { @@ -312,9 +312,9 @@ void telnetd_main(void) if (tm->pty_fd > 0 && tm->buff1_avail < BUFSIZE) FD_SET(tm->pty_fd, &rd); if (tm->new_fd >= 0 && tm->buff2_avail < BUFSIZE) FD_SET(tm->new_fd, &rd); - if (tm->pty_fd > 0 && (tm->buff2_avail - tm->buff2_written) > 0) + if (tm->pty_fd > 0 && (tm->buff2_avail - tm->buff2_written) > 0) FD_SET(tm->pty_fd, &wr); - if (tm->new_fd >= 0 && (tm->buff1_avail - tm->buff1_written) > 0) + if (tm->new_fd >= 0 && (tm->buff1_avail - tm->buff1_written) > 0) FD_SET(tm->new_fd, &wr); tm = tm->next; } @@ -366,12 +366,12 @@ void telnetd_main(void) } c = handle_iacs(tm, c, tm->pty_fd); tm->buff2_avail += c; - if ((w = write(tm->pty_fd, tm->buff2+ tm->buff2_written, + if ((w = write(tm->pty_fd, tm->buff2+ tm->buff2_written, tm->buff2_avail - tm->buff2_written)) < 0) break; tm->buff2_written += w; } if (FD_ISSET(tm->pty_fd, &wr)) { - if ((w = write(tm->pty_fd, tm->buff2 + tm->buff2_written, + if ((w = write(tm->pty_fd, tm->buff2 + tm->buff2_written, tm->buff2_avail - tm->buff2_written)) < 0) break; tm->buff2_written += w; } diff --git a/toys/pending/tftp.c b/toys/pending/tftp.c index 80f14392..967e7a11 100644 --- a/toys/pending/tftp.c +++ b/toys/pending/tftp.c @@ -97,7 +97,7 @@ static int mkpkt_request(uint8_t *buffer, int opcode, char *path, int mode) buffer[0] = opcode >> 8; buffer[1] = opcode & 0xff; if(strlen(path) > TFTP_BLKSIZE) error_exit("path too long"); - return sprintf((char*) &buffer[2], "%s%c%s", path, 0, + return sprintf((char*) &buffer[2], "%s%c%s", path, 0, (mode ? "octet" : "netascii")) + 3; } @@ -137,7 +137,7 @@ static int read_server(int sd, void *buf, int len, { socklen_t alen; ssize_t nb; - + for (;;) { memset(buf, 0, len); alen = sizeof(struct sockaddr_storage); @@ -163,7 +163,7 @@ static ssize_t write_server(int sd, void *buf, size_t len, struct sockaddr_storage *to) { ssize_t nb; - + for (;;) { nb = sendto(sd, buf, len, 0, (struct sockaddr *)to, sizeof(struct sockaddr_storage)); @@ -178,7 +178,7 @@ static ssize_t write_server(int sd, void *buf, size_t len, } // checks packet for data and updates block no -static inline int check_data( uint8_t *packet, uint16_t *opcode, +static inline int check_data( uint8_t *packet, uint16_t *opcode, uint16_t *blockno) { *opcode = (uint16_t) packet[0] << 8 | (uint16_t) packet[1]; diff --git a/toys/pending/traceroute.c b/toys/pending/traceroute.c index c6bcfc31..6107ff3b 100644 --- a/toys/pending/traceroute.c +++ b/toys/pending/traceroute.c @@ -100,7 +100,7 @@ static u_int16_t in_cksum(u_int16_t *p, u_int len) u.c[1] = 0; sum += u.w; } - // end-around-carry + // end-around-carry sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); return (~sum); @@ -133,7 +133,7 @@ static void send_probe4(int seq, int ttl) if (res < 0) perror_exit("setsockopt ttl %d", ttl); len = TT.msg_len; - res = sendto(TT.snd_sock, out, len, 0, (struct sockaddr *) &dest, + res = sendto(TT.snd_sock, out, len, 0, (struct sockaddr *) &dest, sizeof(struct sockaddr_in)); if (res != len) perror_exit(" sendto"); } @@ -148,7 +148,7 @@ static void send_probe6(int seq, int ttl) send_data6->ident = TT.ident; ((struct sockaddr_in6 *)&dest)->sin6_port = TT.port; - if (setsockopt(TT.snd_sock, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, + if (setsockopt(TT.snd_sock, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl)) < 0) error_exit("setsockopt ttl %d", ttl); out = send_data6; @@ -225,12 +225,12 @@ static void do_trace() gettimeofday(&t1, NULL); t2 = t1; - while ((tleft = (int)(tv - ((unsigned long long)(t2.tv_sec * 1000ULL + while ((tleft = (int)(tv - ((unsigned long long)(t2.tv_sec * 1000ULL + t2.tv_usec/1000) - (unsigned long long)(t1.tv_sec * 1000ULL + t1.tv_usec/1000)))) >= 0) { unsigned delta = 0; - if (!(res = poll(pfd, 1, tleft))) { - xprintf(" *"); + if (!(res = poll(pfd, 1, tleft))) { + xprintf(" *"); break; } gettimeofday(&t2, NULL); @@ -276,28 +276,28 @@ static void do_trace() ricmp->icmp_code); } else { hicmp = (struct icmp *) ((char*)hip + (hip->ip_hl << 2)); - if (ricmp->icmp_type == ICMP_ECHOREPLY + if (ricmp->icmp_type == ICMP_ECHOREPLY && ricmp->icmp_id == ntohs(TT.ident) && ricmp->icmp_seq == ntohs(seq)) icmp_res = ICMP_UNREACH_PORT; - else if ((hip->ip_hl << 2) + ICMP_HD_SIZE4 + else if ((hip->ip_hl << 2) + ICMP_HD_SIZE4 <= (rcv_len - (rcv_pkt->ip_hl << 2)) && hip->ip_p == IPPROTO_ICMP && hicmp->icmp_id == htons(TT.ident) && hicmp->icmp_seq == htons(seq)) - icmp_res = (ricmp->icmp_type == ICMP_TIMXCEED ? -1 : + icmp_res = (ricmp->icmp_type == ICMP_TIMXCEED ? -1 : ricmp->icmp_code); } } if (!icmp_res) continue; if (addrlen > 0) { - if (memcmp(&((struct sockaddr_in *)&last_addr)->sin_addr, - &((struct sockaddr_in *)&from)->sin_addr, + if (memcmp(&((struct sockaddr_in *)&last_addr)->sin_addr, + &((struct sockaddr_in *)&from)->sin_addr, sizeof(struct in_addr))) { if (!(toys.optflags & FLAG_n)) { char host[NI_MAXHOST]; - if (!getnameinfo((struct sockaddr *) &from, + if (!getnameinfo((struct sockaddr *) &from, sizeof(struct sockaddr_in), host, NI_MAXHOST, NULL, 0, 0)) xprintf(" %s (", host); else xprintf(" %s (", inet_ntoa( @@ -359,7 +359,7 @@ static void do_trace() xprintf(" !C"); ++fexit; break; - case ICMP_UNREACH_NET_UNKNOWN: + case ICMP_UNREACH_NET_UNKNOWN: case ICMP_UNREACH_HOST_UNKNOWN: xprintf(" !U"); ++fexit; @@ -407,8 +407,8 @@ static void do_trace() if (!icmp_res) continue; if (addrlen > 0) { - if (memcmp(&((struct sockaddr_in6 *)&last_addr)->sin6_addr, - &((struct sockaddr_in6 *)&from)->sin6_addr, + if (memcmp(&((struct sockaddr_in6 *)&last_addr)->sin6_addr, + &((struct sockaddr_in6 *)&from)->sin6_addr, sizeof(struct in6_addr))) { if (!(toys.optflags & FLAG_n)) { char host[NI_MAXHOST]; @@ -467,7 +467,7 @@ static void do_trace() } xputc('\n'); if(!TT.istraceroute6) { - if (!memcmp(&((struct sockaddr_in *)&from)->sin_addr, + if (!memcmp(&((struct sockaddr_in *)&from)->sin_addr, &((struct sockaddr_in *)&dest)->sin_addr, sizeof(struct in_addr)) || dest_reach || (fexit && fexit >= TT.ttl_probes -1)) break; @@ -479,8 +479,8 @@ void traceroute_main(void) { unsigned pack_size = 0, tyser = 0; int lsrr = 0, set = 1; - - if(!(toys.optflags & FLAG_4) && + + if(!(toys.optflags & FLAG_4) && (inet_pton(AF_INET6, toys.optargs[0], &dest))) toys.optflags |= FLAG_6; @@ -511,29 +511,29 @@ void traceroute_main(void) if (TT.istraceroute6) { int two = 2; #ifdef IPV6_RECVPKTINFO - setsockopt(TT.recv_sock, SOL_IPV6, IPV6_RECVPKTINFO, &set, + setsockopt(TT.recv_sock, SOL_IPV6, IPV6_RECVPKTINFO, &set, sizeof(set)); - setsockopt(TT.recv_sock, SOL_IPV6, IPV6_2292PKTINFO, &set, + setsockopt(TT.recv_sock, SOL_IPV6, IPV6_2292PKTINFO, &set, sizeof(set)); #else setsockopt(TT.recv_sock, SOL_IPV6, IPV6_PKTINFO, &set, sizeof(set)); #endif - if (setsockopt(TT.recv_sock, SOL_RAW, IPV6_CHECKSUM, &two, + if (setsockopt(TT.recv_sock, SOL_RAW, IPV6_CHECKSUM, &two, sizeof(two)) < 0) perror_exit("setsockopt RAW_CHECKSUM"); } set_flag_dr(TT.recv_sock); if (!TT.istraceroute6) { - if (toys.optflags & FLAG_U) + if (toys.optflags & FLAG_U) TT.snd_sock = xsocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); else TT.snd_sock = xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP); if (toys.optflags & FLAG_i) bind_to_interface(TT.snd_sock); - resolve_addr(toys.optargs[0], AF_INET, ((toys.optflags & FLAG_U) ? - SOCK_DGRAM : SOCK_RAW), ((toys.optflags & FLAG_U) ? IPPROTO_UDP : + resolve_addr(toys.optargs[0], AF_INET, ((toys.optflags & FLAG_U) ? + SOCK_DGRAM : SOCK_RAW), ((toys.optflags & FLAG_U) ? IPPROTO_UDP : IPPROTO_ICMP), &dest); if (lsrr > 0) { unsigned char optlist[MAX_IPOPTLEN]; @@ -543,7 +543,7 @@ void traceroute_main(void) ++lsrr; optlist[0] = IPOPT_NOP; - optlist[1] = IPOPT_LSRR;// loose source route option + optlist[1] = IPOPT_LSRR;// loose source route option size = lsrr * sizeof(TT.gw_list[0]); optlist[2] = size + 3; optlist[3] = IPOPT_MINOFF; @@ -555,17 +555,17 @@ void traceroute_main(void) } } else TT.snd_sock = xsocket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); - if (setsockopt(TT.snd_sock, SOL_SOCKET, SO_SNDBUF, &TT.msg_len, + if (setsockopt(TT.snd_sock, SOL_SOCKET, SO_SNDBUF, &TT.msg_len, sizeof(TT.msg_len)) < 0) perror_exit("SO_SNDBUF failed "); if (!TT.istraceroute6) { - if ((toys.optflags & FLAG_t) && + if ((toys.optflags & FLAG_t) && setsockopt(TT.snd_sock, IPPROTO_IP, IP_TOS, &tyser, sizeof(tyser)) < 0) perror_exit("IP_TOS %ld failed ", TT.tos); #ifdef IP_DONTFRAG if ((toys.optflags & FLAG_F) && - (setsockopt(TT.snd_sock, IPPROTO_IP, IP_DONTFRAG, &set, + (setsockopt(TT.snd_sock, IPPROTO_IP, IP_DONTFRAG, &set, sizeof(set)) < 0)) perror_exit("IP_DONTFRAG failed "); #endif } else if (setsockopt(TT.snd_sock, IPPROTO_IPV6, IPV6_TCLASS, &TT.tos, @@ -589,10 +589,10 @@ void traceroute_main(void) xbind(TT.snd_sock,(struct sockaddr*)&source, sizeof(struct sockaddr_in)); } - if(TT.first_ttl > TT.max_ttl) + if(TT.first_ttl > TT.max_ttl) error_exit("ERROR :Range for -f is 1 to %ld (max ttl)", TT.max_ttl); - xprintf("traceroute to %s(%s)", toys.optargs[0], + xprintf("traceroute to %s(%s)", toys.optargs[0], inet_ntoa(((struct sockaddr_in *)&dest)->sin_addr)); } else { if (toys.optflags & FLAG_i) bind_to_interface(TT.snd_sock); @@ -614,7 +614,7 @@ void traceroute_main(void) ((struct sockaddr_in6 *)&dest)->sin6_port = htons(1025); xconnect(p_fd, (struct sockaddr *)&dest, sizeof(struct sockaddr_in6)); - if(getsockname(p_fd, (struct sockaddr *)&prb, &len)) + if(getsockname(p_fd, (struct sockaddr *)&prb, &len)) error_exit("probe addr failed"); close(p_fd); prb.sin6_port = 0; @@ -622,7 +622,7 @@ void traceroute_main(void) xbind(TT.recv_sock, (struct sockaddr*)&prb, sizeof(struct sockaddr_in6)); } - inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&dest)->sin6_addr, + inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&dest)->sin6_addr, addr_str, INET6_ADDRSTRLEN); xprintf("traceroute6 to %s(%s)", toys.optargs[0], addr_str); } diff --git a/toys/pending/useradd.c b/toys/pending/useradd.c index c421498e..261c7e48 100644 --- a/toys/pending/useradd.c +++ b/toys/pending/useradd.c @@ -110,7 +110,7 @@ void useradd_main(void) free(s); } - /*add user to system + /*add user to system * 1. add an entry to /etc/passwd and /etcshadow file * 2. Copy /etc/skel dir contents to use home dir * 3. update the user passwd by running 'passwd' utility @@ -123,10 +123,10 @@ void useradd_main(void) update_password("/etc/passwd", pwd.pw_name, entry, 0); free(entry); - if (toys.optflags & FLAG_S) - entry = xmprintf("%s:!!:%u::::::", pwd.pw_name, + if (toys.optflags & FLAG_S) + entry = xmprintf("%s:!!:%u::::::", pwd.pw_name, (unsigned)(time(NULL))/(24*60*60)); //passwd is not set initially - else entry = xmprintf("%s:!!:%u:0:99999:7:::", pwd.pw_name, + else entry = xmprintf("%s:!!:%u:0:99999:7:::", pwd.pw_name, (unsigned)(time(0))/(24*60*60)); //passwd is not set initially update_password("/etc/shadow", pwd.pw_name, entry, 0); free(entry); diff --git a/toys/pending/userdel.c b/toys/pending/userdel.c index 69c520aa..a77fb28e 100644 --- a/toys/pending/userdel.c +++ b/toys/pending/userdel.c @@ -13,7 +13,7 @@ config USERDEL help usage: userdel [-r] USER usage: deluser [-r] USER - + Delete USER from the SYSTEM -r remove home directory @@ -96,9 +96,9 @@ void userdel_main(void) update_password("/etc/shadow", pwd->pw_name, 0, 0); // delete the group named USER, and remove user from group. - // could update_password() be used for this? + // could update_password() be used for this? // not a good idea, as update_passwd() updates one entry at a time - // in this case it will be modifying the files as many times the + // in this case it will be modifying the files as many times the // USER appears in group database files. So the customized version // of update_passwd() is here. update_groupfiles("/etc/group", *toys.optargs); diff --git a/toys/pending/xzcat.c b/toys/pending/xzcat.c index 6fdf3428..cbe48fb7 100644 --- a/toys/pending/xzcat.c +++ b/toys/pending/xzcat.c @@ -13,7 +13,7 @@ config XZCAT default n help usage: xzcat [filename...] - + Decompress listed files to stdout. Use stdin if no files listed. */ @@ -35,7 +35,7 @@ config XZCAT * which is not used in the kernel. Unsupported * check types return XZ_OPTIONS_ERROR if * XZ_DEC_ANY_CHECK was not defined at build time. - * @XZ_MEM_ERROR: Allocating memory failed. The amount of memory + * @XZ_MEM_ERROR: Allocating memory failed. The amount of memory * that was tried to be allocated was no more than the * dict_max argument given to xz_dec_init(). * @XZ_MEMLIMIT_ERROR: A bigger LZMA2 dictionary would be needed than @@ -52,11 +52,11 @@ config XZCAT * different between multi-call and single-call * mode; more information below. * - * XZ_BUF_ERROR is returned when two consecutive calls to XZ code cannot + * XZ_BUF_ERROR is returned when two consecutive calls to XZ code cannot * consume any input and cannot produce any new output. This happens when * there is no new input available, or the output buffer is full while at * least one output byte is still pending. Assuming your code is not buggy, - * you can get this error only when decoding a compressed stream that is + * you can get this error only when decoding a compressed stream that is * truncated or otherwise corrupt. */ enum xz_ret { @@ -305,7 +305,7 @@ void xzcat_main(void) // BEGIN xz_private.h -/* Uncomment as needed to enable BCJ filter decoders. +/* Uncomment as needed to enable BCJ filter decoders. * These cost about 2.5 k when all are enabled; SPARC and IA64 make 0.7 k * */ diff --git a/toys/posix/kill.c b/toys/posix/kill.c index f869e368..dc4c370f 100644 --- a/toys/posix/kill.c +++ b/toys/posix/kill.c @@ -130,7 +130,7 @@ void kill_main(void) if (!readfile(toybuf, toybuf, sizeof(toybuf)) || !*toybuf) continue; // Check with omit list. - for (count = 0; count < ocount; count++) + for (count = 0; count < ocount; count++) if (procpid == olist[count]) break; if (count != ocount) continue; diff --git a/toys/posix/od.c b/toys/posix/od.c index c12055e6..b4f77fd5 100644 --- a/toys/posix/od.c +++ b/toys/posix/od.c @@ -163,7 +163,7 @@ static void od_outline(void) // If more than one byte of input consumed, average rounding up. j = od_out_t(types+i, buf, &bytes); j = (j+bytes-1)/bytes; - + if (j > pad) pad = j; } diff --git a/toys/posix/paste.c b/toys/posix/paste.c index 173c97f3..5c1b234c 100644 --- a/toys/posix/paste.c +++ b/toys/posix/paste.c @@ -2,7 +2,7 @@ * * Copyright 2012 Felix Janda * - * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/paste.html + * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/paste.html * * Deviations from posix: the FILE argument isn't mandatory, none == '-' diff --git a/toys/posix/ps.c b/toys/posix/ps.c index b99fa183..676bfcb9 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -556,7 +556,7 @@ static char *string_field(struct procpid *tb, struct ofields *field) // Clock displays } else if (which <= PS_TIME_) { - int unit = 60, pad = 2, j = TT.ticks; + int unit = 60, pad = 2, j = TT.ticks; time_t seconds; if (which!=PS_TIME_) unit *= 60*24; @@ -619,7 +619,7 @@ static char *string_field(struct procpid *tb, struct ofields *field) if (slot[SLOT_sid]==*slot) *s++ = 's'; if (slot[SLOT_vmlck]) *s++ = 'L'; if (slot[SLOT_ttypgrp]==*slot) *s++ = '+'; - } + } *s = 0; } else if (which==PS_STIME) { time_t t = time(0)-slot[SLOT_uptime]+slot[SLOT_starttime]/TT.ticks; @@ -1255,7 +1255,7 @@ static int ksort(void *aa, void *bb) // Collect ->extra field from leaf nodes DIRTREE_SAVEd by get_ps() into array // (recursion because tree from get_thread() isn't flat list of siblings) -static struct procpid **collate_leaves(struct procpid **tb, struct dirtree *dt) +static struct procpid **collate_leaves(struct procpid **tb, struct dirtree *dt) { while (dt) { struct dirtree *next = dt->next; @@ -1278,7 +1278,7 @@ static struct procpid **collate(int count, struct dirtree *dt) collate_leaves(tbsort, dt); return tbsort; -} +} // parse command line arguments (ala -k -o) with a comma separated FIELD list static void default_ko(char *s, void *fields, char *err, struct arg_list *arg) diff --git a/toys/posix/sed.c b/toys/posix/sed.c index f7a49f2a..98fbd957 100644 --- a/toys/posix/sed.c +++ b/toys/posix/sed.c @@ -91,7 +91,7 @@ config SED = Print the current line number (plus newline) # Comment, ignores rest of this line of SCRIPT (until newline) - Commands that take an argument: + Commands that take an argument: : LABEL Target for jump commands a TEXT Append text to output before reading next line @@ -109,7 +109,7 @@ config SED i/I Ignore case when matching p Print resulting line when match found and replaced w [file] Write (append) line to file when match replaced - t LABEL Test, jump if s/// command matched this line since last test + t LABEL Test, jump if s/// command matched this line since last test T LABEL Test false, jump to :LABEL only if no s/// found a match w FILE Write (append) line to file y/old/new/ Change each character in 'old' to corresponding character @@ -308,7 +308,7 @@ static void sed_line(char **pline, long plen) command->hit = TT.count; if (!command->lmatch[1] && !command->rmatch[1]) miss = 1; - } + } // Didn't match? lm = !(command->not^!!command->hit); @@ -449,7 +449,7 @@ static void sed_line(char **pline, long plen) } // Pending append goes out right after N - goto done; + goto done; } else if (c=='p' || c=='P') { char *l = (c=='P') ? strchr(line, TT.delim) : 0; @@ -1110,7 +1110,7 @@ void sed_main(void) } parse_pattern(0, 0); dlist_terminate(TT.pattern); - if (TT.nextlen) error_exit("no }"); + if (TT.nextlen) error_exit("no }"); TT.fdout = 1; TT.remember = xstrdup(""); diff --git a/toys/posix/tail.c b/toys/posix/tail.c index 1b17fcd5..494e1516 100644 --- a/toys/posix/tail.c +++ b/toys/posix/tail.c @@ -148,7 +148,7 @@ static void tail_continue() } fd = TT.F[i].fd; path = TT.F[i].path; - + if (stat(TT.F[i].path, &sb)) { if (fd >= 0) { close(fd); diff --git a/toys/posix/tar.c b/toys/posix/tar.c index 00cbe968..780acc4c 100644 --- a/toys/posix/tar.c +++ b/toys/posix/tar.c @@ -289,7 +289,7 @@ static int add_to_tar(struct dirtree *node) } else if ((node->again&DIRTREE_BREADTH) && node->child) { struct dirtree *dt, **sort = xmalloc(sizeof(void *)*node->extra); - for (node->extra = 0, dt = node->child; dt; dt = dt->next) + for (node->extra = 0, dt = node->child; dt; dt = dt->next) sort[node->extra++] = dt; qsort(sort, node->extra--, sizeof(void *), (void *)dirtree_sort); node->child = *sort; @@ -616,7 +616,7 @@ static void extract_to_disk(char *name) if (dirflush(name, S_ISDIR(ala))) { if (S_ISREG(ala) && !TT.hdr.link_target) skippy(TT.hdr.size); - + return; } diff --git a/toys/posix/ulimit.c b/toys/posix/ulimit.c index 642f8871..ffb1eb38 100644 --- a/toys/posix/ulimit.c +++ b/toys/posix/ulimit.c @@ -28,7 +28,7 @@ config ULIMIT Print or set resource limits for process number PID. If no LIMIT specified (or read-only -ap selected) display current value (sizes in bytes). Default is ulimit -P $PPID -Sf" (show soft filesize of your shell). - + -P PID to affect (default $PPID) -a Show all limits -S Set/show soft limit -H Set/show hard (maximum) limit diff --git a/toys/posix/uname.c b/toys/posix/uname.c index c89e84c3..dfa5762f 100644 --- a/toys/posix/uname.c +++ b/toys/posix/uname.c @@ -7,7 +7,7 @@ USE_UNAME(NEWTOY(uname, "paomvrns", TOYFLAG_BIN)) USE_ARCH(NEWTOY(arch, 0, TOYFLAG_USR|TOYFLAG_BIN)) -config ARCH +config ARCH bool "arch" default y help @@ -26,7 +26,7 @@ config UNAME -s System name -n Network (domain) name -r Kernel Release number - -v Kernel Version + -v Kernel Version -m Machine (hardware) name -a All of the above (in order) diff --git a/toys/posix/uuencode.c b/toys/posix/uuencode.c index 3bede303..3d9b2fef 100644 --- a/toys/posix/uuencode.c +++ b/toys/posix/uuencode.c @@ -8,7 +8,7 @@ USE_UUENCODE(NEWTOY(uuencode, "<1>2m", TOYFLAG_USR|TOYFLAG_BIN)) config UUENCODE bool "uuencode" - default y + default y help usage: uuencode [-m] [INFILE] ENCODE_FILENAME @@ -51,7 +51,7 @@ void uuencode_main(void) out = (x>>((3-j)*6)) & 0x3f; xputc(FLAG(m) ? (j > bytes ? '=' : toybuf[out]) : (out ? out + 0x20 : 0x60)); - } + } } xputc('\n'); } -- 2.39.2