sdhcp

simple dhcp client
git clone git://git.2f30.org/sdhcp
Log | Files | Refs | LICENSE

commit 983d3375adcee59bf8acc476e0e6260bcbb88ce8
parent b97fe80b0c80d16802031d321f8aeb4f642ba37a
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri, 25 Apr 2014 22:07:25 +0200

fix remaining warnings

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>

Diffstat:
Msdhcp.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/sdhcp.c b/sdhcp.c @@ -145,10 +145,13 @@ udprecv(unsigned char ip[4], int fd, void *data, size_t n) { static void setip(unsigned char ip[4], unsigned char mask[4], unsigned char gateway[4]) { - struct ifreq ifreq = { 0, }; - struct rtentry rtreq = { 0, }; + struct ifreq ifreq; + struct rtentry rtreq; int fd; + memset(&ifreq, 0, sizeof(ifreq)); + memset(&rtreq, 0, sizeof(rtreq)); + strlcpy(ifreq.ifr_name, ifname, IF_NAMESIZE); ifreq.ifr_addr = iptoaddr(ip, 0); if((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)) == -1) @@ -256,7 +259,7 @@ dhcpsend(int type, int how) memcpy(bp.chaddr, hwaddr, sizeof bp.chaddr); p = bp.optdata; p = hnoptput(p, ODtype, type, 1); - p = optput(p, ODclientid, cid, strlen(cid)); + p = optput(p, ODclientid, (unsigned char*)cid, strlen(cid)); switch(type) { case DHCPdiscover: @@ -410,7 +413,7 @@ int main(int argc, char *argv[]) { int bcast = 1; - struct ifreq ifreq = {0,}; + struct ifreq ifreq; struct sockaddr addr; int rnd; @@ -434,6 +437,7 @@ main(int argc, char *argv[]) else if(argc == 1) ifname = argv[0]; + memset(&ifreq, 0, sizeof(ifreq)); signal(SIGALRM, nop); signal(SIGTERM, cleanexit);