提交 d901fd60 编写于 作者: M Michal Privoznik

Drop needless variable

Instead of the following pattern:

  type ret;
  ...
  ret = func();
  return ret;

we can use:

  return func()

directly.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 0975dd6c
......@@ -1392,13 +1392,7 @@ virDomainPCIAddressSetAllMulti(virDomainDefPtr def)
static char*
virDomainCCWAddressAsString(virDomainDeviceCCWAddressPtr addr)
{
char *addrstr = NULL;
addrstr = g_strdup_printf("%x.%x.%04x",
addr->cssid,
addr->ssid,
addr->devno);
return addrstr;
return g_strdup_printf("%x.%x.%04x", addr->cssid, addr->ssid, addr->devno);
}
static int
......
......@@ -31317,7 +31317,6 @@ virDomainDefGetShortName(const virDomainDef *def)
{
wchar_t wshortname[VIR_DOMAIN_SHORT_NAME_MAX + 1] = {0};
size_t len = 0;
char *ret = NULL;
g_autofree char *shortname = NULL;
/* No need to do the whole conversion thing when there are no multibyte
......@@ -31326,8 +31325,8 @@ virDomainDefGetShortName(const virDomainDef *def)
len = mbstowcs(NULL, def->name, 0);
if ((len == (size_t) -1 && errno == EILSEQ) ||
len == strlen(def->name)) {
ret = g_strdup_printf("%d-%.*s", def->id, VIR_DOMAIN_SHORT_NAME_MAX, def->name);
return ret;
return g_strdup_printf("%d-%.*s", def->id, VIR_DOMAIN_SHORT_NAME_MAX,
def->name);
}
if (len == (size_t) -1) {
......@@ -31362,8 +31361,7 @@ virDomainDefGetShortName(const virDomainDef *def)
return NULL;
}
ret = g_strdup_printf("%d-%s", def->id, shortname);
return ret;
return g_strdup_printf("%d-%s", def->id, shortname);
}
#undef VIR_DOMAIN_SHORT_NAME_MAX
......@@ -2892,10 +2892,7 @@ char *
virNetworkConfigFile(const char *dir,
const char *name)
{
char *ret = NULL;
ret = g_strdup_printf("%s/%s.xml", dir, name);
return ret;
return g_strdup_printf("%s/%s.xml", dir, name);
}
......
......@@ -432,10 +432,7 @@ static char *
virNetworkPortDefConfigFile(const char *dir,
const char *name)
{
char *ret = NULL;
ret = g_strdup_printf("%s/%s.xml", dir, name);
return ret;
return g_strdup_printf("%s/%s.xml", dir, name);
}
......
......@@ -4467,7 +4467,6 @@ char *
virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *ret = NULL;
size_t i;
virBufferAddLit(&buf, "<qemuCaps>\n");
......@@ -4537,9 +4536,7 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</qemuCaps>\n");
ret = virBufferContentAndReset(&buf);
return ret;
return virBufferContentAndReset(&buf);
}
......
......@@ -251,7 +251,6 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
static char *
qemuVirCommandGetFDSet(virCommandPtr cmd, int fd)
{
char *result = NULL;
int idx = virCommandPassFDGetFDIndex(cmd, fd);
if (idx < 0) {
......@@ -260,8 +259,7 @@ qemuVirCommandGetFDSet(virCommandPtr cmd, int fd)
return NULL;
}
result = g_strdup_printf("set=%d,fd=%d", idx, fd);
return result;
return g_strdup_printf("set=%d,fd=%d", idx, fd);
}
......@@ -278,7 +276,6 @@ qemuVirCommandGetFDSet(virCommandPtr cmd, int fd)
static char *
qemuVirCommandGetDevSet(virCommandPtr cmd, int fd)
{
char *result = NULL;
int idx = virCommandPassFDGetFDIndex(cmd, fd);
if (idx < 0) {
......@@ -287,8 +284,7 @@ qemuVirCommandGetDevSet(virCommandPtr cmd, int fd)
return NULL;
}
result = g_strdup_printf("/dev/fdset/%d", idx);
return result;
return g_strdup_printf("/dev/fdset/%d", idx);
}
......
......@@ -1429,7 +1429,6 @@ char *
qemuGetSharedDeviceKey(const char *device_path)
{
int maj, min;
char *key = NULL;
int rc;
if ((rc = virGetDeviceID(device_path, &maj, &min)) < 0) {
......@@ -1439,9 +1438,7 @@ qemuGetSharedDeviceKey(const char *device_path)
return NULL;
}
key = g_strdup_printf("%d:%d", maj, min);
return key;
return g_strdup_printf("%d:%d", maj, min);
}
/*
......@@ -1706,7 +1703,6 @@ qemuGetHostdevPath(virDomainHostdevDefPtr hostdev)
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
g_autofree char *dev_name = NULL;
char *dev_path = NULL;
if (!(dev_name = virSCSIDeviceGetDevName(NULL,
scsihostsrc->adapter,
......@@ -1715,8 +1711,7 @@ qemuGetHostdevPath(virDomainHostdevDefPtr hostdev)
scsihostsrc->unit)))
return NULL;
dev_path = g_strdup_printf("/dev/%s", dev_name);
return dev_path;
return g_strdup_printf("/dev/%s", dev_name);
}
......
......@@ -6837,15 +6837,12 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
virDomainDefPtr src,
unsigned int flags)
{
virDomainDefPtr ret = NULL;
g_autofree char *xml = NULL;
if (!(xml = qemuDomainDefFormatXML(driver, qemuCaps, src, flags)))
return NULL;
ret = qemuDomainDefFromXML(driver, qemuCaps, xml);
return ret;
return qemuDomainDefFromXML(driver, qemuCaps, xml);
}
......@@ -13364,11 +13361,8 @@ qemuProcessEventFree(struct qemuProcessEvent *event)
char *
qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv)
{
char *ret = NULL;
ret = g_strdup_printf("%s/%s.sock", priv->libDir, qemuDomainGetManagedPRAlias());
return ret;
return g_strdup_printf("%s/%s.sock", priv->libDir,
qemuDomainGetManagedPRAlias());
}
......
......@@ -7439,31 +7439,25 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
static int qemuConnectListDefinedDomains(virConnectPtr conn,
char **const names, int nnames) {
virQEMUDriverPtr driver = conn->privateData;
int ret = -1;
if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
return -1;
ret = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
virConnectListDefinedDomainsCheckACL,
conn);
return ret;
return virDomainObjListGetInactiveNames(driver->domains, names, nnames,
virConnectListDefinedDomainsCheckACL,
conn);
}
static int qemuConnectNumOfDefinedDomains(virConnectPtr conn)
{
virQEMUDriverPtr driver = conn->privateData;
int ret = -1;
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
return -1;
ret = virDomainObjListNumOfDomains(driver->domains, false,
virConnectNumOfDefinedDomainsCheckACL,
conn);
return ret;
return virDomainObjListNumOfDomains(driver->domains, false,
virConnectNumOfDefinedDomainsCheckACL,
conn);
}
......
......@@ -171,11 +171,7 @@ static char *
qemuTPMCreateEmulatorSocket(const char *swtpmStateDir,
const char *shortName)
{
char *path = NULL;
path = g_strdup_printf("%s/%s-swtpm.sock", swtpmStateDir, shortName);
return path;
return g_strdup_printf("%s/%s-swtpm.sock", swtpmStateDir, shortName);
}
......@@ -213,14 +209,11 @@ static char *
qemuTPMEmulatorCreatePidFilename(const char *swtpmStateDir,
const char *shortName)
{
char *pidfile = NULL;
g_autofree char *devicename = NULL;
devicename = g_strdup_printf("%s-swtpm", shortName);
pidfile = virPidFileBuildPath(swtpmStateDir, devicename);
return pidfile;
return virPidFileBuildPath(swtpmStateDir, devicename);
}
......
......@@ -213,12 +213,9 @@ static char *
get_profile_name(virDomainDefPtr def)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *name = NULL;
virUUIDFormat(def->uuid, uuidstr);
name = g_strdup_printf("%s%s", AA_PREFIX, uuidstr);
return name;
return g_strdup_printf("%s%s", AA_PREFIX, uuidstr);
}
/* returns -1 on error or profile for libvirtd is unconfined, 0 if complain
......
......@@ -92,9 +92,8 @@ virSecurityGetRefCountAttrName(const char *name G_GNUC_UNUSED)
static char *
virSecurityGetTimestampAttrName(const char *name)
{
char *ret = NULL;
ret = g_strdup_printf(XATTR_NAMESPACE ".libvirt.security.timestamp_%s", name);
return ret;
return g_strdup_printf(XATTR_NAMESPACE ".libvirt.security.timestamp_%s",
name);
}
#else /* !XATTR_NAMESPACE */
static char *
......@@ -112,7 +111,6 @@ static char *
virSecurityGetTimestamp(void)
{
unsigned long long boottime = 0;
char *ret = NULL;
if (virHostGetBootTime(&boottime) < 0) {
virReportSystemError(errno, "%s",
......@@ -120,8 +118,7 @@ virSecurityGetTimestamp(void)
return NULL;
}
ret = g_strdup_printf("%llu", boottime);
return ret;
return g_strdup_printf("%llu", boottime);
}
......
......@@ -2839,11 +2839,8 @@ virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr obj,
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
char *tmp = NULL;
tmp = g_strdup_printf("%s/%s.%s.secret.XXXXXX",
driver->stateDir, def->name, voldef->name);
return tmp;
return g_strdup_printf("%s/%s.%s.secret.XXXXXX", driver->stateDir,
def->name, voldef->name);
}
......
......@@ -423,7 +423,6 @@ virCgroupDetect(virCgroupPtr group,
char *
virCgroupGetBlockDevString(const char *path)
{
char *ret = NULL;
struct stat sb;
if (stat(path, &sb) < 0) {
......@@ -442,9 +441,7 @@ virCgroupGetBlockDevString(const char *path)
/* Automatically append space after the string since all callers
* use it anyway */
ret = g_strdup_printf("%d:%d ", major(sb.st_rdev), minor(sb.st_rdev));
return ret;
return g_strdup_printf("%d:%d ", major(sb.st_rdev), minor(sb.st_rdev));
}
......
......@@ -209,7 +209,6 @@ virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr)
g_autofree char *result_file = NULL;
g_autofree char *iommu_path = NULL;
g_autofree char *dev_path = virMediatedDeviceGetSysfsPath(uuidstr);
char *vfio_path = NULL;
if (!dev_path)
return NULL;
......@@ -228,9 +227,7 @@ virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr)
result_file = g_path_get_basename(result_path);
vfio_path = g_strdup_printf("/dev/vfio/%s", result_file);
return vfio_path;
return g_strdup_printf("/dev/vfio/%s", result_file);
}
......@@ -422,10 +419,7 @@ virMediatedDeviceIsUsed(virMediatedDevicePtr dev,
char *
virMediatedDeviceGetSysfsPath(const char *uuidstr)
{
char *ret = NULL;
ret = g_strdup_printf(MDEV_SYSFS_DEVICES "%s", uuidstr);
return ret;
return g_strdup_printf(MDEV_SYSFS_DEVICES "%s", uuidstr);
}
......
......@@ -2308,8 +2308,6 @@ virResctrlDeterminePath(const char *parentpath,
const char *prefix,
const char *id)
{
char *path = NULL;
if (!id) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Resctrl ID must be set before determining resctrl "
......@@ -2317,9 +2315,7 @@ virResctrlDeterminePath(const char *parentpath,
return NULL;
}
path = g_strdup_printf("%s/%s-%s", parentpath, prefix, id);
return path;
return g_strdup_printf("%s/%s-%s", parentpath, prefix, id);
}
......
......@@ -578,7 +578,6 @@ char *
virSocketAddrGetPath(virSocketAddrPtr addr G_GNUC_UNUSED)
{
#ifndef WIN32
char *path = NULL;
if (addr == NULL) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("No socket address provided"));
......@@ -591,9 +590,7 @@ virSocketAddrGetPath(virSocketAddrPtr addr G_GNUC_UNUSED)
return NULL;
}
path = g_strndup(addr->data.un.sun_path, sizeof(addr->data.un.sun_path));
return path;
return g_strndup(addr->data.un.sun_path, sizeof(addr->data.un.sun_path));
#else
virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("UNIX sockets not supported on this platform"));
......
......@@ -1420,7 +1420,6 @@ virGetUnprivSGIOSysfsPath(const char *path,
const char *sysfs_dir)
{
int maj, min;
char *sysfs_path = NULL;
int rc;
if ((rc = virGetDeviceID(path, &maj, &min)) < 0) {
......@@ -1430,10 +1429,9 @@ virGetUnprivSGIOSysfsPath(const char *path,
return NULL;
}
sysfs_path = g_strdup_printf("%s/%d:%d/queue/unpriv_sgio",
sysfs_dir ? sysfs_dir : SYSFS_DEV_BLOCK_PATH,
maj, min);
return sysfs_path;
return g_strdup_printf("%s/%d:%d/queue/unpriv_sgio",
sysfs_dir ? sysfs_dir : SYSFS_DEV_BLOCK_PATH, maj,
min);
}
int
......
......@@ -185,11 +185,7 @@ fakeStorageVolGetInfo(virStorageVolPtr vol,
static char *
fakeStorageVolGetPath(virStorageVolPtr vol)
{
char *ret = NULL;
ret = g_strdup_printf("/some/%s/device/%s", vol->key, vol->name);
return ret;
return g_strdup_printf("/some/%s/device/%s", vol->key, vol->name);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册