[netcf-devel] null MAC address
David Lutterkort
lutter at redhat.com
Mon Oct 19 10:10:33 UTC 2009
On Thu, 2009-10-15 at 23:19 -0400, Laine Stump wrote:
> In many cases there is no MAC address in the xml definition for an
> interface. When this is the case, ncf_if_mac_string returns NULL, as
> well as throwing an error. Should this really be what it does? Perhaps
> it should return "", or at least not throw the error?
Yes, reporting an error there is bogus - just returning NULL should be
good enough. How about this patch:
>From 5b1294f8af37ff72f7f8370c38c48fb7bd519921 Mon Sep 17 00:00:00 2001
From: David Lutterkort <lutter at redhat.com>
Date: Mon, 19 Oct 2009 12:06:46 +0200
Subject: [PATCH] * src/drv_initscripts.c (drv_mac_string): unknown MAC
is not an error
---
src/drv_initscripts.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/drv_initscripts.c b/src/drv_initscripts.c
index cfba2b6..f72f17b 100644
--- a/src/drv_initscripts.c
+++ b/src/drv_initscripts.c
@@ -1118,12 +1118,16 @@ const char *drv_mac_string(struct netcf_if *nif)
{
int r;
r = aug_get_mac(ncf, nif->name, &mac);
- ERR_THROW(r <= 0, ncf, EOTHER, "could not lookup MAC of %s",
nif->name);
+ ERR_THROW(r < 0, ncf, EOTHER, "could not lookup MAC of %s",
nif->name);
- if (nif->mac == NULL || STRNEQ(nif->mac, mac)) {
+ if (mac != NULL) {
+ if (nif->mac == NULL || STRNEQ(nif->mac, mac)) {
+ FREE(nif->mac);
+ nif->mac = strdup(mac);
+ ERR_NOMEM(nif->mac == NULL, ncf);
+ }
+ } else {
FREE(nif->mac);
- nif->mac = strdup(mac);
- ERR_NOMEM(nif->mac == NULL, ncf);
}
/* fallthrough intentional */
error:
--
1.6.2.5
More information about the netcf-devel
mailing list