Here are two change sets. They remove useless comparisons of the style - if (def->nets[i]->mac) { where the mac member is declared as an array. >From d22b04d2684d5a16f797d8df0c2ef036b5b1b2ce Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@xxxxxxxxxx> Date: Mon, 18 Jan 2010 09:49:57 +0100 Subject: [PATCH 1/2] lxc_driver: remove useless comparison * src/lxc/lxc_driver.c (lxcSetupInterfaces): Remove always-true array-is-non-NULL test. git grep 'mac\[.*\];'|grep -F .h src/conf/domain_conf.h: unsigned char mac[VIR_MAC_BUFLEN]; --- src/lxc/lxc_driver.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 86606c7..94ec874 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -834,7 +834,7 @@ static int lxcSetupInterfaces(virConnectPtr conn, goto error_exit; } - if (def->nets[i]->mac) { + { char macaddr[VIR_MAC_STRING_BUFLEN]; virFormatMacAddr(def->nets[i]->mac, macaddr); if (0 != (rc = setMacAddr(containerVeth, macaddr))) { -- 1.6.6.638.g2bc54 >From c751c0cf3352b08d674bb59efd987f106fc1fffb Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@xxxxxxxxxx> Date: Mon, 18 Jan 2010 09:58:57 +0100 Subject: [PATCH 2/2] vbox_tmpl.c: remove useless array-is-non-NULL comparisons * src/vbox/vbox_tmpl.c (vboxStorageVolDelete): Remove always-true array-is-non-NULL test. git grep 'key\[.*\];'|grep -F .h src/datatypes.h: char key[PATH_MAX]; (vboxStorageVolGetInfo): Likewise. (vboxStorageVolGetXMLDesc): Likewise. (vboxStorageVolGetPath): Likewise. (vboxDomainDefineXML): Likewise. (but now with "mac[]") --- src/vbox/vbox_tmpl.c | 16 ++-------------- 1 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 07696c0..e40c848 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -4084,9 +4084,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { } VBOX_UTF8_TO_UTF16(macaddrvbox, &MACAddress); - if (def->nets[i]->mac) { - adapter->vtbl->SetMACAddress(adapter, MACAddress); - } + adapter->vtbl->SetMACAddress(adapter, MACAddress); VBOX_UTF16_FREE(MACAddress); } } @@ -6645,9 +6643,6 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, int i = 0; int j = 0; - if (!vol->key) - return ret; - vboxUtf8toIID(vol->conn, vol->key, &hddIID); if (!hddIID) return ret; @@ -6774,8 +6769,7 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info vboxIID *hddIID = NULL; nsresult rc; - if ( !vol->key - || !info) + if (!info) return ret; vboxUtf8toIID(vol->conn, vol->key, &hddIID); @@ -6824,9 +6818,6 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A int defOk = 0; nsresult rc; - if (!vol->key) - return ret; - memset(&pool, 0, sizeof(pool)); memset(&def, 0, sizeof(def)); @@ -6919,9 +6910,6 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) { vboxIID *hddIID = NULL; nsresult rc; - if (!vol->key) - return ret; - vboxUtf8toIID(vol->conn, vol->key, &hddIID); if (!hddIID) return ret; -- 1.6.6.638.g2bc54 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list