diff options
author | mlaier <mlaier@FreeBSD.org> | 2004-03-15 13:41:17 +0000 |
---|---|---|
committer | mlaier <mlaier@FreeBSD.org> | 2004-03-15 13:41:17 +0000 |
commit | 4c91a73d426123e1662d8a1b186f9605ca384b73 (patch) | |
tree | 0cd850f4bfbc1ebe7c447546892114cb24f965a6 | |
parent | 950b98f1f71ea41489c4abcf9e4071bc2a3d33da (diff) | |
download | FreeBSD-src-4c91a73d426123e1662d8a1b186f9605ca384b73.zip FreeBSD-src-4c91a73d426123e1662d8a1b186f9605ca384b73.tar.gz |
Fix some style(9) related issues after discussion with/education from bde:
- Add <sys/param.h> and <limits.h> where required (do not depend on other
headers pulling it in).
- __dead -> __dead2
- #if defined() -> #ifdef
- Remove ugly PRIu64 macros and use %llu w/ (unsigned long long) cast.
All changes looped back to OpenBSD (where applicable) for easier sync in the
future.
Requested by: bde
Approved by: bms(mentor)
-rw-r--r-- | contrib/pf/authpf/authpf.c | 18 | ||||
-rw-r--r-- | contrib/pf/ftp-proxy/ftp-proxy.c | 1 | ||||
-rw-r--r-- | contrib/pf/pfctl/parse.y | 3 | ||||
-rw-r--r-- | contrib/pf/pfctl/pfctl.c | 31 | ||||
-rw-r--r-- | contrib/pf/pfctl/pfctl.h | 2 | ||||
-rw-r--r-- | contrib/pf/pfctl/pfctl_altq.c | 21 | ||||
-rw-r--r-- | contrib/pf/pfctl/pfctl_parser.c | 50 | ||||
-rw-r--r-- | contrib/pf/pfctl/pfctl_parser.h | 2 | ||||
-rw-r--r-- | contrib/pf/pfctl/pfctl_qstats.c | 44 | ||||
-rw-r--r-- | contrib/pf/pfctl/pfctl_table.c | 23 | ||||
-rw-r--r-- | contrib/pf/pflogd/pflogd.c | 14 | ||||
-rw-r--r-- | contrib/pf/pflogd/pidfile.c | 3 |
12 files changed, 94 insertions, 118 deletions
diff --git a/contrib/pf/authpf/authpf.c b/contrib/pf/authpf/authpf.c index 09d0ac3..ed3d172 100644 --- a/contrib/pf/authpf/authpf.c +++ b/contrib/pf/authpf/authpf.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. */ -#include <sys/types.h> +#include <sys/param.h> #include <sys/file.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -50,9 +50,6 @@ #include "pathnames.h" -#if defined(__FreeBSD__) -#define __dead __volatile -#endif extern int symset(const char *, const char *, int); static int read_config(FILE *); @@ -77,7 +74,11 @@ struct timeval Tstart, Tend; /* start and end times of session */ volatile sig_atomic_t want_death; static void need_death(int signo); +#ifdef __FreeBSD__ +static __dead2 void do_death(int); +#else static __dead void do_death(int); +#endif /* * User shell for authenticating gateways. Sole purpose is to allow @@ -289,9 +290,8 @@ dogdeath: sleep(180); /* them lusers read reaaaaal slow */ die: do_death(0); -#if defined(__FreeBSD__) - return 0; /* gcc hack to prevent warning */ -#endif + + /* NOTREACHED */ } /* @@ -730,7 +730,11 @@ need_death(int signo) /* * function that removes our stuff when we go away. */ +#ifdef __FreeBSD__ +static __dead2 void +#else static __dead void +#endif do_death(int active) { int ret = 0; diff --git a/contrib/pf/ftp-proxy/ftp-proxy.c b/contrib/pf/ftp-proxy/ftp-proxy.c index 2c44431..03c3777 100644 --- a/contrib/pf/ftp-proxy/ftp-proxy.c +++ b/contrib/pf/ftp-proxy/ftp-proxy.c @@ -69,7 +69,6 @@ */ #include <sys/param.h> -#include <sys/types.h> #include <sys/time.h> #include <sys/socket.h> diff --git a/contrib/pf/pfctl/parse.y b/contrib/pf/pfctl/parse.y index 83c5165..5218cc1 100644 --- a/contrib/pf/pfctl/parse.y +++ b/contrib/pf/pfctl/parse.y @@ -49,6 +49,7 @@ #include <string.h> #include <ctype.h> #include <err.h> +#include <limits.h> #include <pwd.h> #include <grp.h> #include <md5.h> @@ -56,7 +57,7 @@ #include "pfctl_parser.h" #include "pfctl.h" -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ #define HTONL(x) (x) = htonl((__uint32_t)(x)) #endif diff --git a/contrib/pf/pfctl/pfctl.c b/contrib/pf/pfctl/pfctl.c index 9a8fed8..cd07433 100644 --- a/contrib/pf/pfctl/pfctl.c +++ b/contrib/pf/pfctl/pfctl.c @@ -37,12 +37,6 @@ #include <net/if.h> #include <netinet/in.h> -#if defined(__FreeBSD__) -#include <inttypes.h> -#include <net/route.h> -#else -#define PRIu64 "llu" -#endif #include <net/pfvar.h> #include <arpa/inet.h> #include <altq/altq.h> @@ -201,7 +195,7 @@ pfctl_enable(int dev, int opts) if (ioctl(dev, DIOCSTART)) { if (errno == EEXIST) errx(1, "pf already enabled"); -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ else if (errno == ESRCH) errx(1, "pfil registeration failed"); #endif @@ -554,10 +548,11 @@ pfctl_print_rule_counters(struct pf_rule *rule, int opts) rule->qname, rule->qid, rule->pqname, rule->pqid); } if (opts & PF_OPT_VERBOSE) - printf(" [ Evaluations: %-8"PRIu64" Packets: %-8"PRIu64" " - "Bytes: %-10"PRIu64" States: %-6u]\n", - rule->evaluations, rule->packets, - rule->bytes, rule->states); + printf(" [ Evaluations: %-8llu Packets: %-8llu " + "Bytes: %-10llu States: %-6u]\n", + (unsigned long long)rule->evaluations, + (unsigned long long)rule->packets, + (unsigned long long)rule->bytes, rule->states); } int @@ -619,9 +614,10 @@ pfctl_show_rules(int dev, int opts, int format, char *anchorname, case 1: if (pr.rule.label[0]) { printf("%s ", pr.rule.label); - printf("%"PRIu64" %"PRIu64" %"PRIu64"\n", - pr.rule.evaluations, pr.rule.packets, - pr.rule.bytes); + printf("%llu %llu %llu\n", + (unsigned long long)pr.rule.evaluations, + (unsigned long long)pr.rule.packets, + (unsigned long long)pr.rule.bytes); } break; default: @@ -651,9 +647,10 @@ pfctl_show_rules(int dev, int opts, int format, char *anchorname, case 1: if (pr.rule.label[0]) { printf("%s ", pr.rule.label); - printf("%"PRIu64" %"PRIu64" %"PRIu64"\n", - pr.rule.evaluations, pr.rule.packets, - pr.rule.bytes); + printf("%llu %llu %llu\n", + (unsigned long long)pr.rule.evaluations, + (unsigned long long)pr.rule.packets, + (unsigned long long)pr.rule.bytes); } break; default: diff --git a/contrib/pf/pfctl/pfctl.h b/contrib/pf/pfctl/pfctl.h index 8b439b4..8ee1ad4 100644 --- a/contrib/pf/pfctl/pfctl.h +++ b/contrib/pf/pfctl/pfctl.h @@ -83,7 +83,7 @@ int pfctl_command_tables(int, char *[], char *, const char *, char *, int pfctl_show_altq(int, int, int); void warn_namespace_collision(const char *); -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ extern int altqsupport; #endif diff --git a/contrib/pf/pfctl/pfctl_altq.c b/contrib/pf/pfctl/pfctl_altq.c index baead1c..8232710 100644 --- a/contrib/pf/pfctl/pfctl_altq.c +++ b/contrib/pf/pfctl/pfctl_altq.c @@ -19,12 +19,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/types.h> +#include <sys/param.h> #include <sys/ioctl.h> #include <sys/socket.h> -#if !defined(__FreeBSD__) -#include <sys/limits.h> -#endif #include <net/if.h> #include <netinet/in.h> @@ -32,6 +29,7 @@ #include <err.h> #include <errno.h> +#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> @@ -77,7 +75,7 @@ static int gsc_add_seg(struct gen_sc *, double, double, double, double); static double sc_x2y(struct service_curve *, double); -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ u_int32_t getifspeed(int, char *); #else u_int32_t getifspeed(char *); @@ -246,7 +244,7 @@ eval_pfaltq(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw, if (bw->bw_absolute > 0) pa->ifbandwidth = bw->bw_absolute; else -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ if ((rate = getifspeed(pf->dev, pa->ifname)) == 0) { #else if ((rate = getifspeed(pa->ifname)) == 0) { @@ -880,12 +878,7 @@ print_hfsc_opts(const struct pf_altq *a, const struct node_queue_opt *qopts) /* * admission control using generalized service curve */ -#if defined(__FreeBSD__) -#if defined(INFINITY) -#undef INFINITY -#endif -#define INFINITY HUGE_VAL /* positive infinity defined in <math.h> */ -#else +#ifndef INFINITY #define INFINITY HUGE_VAL /* positive infinity defined in <math.h> */ #endif @@ -1088,10 +1081,10 @@ rate2str(double rate) return (buf); } -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ /* * XXX - * FreeBSD do not have SIOCGIFDATA. + * FreeBSD does not have SIOCGIFDATA. * To emulate this, DIOCGIFSPEED ioctl added to pf. */ u_int32_t diff --git a/contrib/pf/pfctl/pfctl_parser.c b/contrib/pf/pfctl/pfctl_parser.c index de76cc7..52b00bb 100644 --- a/contrib/pf/pfctl/pfctl_parser.c +++ b/contrib/pf/pfctl/pfctl_parser.c @@ -46,19 +46,13 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <limits.h> #include <netdb.h> #include <stdarg.h> #include <errno.h> #include <err.h> #include <ifaddrs.h> -#if defined(__FreeBSD__) -#include <inttypes.h> -#else -#define PRIu64 "llu" -#define PRId64 "lld" -#endif - #include "pfctl_parser.h" #include "pfctl.h" @@ -511,30 +505,32 @@ print_status(struct pf_status *s) if (s->ifname[0] != 0) { printf("Interface Stats for %-16s %5s %16s\n", s->ifname, "IPv4", "IPv6"); - printf(" %-25s %14"PRIu64" %16"PRIu64"\n", "Bytes In", - s->bcounters[0][0], s->bcounters[1][0]); - printf(" %-25s %14"PRIu64" %16"PRIu64"\n", "Bytes Out", - s->bcounters[0][1], s->bcounters[1][1]); + printf(" %-25s %14llu %16llu\n", "Bytes In", + (unsigned long long)s->bcounters[0][0], + (unsigned long long)s->bcounters[1][0]); + printf(" %-25s %14llu %16llu\n", "Bytes Out", + (unsigned long long)s->bcounters[0][1], + (unsigned long long)s->bcounters[1][1]); printf(" Packets In\n"); - printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Passed", - s->pcounters[0][0][PF_PASS], - s->pcounters[1][0][PF_PASS]); - printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Blocked", - s->pcounters[0][0][PF_DROP], - s->pcounters[1][0][PF_DROP]); + printf(" %-23s %14llu %16llu\n", "Passed", + (unsigned long long)s->pcounters[0][0][PF_PASS], + (unsigned long long)s->pcounters[1][0][PF_PASS]); + printf(" %-23s %14llu %16llu\n", "Blocked", + (unsigned long long)s->pcounters[0][0][PF_DROP], + (unsigned long long)s->pcounters[1][0][PF_DROP]); printf(" Packets Out\n"); - printf(" %-23s %14"PRIu64" %16"PRIu64"\n", "Passed", - s->pcounters[0][1][PF_PASS], - s->pcounters[1][1][PF_PASS]); - printf(" %-23s %14"PRIu64" %16"PRIu64"\n\n", "Blocked", - s->pcounters[0][1][PF_DROP], - s->pcounters[1][1][PF_DROP]); + printf(" %-23s %14llu %16llu\n", "Passed", + (unsigned long long)s->pcounters[0][1][PF_PASS], + (unsigned long long)s->pcounters[1][1][PF_PASS]); + printf(" %-23s %14llu %16llu\n\n", "Blocked", + (unsigned long long)s->pcounters[0][1][PF_DROP], + (unsigned long long)s->pcounters[1][1][PF_DROP]); } printf("%-27s %14s %16s\n", "State Table", "Total", "Rate"); printf(" %-25s %14u %14s\n", "current entries", s->states, ""); for (i = 0; i < FCNT_MAX; i++) { - printf(" %-25s %14"PRIu64" ", pf_fcounters[i], - s->fcounters[i]); + printf(" %-25s %14llu ", pf_fcounters[i], + (unsigned long long)s->fcounters[i]); if (runtime > 0) printf("%14.1f/s\n", (double)s->fcounters[i] / (double)runtime); @@ -543,8 +539,8 @@ print_status(struct pf_status *s) } printf("Counters\n"); for (i = 0; i < PFRES_MAX; i++) { - printf(" %-25s %14"PRIu64" ", pf_reasons[i], - s->counters[i]); + printf(" %-25s %14llu ", pf_reasons[i], + (unsigned long long)s->counters[i]); if (runtime > 0) printf("%14.1f/s\n", (double)s->counters[i] / (double)runtime); diff --git a/contrib/pf/pfctl/pfctl_parser.h b/contrib/pf/pfctl/pfctl_parser.h index e866bd8..47e60ee 100644 --- a/contrib/pf/pfctl/pfctl_parser.h +++ b/contrib/pf/pfctl/pfctl_parser.h @@ -135,7 +135,7 @@ struct node_queue_opt { } data; }; -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ /* * XXX * Absolutely this is not correct location to define this. diff --git a/contrib/pf/pfctl/pfctl_qstats.c b/contrib/pf/pfctl/pfctl_qstats.c index ea4b6f5..5d65ebc 100644 --- a/contrib/pf/pfctl/pfctl_qstats.c +++ b/contrib/pf/pfctl/pfctl_qstats.c @@ -37,12 +37,6 @@ #include <altq/altq_priq.h> #include <altq/altq_hfsc.h> -#if defined(__FreeBSD__) -#include <inttypes.h> -#else -#define PRIu64 "llu" -#endif - #include "pfctl.h" #include "pfctl_parser.h" @@ -92,7 +86,7 @@ pfctl_show_altq(int dev, int opts, int verbose2) { struct pf_altq_node *root = NULL, *node; -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ if (!altqsupport) return (-1); #endif @@ -286,12 +280,12 @@ pfctl_print_altq_nodestat(int dev, const struct pf_altq_node *a) void print_cbqstats(struct queue_stats cur) { - printf(" [ pkts: %10"PRIu64" bytes: %10"PRIu64" " - "dropped pkts: %6"PRIu64" bytes: %6"PRIu64" ]\n", - cur.data.cbq_stats.xmit_cnt.packets, - cur.data.cbq_stats.xmit_cnt.bytes, - cur.data.cbq_stats.drop_cnt.packets, - cur.data.cbq_stats.drop_cnt.bytes); + printf(" [ pkts: %10llu bytes: %10llu " + "dropped pkts: %6llu bytes: %6llu ]\n", + (unsigned long long)cur.data.cbq_stats.xmit_cnt.packets, + (unsigned long long)cur.data.cbq_stats.xmit_cnt.bytes, + (unsigned long long)cur.data.cbq_stats.drop_cnt.packets, + (unsigned long long)cur.data.cbq_stats.drop_cnt.bytes); printf(" [ qlength: %3d/%3d borrows: %6u suspends: %6u ]\n", cur.data.cbq_stats.qcnt, cur.data.cbq_stats.qmax, cur.data.cbq_stats.borrows, cur.data.cbq_stats.delays); @@ -307,12 +301,12 @@ print_cbqstats(struct queue_stats cur) void print_priqstats(struct queue_stats cur) { - printf(" [ pkts: %10"PRIu64" bytes: %10"PRIu64" " - "dropped pkts: %6"PRIu64" bytes: %6"PRIu64" ]\n", - cur.data.priq_stats.xmitcnt.packets, - cur.data.priq_stats.xmitcnt.bytes, - cur.data.priq_stats.dropcnt.packets, - cur.data.priq_stats.dropcnt.bytes); + printf(" [ pkts: %10llu bytes: %10llu " + "dropped pkts: %6llu bytes: %6llu ]\n", + (unsigned long long)cur.data.priq_stats.xmitcnt.packets, + (unsigned long long)cur.data.priq_stats.xmitcnt.bytes, + (unsigned long long)cur.data.priq_stats.dropcnt.packets, + (unsigned long long)cur.data.priq_stats.dropcnt.bytes); printf(" [ qlength: %3d/%3d ]\n", cur.data.priq_stats.qlength, cur.data.priq_stats.qlimit); @@ -327,12 +321,12 @@ print_priqstats(struct queue_stats cur) void print_hfscstats(struct queue_stats cur) { - printf(" [ pkts: %10"PRIu64" bytes: %10"PRIu64" " - "dropped pkts: %6"PRIu64" bytes: %6"PRIu64" ]\n", - cur.data.hfsc_stats.xmit_cnt.packets, - cur.data.hfsc_stats.xmit_cnt.bytes, - cur.data.hfsc_stats.drop_cnt.packets, - cur.data.hfsc_stats.drop_cnt.bytes); + printf(" [ pkts: %10llu bytes: %10llu " + "dropped pkts: %6llu bytes: %6llu ]\n", + (unsigned long long)cur.data.hfsc_stats.xmit_cnt.packets, + (unsigned long long)cur.data.hfsc_stats.xmit_cnt.bytes, + (unsigned long long)cur.data.hfsc_stats.drop_cnt.packets, + (unsigned long long)cur.data.hfsc_stats.drop_cnt.bytes); printf(" [ qlength: %3d/%3d ]\n", cur.data.hfsc_stats.qlength, cur.data.hfsc_stats.qlimit); diff --git a/contrib/pf/pfctl/pfctl_table.c b/contrib/pf/pfctl/pfctl_table.c index 1764750..3796e1e 100644 --- a/contrib/pf/pfctl/pfctl_table.c +++ b/contrib/pf/pfctl/pfctl_table.c @@ -49,12 +49,6 @@ #include <string.h> #include <time.h> -#if defined(__FreeBSD__) -#include <inttypes.h> -#else -#define PRIu64 "llu" -#endif - #include "pfctl_parser.h" #include "pfctl.h" @@ -354,14 +348,15 @@ print_tstats(struct pfr_tstats *ts, int debug) printf("\tReferences: [ Anchors: %-18d Rules: %-18d ]\n", ts->pfrts_refcnt[PFR_REFCNT_ANCHOR], ts->pfrts_refcnt[PFR_REFCNT_RULE]); - printf("\tEvaluations: [ NoMatch: %-18"PRIu64" Match: %-18"PRIu64" ]\n", - ts->pfrts_nomatch, ts->pfrts_match); + printf("\tEvaluations: [ NoMatch: %-18llu Match: %-18llu ]\n", + (unsigned long long)ts->pfrts_nomatch, + (unsigned long long)ts->pfrts_match); for (dir = 0; dir < PFR_DIR_MAX; dir++) for (op = 0; op < PFR_OP_TABLE_MAX; op++) - printf("\t%-12s [ Packets: %-18"PRIu64" Bytes: %-18"PRIu64" ]\n", + printf("\t%-12s [ Packets: %-18llu Bytes: %-18llu ]\n", stats_text[dir][op], - ts->pfrts_packets[dir][op], - ts->pfrts_bytes[dir][op]); + (unsigned long long)ts->pfrts_packets[dir][op], + (unsigned long long)ts->pfrts_bytes[dir][op]); } int @@ -436,10 +431,10 @@ print_astats(struct pfr_astats *as, int dns) printf("\tCleared: %s", ctime(&time)); for (dir = 0; dir < PFR_DIR_MAX; dir++) for (op = 0; op < PFR_OP_ADDR_MAX; op++) - printf("\t%-12s [ Packets: %-18"PRIu64" Bytes: %-18"PRIu64" ]\n", + printf("\t%-12s [ Packets: %-18llu Bytes: %-18llu ]\n", stats_text[dir][op], - as->pfras_packets[dir][op], - as->pfras_bytes[dir][op]); + (unsigned long long)as->pfras_packets[dir][op], + (unsigned long long)as->pfras_bytes[dir][op]); } void diff --git a/contrib/pf/pflogd/pflogd.c b/contrib/pf/pflogd/pflogd.c index 10d8816..6ed5f9f 100644 --- a/contrib/pf/pflogd/pflogd.c +++ b/contrib/pf/pflogd/pflogd.c @@ -45,16 +45,12 @@ #include <errno.h> #include <stdarg.h> #include <fcntl.h> -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ #include "pidfile.h" #else #include <util.h> #endif -#if defined(__FreeBSD__) -#define __dead __volatile -#endif - #define DEF_SNAPLEN 116 /* default plus allow for larger header of pflog */ #define PCAP_TO_MS 500 /* pcap read timeout (ms) */ #define PCAP_NUM_PKTS 1000 /* max number of packets to process at each loop */ @@ -88,11 +84,7 @@ int reset_dump(void); void sig_alrm(int); void sig_close(int); void sig_hup(int); -#if defined(__FreeBSD__) -__volatile void usage(void); -#else void usage(void); -#endif char * @@ -135,7 +127,11 @@ logmsg(int pri, const char *message, ...) va_end(ap); } +#ifdef __FreeBSD__ +__dead2 void +#else __dead void +#endif usage(void) { fprintf(stderr, "usage: pflogd [-D] [-d delay] [-f filename] "); diff --git a/contrib/pf/pflogd/pidfile.c b/contrib/pf/pflogd/pidfile.c index 61eca26..db6007f 100644 --- a/contrib/pf/pflogd/pidfile.c +++ b/contrib/pf/pflogd/pidfile.c @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* $OpenBSD: pidfile.c,v 1.5 2002/05/26 09:29:02 deraadt Exp $ */ /* $NetBSD: pidfile.c,v 1.4 2001/02/19 22:43:42 cgd Exp $ */ @@ -47,7 +48,7 @@ static const char rcsid[] = "$OpenBSD: pidfile.c,v 1.5 2002/05/26 09:29:02 deraa #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#if defined(__FreeBSD__) +#ifdef __FreeBSD__ #include "pidfile.h" #else #include <util.h> |