src: Avoid needless checks before calling g_strdup()
There are few places where the following pattern occurs: if (var) other = g_strdup(var); where @other wasn't initialized before g_strdup(). Checking for var != NULL is useless in this case, as that's exactly what g_strdup() does (in which case it returns NULL). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
65558eb5cb
commit
732c5f4270
@ -1561,8 +1561,7 @@ virDomainEventMetadataChangeNew(int id,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ev->type = type;
|
ev->type = type;
|
||||||
if (nsuri)
|
ev->nsuri = g_strdup(nsuri);
|
||||||
ev->nsuri = g_strdup(nsuri);
|
|
||||||
|
|
||||||
return (virObjectEvent *)ev;
|
return (virObjectEvent *)ev;
|
||||||
}
|
}
|
||||||
|
@ -583,8 +583,7 @@ libxlMakeDomBuildInfo(virDomainDef *def,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* copy SLIC table path to acpi_firmware */
|
/* copy SLIC table path to acpi_firmware */
|
||||||
if (def->os.slic_table)
|
b_info->u.hvm.acpi_firmware = g_strdup(def->os.slic_table);
|
||||||
b_info->u.hvm.acpi_firmware = g_strdup(def->os.slic_table);
|
|
||||||
|
|
||||||
if (def->nsounds > 0) {
|
if (def->nsounds > 0) {
|
||||||
/*
|
/*
|
||||||
@ -1198,8 +1197,7 @@ libxlMakeDisk(virDomainDiskDef *l_disk, libxl_device_disk *x_disk)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l_disk->domain_name)
|
x_disk->backend_domname = g_strdup(l_disk->domain_name);
|
||||||
x_disk->backend_domname = g_strdup(l_disk->domain_name);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,7 @@ lxcCreateFSDef(int type,
|
|||||||
|
|
||||||
def->type = type;
|
def->type = type;
|
||||||
def->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH;
|
def->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH;
|
||||||
if (src)
|
def->src->path = g_strdup(src);
|
||||||
def->src->path = g_strdup(src);
|
|
||||||
def->dst = g_strdup(dst);
|
def->dst = g_strdup(dst);
|
||||||
def->readonly = readonly;
|
def->readonly = readonly;
|
||||||
def->usage = usage;
|
def->usage = usage;
|
||||||
|
@ -2960,8 +2960,7 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValue *reply,
|
|||||||
case QEMU_MONITOR_MIGRATION_STATUS_ERROR:
|
case QEMU_MONITOR_MIGRATION_STATUS_ERROR:
|
||||||
if (error) {
|
if (error) {
|
||||||
tmp = virJSONValueObjectGetString(ret, "error-desc");
|
tmp = virJSONValueObjectGetString(ret, "error-desc");
|
||||||
if (tmp)
|
*error = g_strdup(tmp);
|
||||||
*error = g_strdup(tmp);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -939,8 +939,7 @@ int virConfGetValueStringList(virConf *conf,
|
|||||||
case VIR_CONF_STRING:
|
case VIR_CONF_STRING:
|
||||||
if (compatString) {
|
if (compatString) {
|
||||||
*values = g_new0(char *, cval->str ? 2 : 1);
|
*values = g_new0(char *, cval->str ? 2 : 1);
|
||||||
if (cval->str)
|
(*values)[0] = g_strdup(cval->str);
|
||||||
(*values)[0] = g_strdup(cval->str);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
G_GNUC_FALLTHROUGH;
|
G_GNUC_FALLTHROUGH;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user