* eth-multiplexer/vdev.c (add_vdev): Assert the name of the device to be created before copying it into the vdev structure. ---
Hello, On Sat, Dec 26, 2009 at 06:03:46PM +0100, olafbuddenha...@gmx.net wrote: > Hi, > > On Thu, Dec 24, 2009 at 10:25:47PM +0200, Sergiu Ivanov wrote: > > > Still, I somehow feel bad about copying from a pointer without doing > > an extra check. Would it be an acceptable idea to assert (name) ? > > Sure: if you think that something *should* be a certain way (non-NULL in > this case), but want to protect against the possibility that the > assumption was wrong after all, because of something that was overlooked > -- that's precisely what assert() is for :-) Great :-) This patch adds this assert. Regards, Sergiu --- eth-multiplexer/vdev.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/eth-multiplexer/vdev.c b/eth-multiplexer/vdev.c index dac9802..7e2a40b 100644 --- a/eth-multiplexer/vdev.c +++ b/eth-multiplexer/vdev.c @@ -27,6 +27,7 @@ #include <arpa/inet.h> #include <stdlib.h> #include <error.h> +#include <assert.h> #include <cthreads.h> @@ -135,6 +136,7 @@ add_vdev (char *name, int size, vdev->dev_port = ports_get_right (vdev); ports_port_deref (vdev); + assert (name); strncpy (vdev->name, name, IFNAMSIZ); vdev->if_header_size = ETH_HLEN; vdev->if_mtu = ETH_MTU; -- 1.5.2.4