
From: "Eduardo Lima (Etrunko)" <eblima@br.ibm.com> I am building libvirt-cim with gcc 4.6.3 in fedora 16 and got a bunch of new warnings. Most of them are about variables that are set but not used anywhere, but there is one possible access to unitialized variables in Virt_RASD.c which might result in unexpected behavior. xmlgen.c: In function 'system_xml': xmlgen.c:633:28: error: variable 'bl' set but not used [-Werror=unused-but-set-variable] xmlgen.c:642:28: error: variable 'bl_args' set but not used [-Werror=unused-but-set-variable] xmlgen.c: In function 'disk_pool_xml': xmlgen.c:1244:20: error: variable 'path' set but not used [-Werror=unused-but-set-variable] xmlgen.c: In function 'filter_to_xml': xmlgen.c:1474:15: error: variable 'msg' set but not used [-Werror=unused-but-set-variable] Virt_FilterEntry.c: In function 'enum_filter_rules': Virt_FilterEntry.c:576:30: error: variable 'class_type' set but not used [-Werror=unused-but-set-variable] Virt_RASD.c: In function 'rasd_from_vdev': Virt_RASD.c:406:27: error: 'pool' may be used uninitialized in this function [-Werror=uninitialized] Virt_RASD.c:330:27: note: 'pool' was declared here Virt_RASD.c:407:26: error: 'vol' may be used uninitialized in this function [-Werror=uninitialized] Virt_RASD.c:320:26: note: 'vol' was declared here Virt_VSMigrationService.c: In function 'clear_infstore_migration_flag': Virt_VSMigrationService.c:1185:15: error: variable 'ret' set but not used [-Werror=unused-but-set-variable] Virt_VSMigrationService.c: In function 'migrate_do': Virt_VSMigrationService.c:1478:15: error: variable 'thread' set but not used [-Werror=unused-but-set-variable] Virt_Device.c: In function 'device_instances': Virt_Device.c:431:15: error: variable 'ret' set but not used [-Werror=unused-but-set-variable] Virt_Device.c: In function 'proc_dev_list': Virt_Device.c:657:13: error: variable 'rc' set but not used [-Werror=unused-but-set-variable] Virt_Device.c: In function 'get_device_by_name': Virt_Device.c:769:21: error: variable 'ret' set but not used [-Werror=unused-but-set-variable] Virt_Device.c:729:15: error: variable 'rc' set but not used [-Werror=unused-but-set-variable] Virt_VirtualSystemManagementService.c: In function 'input_rasd_to_vdev': Virt_VirtualSystemManagementService.c:1384:21: error: variable 'msg' set but not used [-Werror=unused-but-set-variable] Signed-off-by: Eduardo Lima (Etrunko) <eblima@br.ibm.com> --- libxkutil/xmlgen.c | 34 ++++++------------------ src/Virt_Device.c | 39 +++++++++-------------------- src/Virt_FilterEntry.c | 11 ++------ src/Virt_RASD.c | 17 +++++++----- src/Virt_VSMigrationService.c | 6 +--- src/Virt_VirtualSystemManagementService.c | 5 +-- 6 files changed, 38 insertions(+), 74 deletions(-) diff --git a/libxkutil/xmlgen.c b/libxkutil/xmlgen.c index afd8c21..46712df 100644 --- a/libxkutil/xmlgen.c +++ b/libxkutil/xmlgen.c @@ -630,21 +630,17 @@ static char *system_xml(xmlNodePtr root, struct domain *domain) tmp = xmlNewChild(root, NULL, BAD_CAST "name", BAD_CAST domain->name); if (domain->bootloader) { - xmlNodePtr bl; - - bl = xmlNewChild(root, - NULL, - BAD_CAST "bootloader", - BAD_CAST domain->bootloader); + tmp = xmlNewChild(root, + NULL, + BAD_CAST "bootloader", + BAD_CAST domain->bootloader); } if (domain->bootloader_args) { - xmlNodePtr bl_args; - - bl_args = xmlNewChild(root, - NULL, - BAD_CAST "bootloader_args", - BAD_CAST domain->bootloader_args); + tmp = xmlNewChild(root, + NULL, + BAD_CAST "bootloader_args", + BAD_CAST domain->bootloader_args); } tmp = xmlNewChild(root, @@ -1241,7 +1237,6 @@ static const char *disk_pool_xml(xmlNodePtr root, xmlNodePtr disk = NULL; xmlNodePtr name = NULL; xmlNodePtr target = NULL; - xmlNodePtr path = NULL; const char *type = NULL; const char *msg = NULL; struct disk_pool *pool = &_pool->pool_info.disk; @@ -1271,7 +1266,7 @@ static const char *disk_pool_xml(xmlNodePtr root, if (target == NULL) goto out; - path = xmlNewChild(target, NULL, BAD_CAST "path", BAD_CAST pool->path); + xmlNewChild(target, NULL, BAD_CAST "path", BAD_CAST pool->path); if (target == NULL) goto out; @@ -1471,7 +1466,6 @@ char *res_to_xml(struct virt_pool_res *res) { char *filter_to_xml(struct acl_filter *filter) { - char *msg = XML_ERROR; char *xml = NULL; xmlNodePtr root = NULL; xmlNodePtr tmp = NULL; @@ -1504,17 +1498,7 @@ char *filter_to_xml(struct acl_filter *filter) goto out; } - /* TODO: Not yet supported - for (i = 0; i < filter->rule_ct; i++) { - msg = rule_to_xml(root, filter->rules[i]); - if (msg != NULL) - goto out; - } - */ - xml = tree_to_xml(root); - if (xml != NULL) - msg = NULL; /* no errors */ out: CU_DEBUG("Filter XML: %s", xml); diff --git a/src/Virt_Device.c b/src/Virt_Device.c index faa304d..fd11370 100644 --- a/src/Virt_Device.c +++ b/src/Virt_Device.c @@ -428,7 +428,6 @@ static bool device_instances(const CMPIBroker *broker, struct inst_list *list) { int i; - bool ret; uint64_t proc_count = 0; CMPIInstance *instance = NULL; @@ -475,11 +474,7 @@ static bool device_instances(const CMPIBroker *broker, } if (proc_count) { - ret = vcpu_instances(broker, - dom, - ns, - proc_count, - list); + vcpu_instances(broker, dom, ns, proc_count, list); } return true; @@ -654,16 +649,17 @@ static int proc_dev_list(uint64_t quantity, struct virt_device **list) { int i; - int rc; - *list = (struct virt_device *)calloc(quantity, sizeof(struct virt_device)); for (i = 0; i < quantity; i++) { char *dev_num; + int ret; - rc = asprintf(&dev_num, "%d", i); + ret = asprintf(&dev_num, "%d", i); + if (ret == -1) + CU_DEBUG("asprintf error %d" , ret); (*list)[i].id = strdup(dev_num); @@ -726,7 +722,6 @@ CMPIStatus get_device_by_name(const CMPIBroker *broker, virDomainPtr dom = NULL; struct virt_device *dev = NULL; struct inst_list tmp_list; - bool rc; inst_list_init(&tmp_list); @@ -766,24 +761,14 @@ CMPIStatus get_device_by_name(const CMPIBroker *broker, } if (type == CIM_RES_TYPE_PROC) { - int ret; int dev_id_num; - - ret = sscanf(dev->id, "%d", &dev_id_num); + sscanf(dev->id, "%d", &dev_id_num); - rc = vcpu_inst(broker, - dom, - NAMESPACE(reference), - dev_id_num, - &tmp_list); + vcpu_inst(broker, dom, NAMESPACE(reference), + dev_id_num, &tmp_list); } else { - - rc = device_instances(broker, - dev, - 1, - dom, - NAMESPACE(reference), - &tmp_list); + device_instances(broker, dev, 1, dom, + NAMESPACE(reference), &tmp_list); } cleanup_virt_devices(&dev, 1); @@ -799,8 +784,8 @@ CMPIStatus get_device_by_name(const CMPIBroker *broker, inst_list_free(&tmp_list); virConnectClose(conn); - return s; -} + return s; +} CMPIStatus get_device_by_ref(const CMPIBroker *broker, const CMPIObjectPath *reference, diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c index acc3d61..16b211e 100644 --- a/src/Virt_FilterEntry.c +++ b/src/Virt_FilterEntry.c @@ -573,17 +573,12 @@ CMPIStatus enum_filter_rules( struct acl_filter *filters = NULL; int i, j, count = 0; CMPIStatus s = {CMPI_RC_OK, NULL}; - enum {NONE, MAC, IP} class_type = NONE; CU_DEBUG("Reference = %s", REF2STR(reference)); - if (STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter")) { - class_type = MAC; - } else if (STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter")) { - class_type = IP; - } else if (STREQC(CLASSNAME(reference), "KVM_FilterEntry")) { - class_type = NONE; - } else { + if (!STREQC(CLASSNAME(reference), "KVM_Hdr8021Filter") && + !STREQC(CLASSNAME(reference), "KVM_IPHeadersFilter") && + !STREQC(CLASSNAME(reference), "KVM_FilterEntry")) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Unrecognized class type"); diff --git a/src/Virt_RASD.c b/src/Virt_RASD.c index 4ac2f93..4939f7b 100644 --- a/src/Virt_RASD.c +++ b/src/Virt_RASD.c @@ -289,6 +289,11 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, uint16_t type; CMPIStatus s = {CMPI_RC_OK, NULL}; char *poolid = NULL; + virConnectPtr conn = NULL; + virStorageVolPtr vol = NULL; + virStoragePoolPtr pool = NULL; + const char *pool_name = NULL; + int ret = -1; get_vol_size(broker, ref, dev->dev.disk.source, &cap); @@ -308,7 +313,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, (CMPIValue *)dev->dev.disk.source, CMPI_chars); - virConnectPtr conn = connect_by_classname(broker, CLASSNAME(ref), &s); + conn = connect_by_classname(broker, CLASSNAME(ref), &s); if (conn == NULL) { virt_set_status(broker, &s, CMPI_RC_ERR_NOT_FOUND, @@ -317,8 +322,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, goto cont; } - virStorageVolPtr vol = virStorageVolLookupByPath(conn, - dev->dev.disk.source); + vol = virStorageVolLookupByPath(conn, dev->dev.disk.source); if (vol == NULL) { virt_set_status(broker, &s, CMPI_RC_ERR_NOT_FOUND, @@ -327,7 +331,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, goto cont; } - virStoragePoolPtr pool = virStoragePoolLookupByVolume(vol); + pool = virStoragePoolLookupByVolume(vol); if (pool == NULL) { virt_set_status(broker, &s, CMPI_RC_ERR_NOT_FOUND, @@ -336,7 +340,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, goto cont; } - const char *pool_name = virStoragePoolGetName(pool); + pool_name = virStoragePoolGetName(pool); if (pool_name == NULL) { virt_set_status(broker, &s, CMPI_RC_ERR_NOT_FOUND, @@ -345,8 +349,7 @@ static CMPIStatus set_disk_rasd_params(const CMPIBroker *broker, goto cont; } - int ret = asprintf(&poolid, "DiskPool/%s", pool_name); - + ret = asprintf(&poolid, "DiskPool/%s", pool_name); if (ret == -1) { CU_DEBUG("Failed to get disk poolid"); goto cont; diff --git a/src/Virt_VSMigrationService.c b/src/Virt_VSMigrationService.c index 4f48a68..d393787 100644 --- a/src/Virt_VSMigrationService.c +++ b/src/Virt_VSMigrationService.c @@ -1182,7 +1182,6 @@ static CMPIStatus ensure_dom_offline(virDomainPtr dom) static void clear_infstore_migration_flag(virDomainPtr dom) { struct infostore_ctx *infp; - bool ret = false; infp = infostore_open(dom); if (infp == NULL) { @@ -1191,7 +1190,7 @@ static void clear_infstore_migration_flag(virDomainPtr dom) return; } - ret = infostore_set_bool(infp, "migrating", false); + infostore_set_bool(infp, "migrating", false); CU_DEBUG("Clearing infostore migrating flag"); infostore_close(infp); @@ -1475,7 +1474,6 @@ static CMPIStatus migrate_do(const CMPIObjectPath *ref, CMPIStatus s; CMPIObjectPath *job_op; struct migration_job *job; - CMPI_THREAD_TYPE thread; uint32_t retcode = 1; CMPIInstance *ind = NULL; CMPIInstance *inst = NULL; @@ -1517,7 +1515,7 @@ static CMPIStatus migrate_do(const CMPIObjectPath *ref, if (!rc) CU_DEBUG("Failed to raise indication"); - thread = _BROKER->xft->newThread((void*)migration_thread, job, 0); + _BROKER->xft->newThread((void*)migration_thread, job, 0); retcode = CIM_SVPC_RETURN_JOB_STARTED; diff --git a/src/Virt_VirtualSystemManagementService.c b/src/Virt_VirtualSystemManagementService.c index 5229f56..f8c5f24 100644 --- a/src/Virt_VirtualSystemManagementService.c +++ b/src/Virt_VirtualSystemManagementService.c @@ -1381,10 +1381,9 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { const char *val; - const char *msg; if (cu_get_str_prop(inst, "ResourceSubType", &val) != CMPI_RC_OK) { - msg = "InputRASD ResourceSubType field not valid"; + CU_DEBUG("InputRASD ResourceSubType field not valid"); goto out; } dev->dev.input.type = strdup(val); @@ -1395,7 +1394,7 @@ static const char *input_rasd_to_vdev(CMPIInstance *inst, else if (STREQC(dev->dev.input.type, "tablet")) dev->dev.input.bus = strdup("usb"); else { - msg = "Invalid value for ResourceSubType in InputRASD"; + CU_DEBUG("Invalid value for ResourceSubType in InputRASD"); goto out; } } else -- 1.7.7.5