From 55702ae05b838f0bafa546dc654d2fc0723d4a2e Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 20 Dec 2017 10:24:55 +0100 Subject: [PATCH] whitespace, coding style and copyright updates --- config.h | 4 ++-- dist-maketable.c | 30 +++++++++++++++--------------- dist-maketable.h | 1 + dist.c | 2 +- emulate.c | 2 +- hist.c | 2 +- hist.h | 2 +- main.c | 24 ++++++++++++------------ mark.c | 2 +- netlink-private.h | 2 +- probe.c | 2 +- tc.c | 2 +- tc.h | 2 +- tcp.c | 2 +- tcp.h | 2 +- timing.c | 2 +- timing.h | 2 +- ts.c | 2 +- ts.h | 2 +- utils.c | 18 +++++++++--------- utils.h | 4 ++-- 21 files changed, 56 insertions(+), 55 deletions(-) diff --git a/config.h b/config.h index 4995662..919623d 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ /** Global configuration. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ @@ -23,4 +23,4 @@ struct config { /* Declared in main.c */ extern struct config cfg; -#endif \ No newline at end of file +#endif diff --git a/dist-maketable.c b/dist-maketable.c index 386b405..78a4d89 100644 --- a/dist-maketable.c +++ b/dist-maketable.c @@ -40,7 +40,7 @@ double * readdoubles(FILE *fp, int *number) x = calloc(limit, sizeof(double)); if (!x) error(-1, 0, "Alloc"); - + size_t linelen = 0; char *line; @@ -48,9 +48,9 @@ double * readdoubles(FILE *fp, int *number) if (getline(&line, &linelen, fp) > 0) { if (line[0] == '#' || line[0] == '\r' || line[0] == '\n') continue; - + fscanf(fp, "%lf", &x[i]); - + ++n; } else if (feof(fp)) @@ -64,21 +64,21 @@ double * readdoubles(FILE *fp, int *number) void arraystats(double *x, int limit, double *mu, double *sigma, double *rho) { - int n=0, i; - double sumsquare=0.0, sum=0.0, top=0.0; - double sigma2=0.0; + int n = 0, i; + double sumsquare = 0.0, sum = 0.0, top = 0.0; + double sigma2 = 0.0; - for (i=0; i - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/emulate.c b/emulate.c index c54c4fc..2c6ca4a 100644 --- a/emulate.c +++ b/emulate.c @@ -1,7 +1,7 @@ /** Setup and update netem qdisc. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/hist.c b/hist.c index 84adef8..86ea466 100644 --- a/hist.c +++ b/hist.c @@ -1,7 +1,7 @@ /** Histogram functions. * * @author Steffen Vogel - * @copyright 2014-2015, Institute for Automation of Complex Power Systems, EONERC + * @copyright 2014-2017, Institute for Automation of Complex Power Systems, EONERC * This file is part of S2SS. All Rights Reserved. Proprietary and confidential. * Unauthorized copying of this file, via any medium is strictly prohibited. *********************************************************************************/ diff --git a/hist.h b/hist.h index ae0f95b..208333a 100644 --- a/hist.h +++ b/hist.h @@ -2,7 +2,7 @@ * * @file * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/main.c b/main.c index 77cfad6..10fb01b 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,7 @@ /** Main routine. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ @@ -44,7 +44,7 @@ void quit(int sig, siginfo_t *si, void *ptr) } int main(int argc, char *argv[]) -{ +{ if (argc < 2) { printf( "usage: %s CMD [OPTIONS]\n" " CMD can be one of:\n\n" @@ -68,10 +68,10 @@ int main(int argc, char *argv[]) " -d IF network interface\n" "\n" "netem util %s (built on %s %s)\n" - " Copyright 2015, Steffen Vogel \n", argv[0], VERSION, __DATE__, __TIME__); + " Copyright 2017, Steffen Vogel \n", argv[0], VERSION, __DATE__, __TIME__); exit(EXIT_FAILURE); - } + } /* Setup signals */ struct sigaction sa_quit = { @@ -82,10 +82,10 @@ int main(int argc, char *argv[]) sigemptyset(&sa_quit.sa_mask); sigaction(SIGTERM, &sa_quit, NULL); sigaction(SIGINT, &sa_quit, NULL); - + /* Initialize PRNG for TCP sequence nos */ srand(time(NULL)); - + /* Parse Arguments */ char c, *endptr; while ((c = getopt (argc-1, argv+1, "h:m:M:i:l:d:r:w:")) != -1) { @@ -108,11 +108,11 @@ int main(int argc, char *argv[]) case 'l': cfg.limit = strtoul(optarg, &endptr, 10); goto check; - + case 'd': cfg.dev = strdup(optarg); break; - + case '?': if (optopt == 'c') error(-1, 0, "Option -%c requires an argument.", optopt); @@ -124,13 +124,13 @@ int main(int argc, char *argv[]) default: abort(); } - + continue; check: if (optarg == endptr) error(-1, 0, "Failed to parse parse option argument '-%c %s'", c, optarg); } - + char *cmd = argv[1]; if (!strcmp(cmd, "probe")) @@ -141,6 +141,6 @@ check: return dist(argc-optind-1, argv+optind+1); else error(-1, 0, "Unknown command: %s", cmd); - + return 0; -} \ No newline at end of file +} diff --git a/mark.c b/mark.c index 64e7a45..aa954f3 100644 --- a/mark.c +++ b/mark.c @@ -9,7 +9,7 @@ * * @author Steffen Vogel * @authir D.J. Capelis - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @copyright 2007, Regents of the University of California * @license GPLv3 *********************************************************************************/ diff --git a/netlink-private.h b/netlink-private.h index 367e75a..c9a8569 100644 --- a/netlink-private.h +++ b/netlink-private.h @@ -5,7 +5,7 @@ * Based on libnl3 3.2.26 * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/probe.c b/probe.c index 1383540..7dcda3c 100644 --- a/probe.c +++ b/probe.c @@ -1,7 +1,7 @@ /** Probing for RTT, Loss, Duplication, Corruption. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/tc.c b/tc.c index 2bcb579..429bc60 100644 --- a/tc.c +++ b/tc.c @@ -1,7 +1,7 @@ /** Trafic Controller (TC) related functions * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/tc.h b/tc.h index 84b3dc2..2ff8de3 100644 --- a/tc.h +++ b/tc.h @@ -1,7 +1,7 @@ /** Trafic Controller (TC) related functions * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/tcp.c b/tcp.c index f364b47..6f1dbec 100644 --- a/tcp.c +++ b/tcp.c @@ -1,7 +1,7 @@ /** Userspace TCP functions. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/tcp.h b/tcp.h index 4411fe3..6a9ed31 100644 --- a/tcp.h +++ b/tcp.h @@ -1,7 +1,7 @@ /** Userspace TCP functions. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/timing.c b/timing.c index 5380d10..c9cf6e4 100644 --- a/timing.c +++ b/timing.c @@ -1,7 +1,7 @@ /** Time related functions. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/timing.h b/timing.h index d590d37..510d265 100644 --- a/timing.h +++ b/timing.h @@ -1,7 +1,7 @@ /** Time related functions. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/ts.c b/ts.c index 50b9ac0..a3c3cbb 100644 --- a/ts.c +++ b/ts.c @@ -1,7 +1,7 @@ /** Hardware / Kernelspace Timestamping of network packets. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ #define _POSIX_C_SOURCE 199309L diff --git a/ts.h b/ts.h index 4741af1..5981867 100644 --- a/ts.h +++ b/ts.h @@ -1,7 +1,7 @@ /** Hardware / Kernelspace Timestamping of network packets. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ diff --git a/utils.c b/utils.c index e422d66..cdf0aab 100644 --- a/utils.c +++ b/utils.c @@ -1,7 +1,7 @@ /** Utilities. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 *********************************************************************************/ @@ -20,7 +20,7 @@ void hexdump(void *mem, unsigned int len) { unsigned int i, j; - + for (i = 0; i < len + ((len % HEXDUMP_COLS) ? (HEXDUMP_COLS - len % HEXDUMP_COLS) : 0); i++) { if (i % HEXDUMP_COLS == 0) printf("0x%06x: ", i); /* print offset */ @@ -29,18 +29,18 @@ void hexdump(void *mem, unsigned int len) printf("%02x ", 0xFF & ((char*)mem)[i]); /* print hex data */ else printf(" "); /* end of block, just aligning for ASCII dump */ - + /* print ASCII dump */ if (i % HEXDUMP_COLS == (HEXDUMP_COLS - 1)) { for (j = i - (HEXDUMP_COLS - 1); j <= i; j++) { if (j >= len) /* end of block, not really printing */ putchar(' '); else if (isprint(((char*)mem)[j])) /* printable char */ - putchar(0xFF & ((char*)mem)[j]); + putchar(0xFF & ((char*)mem)[j]); else /* other char */ putchar('.'); } - + putchar('\n'); } } @@ -53,19 +53,19 @@ void * alloc(size_t bytes) error(-1, 0, "Failed to allocate memory"); memset(p, 0, bytes); - + return p; } int strap(char *dest, size_t size, const char *fmt, ...) { int ret; - + va_list ap; va_start(ap, fmt); ret = vstrap(dest, size, fmt, ap); va_end(ap); - + return ret; } @@ -74,4 +74,4 @@ int vstrap(char *dest, size_t size, const char *fmt, va_list ap) int len = strlen(dest); return vsnprintf(dest + len, size - len, fmt, ap); -} \ No newline at end of file +} diff --git a/utils.h b/utils.h index 4c937f7..d8d86bb 100644 --- a/utils.h +++ b/utils.h @@ -1,7 +1,7 @@ /** Utilities. * * @author Steffen Vogel - * @copyright 2014-2015, Steffen Vogel + * @copyright 2014-2017, Steffen Vogel * @license GPLv3 * @file *********************************************************************************/ @@ -27,4 +27,4 @@ int strap(char *dest, size_t size, const char *fmt, ...); /** Variadic version of strap() */ int vstrap(char *dest, size_t size, const char *fmt, va_list va); -#endif \ No newline at end of file +#endif