From f6807f8a6d6c8e1e2928cefe3428d79d56550593 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 10 Sep 2011 11:09:41 +0200 Subject: [PATCH] build: smatch compiler warnings fixed dhcpd-pools.c:221:20: warning: non-ANSI function declaration of function 'prepare_memory' getdata.c +178 parse_leases(112) error: potential null derefence 'macstring'. getdata.c +179 parse_leases(113) error: potential null derefence 'macaddr_p'. Signed-off-by: Sami Kerola --- src/dhcpd-pools.c | 2 +- src/getdata.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 07e3ac5..9a3f344 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -218,7 +218,7 @@ int main(int argc, char **argv) } /* Global allocations, counter resets etc */ -int prepare_memory() +int prepare_memory(void) { RANGES = 64; num_ranges = num_shared_networks = 0; diff --git a/src/getdata.c b/src/getdata.c index 01bf3e9..2946ee0 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -175,12 +175,14 @@ int parse_leases(void) && (sw_active_lease == 1) && (xstrstr(line, " hardware ethernet", 19))) { nth_field(3, macstring, line); - macstring[17] = '\0'; - macaddr_p->ethernet = safe_strdup(macstring); - macaddr_p->ip = safe_strdup(ipstring); - macaddr_p->next = safe_malloc(sizeof(struct macaddr_t)); - macaddr_p = macaddr_p->next; - macaddr_p->next = NULL; + if (macstring) { + macstring[17] = '\0'; + macaddr_p->ethernet = safe_strdup(macstring); + macaddr_p->ip = safe_strdup(ipstring); + macaddr_p->next = safe_malloc(sizeof(struct macaddr_t)); + macaddr_p = macaddr_p->next; + macaddr_p->next = NULL; + } } } free(line);