From 695593fe000e07c4caef0fd30e8cabc2eeb3fe3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 21 Jun 2013 18:57:12 +0200 Subject: [PATCH] netdev: accept NULL in virNetDevSetupControl Commit b9c6b073 dropped the version of virNetDevSetupControl that didn't check for NULL arguments, but we call it like that in virNetDevBridgeDelete. --- src/util/virnetdev.c | 14 ++++++++------ src/util/virnetdev.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 7aba515ae3..ebe20d09fb 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -62,13 +62,15 @@ static int virNetDevSetupControlFull(const char *ifname, { int fd; - memset(ifr, 0, sizeof(*ifr)); + if (ifr && ifname) { + memset(ifr, 0, sizeof(*ifr)); - if (virStrcpyStatic(ifr->ifr_name, ifname) == NULL) { - virReportSystemError(ERANGE, - _("Network interface name '%s' is too long"), - ifname); - return -1; + if (virStrcpyStatic(ifr->ifr_name, ifname) == NULL) { + virReportSystemError(ERANGE, + _("Network interface name '%s' is too long"), + ifname); + return -1; + } } if ((fd = socket(domain, type, 0)) < 0) { diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index 933a9b334c..44a37ca739 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -38,7 +38,7 @@ typedef void virIfreq; int virNetDevSetupControl(const char *ifname, virIfreq *ifr) - ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + ATTRIBUTE_RETURN_CHECK; int virNetDevExists(const char *brname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;