From: Arran Cudbard-Bell Date: Mon, 4 Mar 2013 23:33:37 +0000 (-0500) Subject: Whitespace fixes X-Git-Tag: release_2_2_1~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ea7f50f49fc91bef42a91f7de9960f582cf254c;p=thirdparty%2Ffreeradius-server.git Whitespace fixes --- diff --git a/src/lib/dhcp.c b/src/lib/dhcp.c index 05e3ec1f250..b4fc2f52cf6 100644 --- a/src/lib/dhcp.c +++ b/src/lib/dhcp.c @@ -222,7 +222,7 @@ RADIUS_PACKET *fr_dhcp_recv(int sockfd) fr_strerror_printf("Failed allocating packet"); return NULL; } - memset(packet, 0, sizeof(packet)); + memset(packet, 0, sizeof(*packet)); packet->data = malloc(MAX_PACKET_SIZE); if (!packet->data) { @@ -251,7 +251,7 @@ RADIUS_PACKET *fr_dhcp_recv(int sockfd) if (packet->data_len < MIN_PACKET_SIZE) { fr_strerror_printf("DHCP packet is too small (%d < %d)", - packet->data_len, MIN_PACKET_SIZE); + packet->data_len, MIN_PACKET_SIZE); rad_free(&packet); return NULL; } @@ -334,7 +334,11 @@ RADIUS_PACKET *fr_dhcp_recv(int sockfd) /* * This should never fail... */ - getsockname(sockfd, (struct sockaddr *) &dst, &sizeof_dst); + if (getsockname(sockfd, (struct sockaddr *) &dst, &sizeof_dst) < 0) { + fr_strerror_printf("getsockname failed: %s", strerror(errno)); + rad_free(&packet); + return NULL; + } #endif fr_sockaddr2ipaddr(&dst, sizeof_dst, &packet->dst_ipaddr, &port); @@ -430,12 +434,12 @@ int fr_dhcp_send(RADIUS_PACKET *packet) * Assume that the packet is encoded before sending it. */ return sendto(packet->sockfd, packet->data, packet->data_len, 0, - (struct sockaddr *)&dst, sizeof_dst); + (struct sockaddr *)&dst, sizeof_dst); #else return sendfromto(packet->sockfd, packet->data, packet->data_len, 0, - (struct sockaddr *)&src, sizeof_src, - (struct sockaddr *)&dst, sizeof_dst); + (struct sockaddr *)&src, sizeof_src, + (struct sockaddr *)&dst, sizeof_dst); #endif } @@ -531,7 +535,10 @@ static int fr_dhcp_attr2vp(VALUE_PAIR *vp, const uint8_t *p, size_t alen) case PW_TYPE_IPADDR: if (alen != 4) goto raw; - memcpy(&vp->vp_ipaddr, p , 4); /* Keep value in Network Order!!! */ + /* + * Keep value in Network Order! + */ + memcpy(&vp->vp_ipaddr, p , 4); vp->length = 4; break; @@ -774,8 +781,8 @@ int fr_dhcp_decode(RADIUS_PACKET *packet) */ /* - * Nothing uses tail after this call, if it does in the future - * it'll need to find the new tail... + * Nothing uses tail after this call, if it does in the future + * it'll need to find the new tail... * FIXME: This should also check sname && file fields. * See the dhcp_get_option() function above. */ @@ -1326,7 +1333,7 @@ int fr_dhcp_encode(RADIUS_PACKET *packet) } /* - * Jump over DHCP magic number, response, etc. + * Jump over DHCP magic number, response, etc. */ p = pp; }