aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2018-06-24 13:23:27 +0000
committerEitan Adler <eadler@FreeBSD.org>2018-06-24 13:23:27 +0000
commit71c6c44d8d2b62f4e1b6bb5b12fa252314ef116a (patch)
treed9000d0d851f2c727d574c99bc8a660ce3831d77 /sbin
parent8d3f65e7673045c0d2f828bec00a0bab94b8af20 (diff)
downloadsrc-71c6c44d8d2b62f4e1b6bb5b12fa252314ef116a.tar.gz
src-71c6c44d8d2b62f4e1b6bb5b12fa252314ef116a.zip
dhclient: build with WARNS=6
- add static in a number of places - initialize __progname rather than rely on magical extern values - use nitems() instead of manually spelling it out - unshadow 'idi' - teach 'error' that it is '__dead2' - add missing 'break'
Notes
Notes: svn path=/head/; revision=335602
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/Makefile1
-rw-r--r--sbin/dhclient/bpf.c8
-rw-r--r--sbin/dhclient/clparse.c5
-rw-r--r--sbin/dhclient/conflex.c5
-rw-r--r--sbin/dhclient/dhclient.c33
-rw-r--r--sbin/dhclient/dhcpd.h4
-rw-r--r--sbin/dhclient/dispatch.c4
-rw-r--r--sbin/dhclient/options.c4
-rw-r--r--sbin/dhclient/privsep.c6
-rw-r--r--sbin/dhclient/privsep.h5
10 files changed, 37 insertions, 38 deletions
diff --git a/sbin/dhclient/Makefile b/sbin/dhclient/Makefile
index fb72f5f03a8e..dbba0d41226a 100644
--- a/sbin/dhclient/Makefile
+++ b/sbin/dhclient/Makefile
@@ -50,7 +50,6 @@ LIBADD+= cap_syslog
CFLAGS+=-DWITH_CASPER
.endif
-WARNS?= 4
NO_WCAST_ALIGN= yes
HAS_TESTS=
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index a9da1f0a5a9f..3fe76f6e5579 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -95,7 +95,7 @@ if_register_bpf(struct interface_info *info, int flags)
* Packet write filter program:
* 'ip and udp and src port bootps and dst port (bootps or bootpc)'
*/
-struct bpf_insn dhcp_bpf_wfilter[] = {
+static struct bpf_insn dhcp_bpf_wfilter[] = {
BPF_STMT(BPF_LD + BPF_B + BPF_IND, 14),
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, (IPVERSION << 4) + 5, 0, 12),
@@ -129,7 +129,7 @@ struct bpf_insn dhcp_bpf_wfilter[] = {
BPF_STMT(BPF_RET+BPF_K, 0),
};
-int dhcp_bpf_wfilter_len = sizeof(dhcp_bpf_wfilter) / sizeof(struct bpf_insn);
+static int dhcp_bpf_wfilter_len = nitems(dhcp_bpf_wfilter);
void
if_register_send(struct interface_info *info)
@@ -184,7 +184,7 @@ if_register_send(struct interface_info *info)
* XXX: Changes to the filter program may require changes to the
* constant offsets used in if_register_send to patch the BPF program!
*/
-struct bpf_insn dhcp_bpf_filter[] = {
+static struct bpf_insn dhcp_bpf_filter[] = {
/* Make sure this is an IP packet... */
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12),
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 8),
@@ -211,7 +211,7 @@ struct bpf_insn dhcp_bpf_filter[] = {
BPF_STMT(BPF_RET+BPF_K, 0),
};
-int dhcp_bpf_filter_len = sizeof(dhcp_bpf_filter) / sizeof(struct bpf_insn);
+static int dhcp_bpf_filter_len = nitems(dhcp_bpf_filter);
void
if_register_receive(struct interface_info *info)
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 2090aa9698ea..66695fd6b8f0 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -49,10 +49,9 @@ __FBSDID("$FreeBSD$");
#include "dhctoken.h"
struct client_config top_level_config;
-struct interface_info *dummy_interfaces;
-extern struct interface_info *ifi;
+static struct interface_info *dummy_interfaces;
-char client_script_name[] = "/sbin/dhclient-script";
+static char client_script_name[] = "/sbin/dhclient-script";
/*
* client-conf-file :== client-declarations EOF
diff --git a/sbin/dhclient/conflex.c b/sbin/dhclient/conflex.c
index 9823830472c2..66fc9e397125 100644
--- a/sbin/dhclient/conflex.c
+++ b/sbin/dhclient/conflex.c
@@ -53,8 +53,8 @@ __FBSDID("$FreeBSD$");
int lexline;
int lexchar;
char *token_line;
-char *prev_line;
-char *cur_line;
+static char *prev_line;
+static char *cur_line;
const char *tlname;
int eol_token;
@@ -347,6 +347,7 @@ intern(char *atom, int dfv)
return (BOOTING);
if (!strcasecmp(atom + 1, "oot-unknown-clients"))
return (BOOT_UNKNOWN_CLIENTS);
+ break;
case 'c':
if (!strcasecmp(atom + 1, "lass"))
return (CLASS);
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 37fd46abbba1..c92b5f1dd132 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -65,9 +65,11 @@ __FBSDID("$FreeBSD$");
#include <sys/endian.h>
#include <capsicum_helpers.h>
+#include <libgen.h>
#include <net80211/ieee80211_freebsd.h>
+
#ifndef _PATH_VAREMPTY
#define _PATH_VAREMPTY "/var/empty"
#endif
@@ -91,21 +93,21 @@ __FBSDID("$FreeBSD$");
cap_channel_t *capsyslog;
time_t cur_time;
-time_t default_lease_time = 43200; /* 12 hours... */
+static time_t default_lease_time = 43200; /* 12 hours... */
const char *path_dhclient_conf = _PATH_DHCLIENT_CONF;
char *path_dhclient_db = NULL;
int log_perror = 1;
-int privfd;
-int nullfd = -1;
+static int privfd;
+static int nullfd = -1;
-char hostname[_POSIX_HOST_NAME_MAX + 1];
+static char hostname[_POSIX_HOST_NAME_MAX + 1];
-struct iaddr iaddr_broadcast = { 4, { 255, 255, 255, 255 } };
-struct in_addr inaddr_any, inaddr_broadcast;
+static struct iaddr iaddr_broadcast = { 4, { 255, 255, 255, 255 } };
+static struct in_addr inaddr_any, inaddr_broadcast;
-char *path_dhclient_pidfile;
+static char *path_dhclient_pidfile;
struct pidfh *pidfile;
/*
@@ -121,9 +123,9 @@ struct pidfh *pidfile;
#define TIME_MAX ((((time_t) 1 << (sizeof(time_t) * CHAR_BIT - 2)) - 1) * 2 + 1)
int log_priority;
-int no_daemon;
-int unknown_ok = 1;
-int routefd;
+static int no_daemon;
+static int unknown_ok = 1;
+static int routefd;
struct interface_info *ifi;
@@ -147,6 +149,7 @@ int fork_privchld(int, int);
#define MIN_MTU 68
static time_t scripttime;
+static char *__progname;
int
findproto(char *cp, int n)
@@ -197,8 +200,8 @@ get_ifa(char *cp, int n)
return (NULL);
}
-struct iaddr defaddr = { .len = 4 };
-uint8_t curbssid[6];
+static struct iaddr defaddr = { .len = 4 };
+static uint8_t curbssid[6];
static void
disassoc(void *arg)
@@ -369,7 +372,6 @@ init_casper(void)
int
main(int argc, char *argv[])
{
- extern char *__progname;
int ch, fd, quiet = 0, i = 0;
int pipe_fd[2];
int immediate_daemon = 0;
@@ -377,6 +379,8 @@ main(int argc, char *argv[])
pid_t otherpid;
cap_rights_t rights;
+ __progname = basename(argv[0]);
+
init_casper();
/* Initially, log errors to stderr as well as to syslogd. */
@@ -561,7 +565,6 @@ main(int argc, char *argv[])
void
usage(void)
{
- extern char *__progname;
fprintf(stderr, "usage: %s [-bdqu] ", __progname);
fprintf(stderr, "[-c conffile] [-l leasefile] interface\n");
@@ -1903,7 +1906,7 @@ free_client_lease(struct client_lease *lease)
free(lease);
}
-FILE *leaseFile;
+static FILE *leaseFile;
void
rewrite_client_leases(void)
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 8f9071aaeba6..240a3ae23bda 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -265,7 +265,7 @@ void do_packet(struct interface_info *, struct dhcp_packet *,
/* errwarn.c */
extern int warnings_occurred;
-void error(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
+void error(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))) __dead2;
int warning(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
int note(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
int debug(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
@@ -369,6 +369,8 @@ extern struct client_config top_level_config;
extern struct pidfh *pidfile;
+extern struct interface_info *ifi;
+
void dhcpoffer(struct packet *);
void dhcpack(struct packet *);
void dhcpnak(struct packet *);
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index ae3f0052d396..48960f3a2e39 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -57,8 +57,8 @@ __FBSDID("$FreeBSD$");
/* Assert that pointer p is aligned to at least align bytes */
#define assert_aligned(p, align) assert((((uintptr_t)p) & ((align) - 1)) == 0)
-struct protocol *protocols;
-struct timeout *timeouts;
+static struct protocol *protocols;
+static struct timeout *timeouts;
static struct timeout *free_timeouts;
static int interfaces_invalidated;
void (*bootp_packet_handler)(struct interface_info *,
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c
index f29a8b8f6fc8..3b05e3ff1889 100644
--- a/sbin/dhclient/options.c
+++ b/sbin/dhclient/options.c
@@ -50,8 +50,8 @@ __FBSDID("$FreeBSD$");
#define DHCP_OPTION_DATA
#include "dhcpd.h"
-int bad_options = 0;
-int bad_options_max = 5;
+static int bad_options = 0;
+static int bad_options_max = 5;
void parse_options(struct packet *);
void parse_option_buffer(struct packet *, unsigned char *, int);
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index 9943898b278a..a286b6900808 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -102,7 +102,7 @@ buf_read(int sock, void *buf, size_t nbytes)
}
void
-dispatch_imsg(struct interface_info *ifi, int fd)
+dispatch_imsg(struct interface_info *ifix, int fd)
{
struct imsg_hdr hdr;
char *medium, *reason, *filename,
@@ -235,14 +235,14 @@ dispatch_imsg(struct interface_info *ifi, int fd)
error("buf_close: %m");
break;
case IMSG_SEND_PACKET:
- send_packet_priv(ifi, &hdr, fd);
+ send_packet_priv(ifix, &hdr, fd);
break;
case IMSG_SET_INTERFACE_MTU:
if (hdr.len < sizeof(hdr) + sizeof(u_int16_t))
error("corrupted message received");
buf_read(fd, &mtu, sizeof(u_int16_t));
- interface_set_mtu_priv(ifi->name, mtu);
+ interface_set_mtu_priv(ifix->name, mtu);
break;
default:
error("received unknown message, code %d", hdr.code);
diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h
index 41b8267ee2ef..db6ec9b4acea 100644
--- a/sbin/dhclient/privsep.h
+++ b/sbin/dhclient/privsep.h
@@ -44,8 +44,3 @@ struct imsg_hdr {
enum imsg_code code;
size_t len;
};
-
-struct buf *buf_open(size_t);
-int buf_add(struct buf *, const void *, size_t);
-int buf_close(int, struct buf *);
-ssize_t buf_read(int sock, void *, size_t);