summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Berger <cedric@cvs.openbsd.org>2003-01-25 23:17:35 +0000
committerCedric Berger <cedric@cvs.openbsd.org>2003-01-25 23:17:35 +0000
commitd70e7c397a12664bda434e9076b904a5b13fae54 (patch)
tree8e56cb38189b4239b1a0eb9fa18a5f81ffc4d164
parent3ba0735ba16e06664688dc066917c7e89fca19bc (diff)
Another nice cleanup patch from Andrey Matveev
KNF + remove/reorg headers.
-rw-r--r--sbin/pfctl/pfctl_radix.c46
-rw-r--r--sbin/pfctl/pfctl_table.c17
2 files changed, 29 insertions, 34 deletions
diff --git a/sbin/pfctl/pfctl_radix.c b/sbin/pfctl/pfctl_radix.c
index e8faa8201f7..ca2582a5e1b 100644
--- a/sbin/pfctl/pfctl_radix.c
+++ b/sbin/pfctl/pfctl_radix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_radix.c,v 1.9 2003/01/20 20:47:10 cedric Exp $ */
+/* $OpenBSD: pfctl_radix.c,v 1.10 2003/01/25 23:17:34 cedric Exp $ */
/*
* Copyright (c) 2002 Cedric Berger
@@ -38,10 +38,8 @@
#include <netinet/in.h>
#include <net/pfvar.h>
-#include <string.h>
#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
+#include <string.h>
#include "pfctl.h"
@@ -68,7 +66,7 @@ pfr_add_tables(struct pfr_table *tbl, int size, int *nadd, int flags)
if (size < 0 || (size && tbl == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -88,7 +86,7 @@ pfr_del_tables(struct pfr_table *tbl, int size, int *ndel, int flags)
if (size < 0 || (size && tbl == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -108,7 +106,7 @@ pfr_get_tables(struct pfr_table *tbl, int *size, int flags)
if (size == NULL || *size < 0 || (*size && tbl == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -127,7 +125,7 @@ pfr_get_tstats(struct pfr_tstats *tbl, int *size, int flags)
if (size == NULL || *size < 0 || (*size && tbl == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -146,7 +144,7 @@ pfr_clr_addrs(struct pfr_table *tbl, int *ndel, int flags)
if (tbl == NULL) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -166,7 +164,7 @@ pfr_add_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
if (tbl == NULL || size < 0 || (size && addr == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -188,7 +186,7 @@ pfr_del_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
if (tbl == NULL || size < 0 || (size && addr == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -210,7 +208,7 @@ pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
if (tbl == NULL || size < 0 || (size && addr == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -233,13 +231,13 @@ pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
int
pfr_get_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int *size,
- int flags)
+ int flags)
{
struct pfioc_table io;
if (tbl == NULL || size == NULL || *size < 0 || (*size && addr == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -254,13 +252,13 @@ pfr_get_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int *size,
int
pfr_get_astats(struct pfr_table *tbl, struct pfr_astats *addr, int *size,
- int flags)
+ int flags)
{
struct pfioc_table io;
if (tbl == NULL || size == NULL || *size < 0 || (*size && addr == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -281,7 +279,7 @@ pfr_clr_astats(struct pfr_table *tbl, struct pfr_addr *addr, int size,
if (tbl == NULL || size < 0 || (size && addr == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -302,7 +300,7 @@ pfr_clr_tstats(struct pfr_table *tbl, int size, int *nzero, int flags)
if (size < 0 || (size && !tbl)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -317,13 +315,13 @@ pfr_clr_tstats(struct pfr_table *tbl, int size, int *nzero, int flags)
int
pfr_set_tflags(struct pfr_table *tbl, int size, int setflag, int clrflag,
- int *nchange, int *ndel, int flags)
+ int *nchange, int *ndel, int flags)
{
struct pfioc_table io;
if (size < 0 || (size && !tbl)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -342,13 +340,13 @@ pfr_set_tflags(struct pfr_table *tbl, int size, int setflag, int clrflag,
int
pfr_tst_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
- int *nmatch, int flags)
+ int *nmatch, int flags)
{
struct pfioc_table io;
if (tbl == NULL || size < 0 || (size && addr == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
@@ -397,13 +395,13 @@ pfr_ina_commit(int ticket, int *nadd, int *nchange, int flags)
int
pfr_ina_define(struct pfr_table *tbl, struct pfr_addr *addr, int size,
- int *nadd, int *naddr, int ticket, int flags)
+ int *nadd, int *naddr, int ticket, int flags)
{
struct pfioc_table io;
if (tbl == NULL || size < 0 || (size && addr == NULL)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
bzero(&io, sizeof io);
io.pfrio_flags = flags;
diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c
index 11268913b32..4b206f10cb8 100644
--- a/sbin/pfctl/pfctl_table.c
+++ b/sbin/pfctl/pfctl_table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_table.c,v 1.28 2003/01/25 18:16:05 cedric Exp $ */
+/* $OpenBSD: pfctl_table.c,v 1.29 2003/01/25 23:17:34 cedric Exp $ */
/*
* Copyright (c) 2002 Cedric Berger
@@ -39,22 +39,19 @@
#include <net/pfvar.h>
#include <arpa/inet.h>
+#include <assert.h>
+#include <ctype.h>
#include <err.h>
#include <errno.h>
-#include <time.h>
-#include <fcntl.h>
-#include <limits.h>
#include <netdb.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <assert.h>
+#include <time.h>
-#include "pfctl.h"
#include "pfctl_parser.h"
+#include "pfctl.h"
#define BUF_SIZE 256
@@ -493,7 +490,7 @@ print_addrx(struct pfr_addr *ad, struct pfr_addr *rad, int dns)
{
char ch, buf[BUF_SIZE] = "{error}";
char fb[] = { ' ', 'M', 'A', 'D', 'C', 'Z', 'X', ' ', 'Y' };
- unsigned fback, hostnet;
+ unsigned int fback, hostnet;
fback = (rad != NULL) ? rad->pfra_fback : ad->pfra_fback;
ch = (fback < sizeof(fb)/sizeof(*fb)) ? fb[fback] : '?';