[klibc] valgrind ipconfig work
maximilian attems
max at stro.at
Mon Apr 26 06:01:33 PDT 2010
this is just on the common path, need to checkout others too,
but a start:
commit 5501109f6597f2bbed17a264b247c36220362dfb
Author: maximilian attems <max at stro.at>
Date: Mon Apr 26 08:07:51 2010 +0200
[klibc] ipconfig: Fix valgrind errors
valgrind was rightfully complaining on ipconfig eth0:
ERROR SUMMARY: 5 errors from 4 contexts (suppressed: 0 from 0)
all errors where stack allocations pointing to unitialized values,
now:
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0
as bonus cleanup a bit coding style of packet_send().
Signed-off-by: maximilian attems <max at stro.at>
diff --git a/usr/kinit/ipconfig/netdev.c b/usr/kinit/ipconfig/netdev.c
index 6e3014f..e203d0c 100644
--- a/usr/kinit/ipconfig/netdev.c
+++ b/usr/kinit/ipconfig/netdev.c
@@ -43,6 +43,7 @@ static int netdev_sif_addr(struct ifreq *ifr, int cmd, uint32_t addr)
{
struct sockaddr_in sin;
+ memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = addr;
diff --git a/usr/kinit/ipconfig/packet.c b/usr/kinit/ipconfig/packet.c
index 508c7ba..4df5431 100644
--- a/usr/kinit/ipconfig/packet.c
+++ b/usr/kinit/ipconfig/packet.c
@@ -114,16 +114,18 @@ static char *ntoa(uint32_t addr)
int packet_send(struct netdev *dev, struct iovec *iov, int iov_len)
{
struct sockaddr_ll sll;
- struct msghdr msg = {
- .msg_name = &sll,
- .msg_namelen = sizeof(sll),
- .msg_iov = iov,
- .msg_iovlen = iov_len,
- .msg_control = NULL,
- .msg_controllen = 0,
- .msg_flags = 0
- };
int i, len = 0;
+ struct msghdr msg;
+
+ memset(&sll, 0, sizeof(sll));
+
+ msg.msg_name = &sll;
+ msg.msg_namelen = sizeof(sll);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = iov_len;
+ msg.msg_control = NULL;
+ msg.msg_controllen = 0;
+ msg.msg_flags = 0;
if (cfg_local_port != LOCAL_PORT) {
ipudp_hdrs.udp.source = htons(cfg_local_port);
More information about the klibc
mailing list