1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-21 13:34:06 +03:00

util: virsysinfo: Change return type of functions that never fail to void

These functions return value is invariant since VIR_EXPAND_N check
removal in 7d2fd6e, so change its type and remove all dependent checks.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Reported-by: Pavel Nekrasov <p.nekrasov@fobos-nt.ru>
Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Alexander Kuznetsov 2024-11-28 18:21:22 +03:00 committed by Jiri Denemark
parent abd9887b6c
commit 2195037265

View File

@ -263,7 +263,7 @@ virSysinfoParsePPCSystem(const char *base, virSysinfoSystemDef **sysdef)
return ret; return ret;
} }
static int static void
virSysinfoParsePPCProcessor(const char *base, virSysinfoDef *ret) virSysinfoParsePPCProcessor(const char *base, virSysinfoDef *ret)
{ {
const char *cur; const char *cur;
@ -303,8 +303,6 @@ virSysinfoParsePPCProcessor(const char *base, virSysinfoDef *ret)
} }
} }
return 0;
} }
/* virSysinfoRead for PowerPC /* virSysinfoRead for PowerPC
@ -325,8 +323,7 @@ virSysinfoReadPPC(void)
ret->nprocessor = 0; ret->nprocessor = 0;
ret->processor = NULL; ret->processor = NULL;
if (virSysinfoParsePPCProcessor(outbuf, ret) < 0) virSysinfoParsePPCProcessor(outbuf, ret);
return NULL;
if (virSysinfoParsePPCSystem(outbuf, &ret->system) < 0) if (virSysinfoParsePPCSystem(outbuf, &ret->system) < 0)
return NULL; return NULL;
@ -383,7 +380,7 @@ virSysinfoParseARMSystem(const char *base, virSysinfoSystemDef **sysdef)
return ret; return ret;
} }
static int static void
virSysinfoParseARMProcessor(const char *base, virSysinfoDef *ret) virSysinfoParseARMProcessor(const char *base, virSysinfoDef *ret)
{ {
const char *cur; const char *cur;
@ -393,7 +390,7 @@ virSysinfoParseARMProcessor(const char *base, virSysinfoDef *ret)
if (!(tmp_base = strstr(base, "model name")) && if (!(tmp_base = strstr(base, "model name")) &&
!(tmp_base = strstr(base, "Processor"))) !(tmp_base = strstr(base, "Processor")))
return 0; return;
eol = strchr(tmp_base, '\n'); eol = strchr(tmp_base, '\n');
cur = strchr(tmp_base, ':') + 1; cur = strchr(tmp_base, ':') + 1;
@ -420,7 +417,7 @@ virSysinfoParseARMProcessor(const char *base, virSysinfoDef *ret)
} }
VIR_FREE(processor_type); VIR_FREE(processor_type);
return 0; return;
} }
/* virSysinfoRead for ARMv7 /* virSysinfoRead for ARMv7
@ -451,8 +448,7 @@ virSysinfoReadARM(void)
ret->nprocessor = 0; ret->nprocessor = 0;
ret->processor = NULL; ret->processor = NULL;
if (virSysinfoParseARMProcessor(outbuf, ret) < 0) virSysinfoParseARMProcessor(outbuf, ret);
return NULL;
if (virSysinfoParseARMSystem(outbuf, &ret->system) < 0) if (virSysinfoParseARMSystem(outbuf, &ret->system) < 0)
return NULL; return NULL;
@ -753,7 +749,7 @@ virSysinfoParseX86System(const char *base, virSysinfoSystemDef **sysdef)
return ret; return ret;
} }
static int static void
virSysinfoParseX86BaseBoard(const char *base, virSysinfoParseX86BaseBoard(const char *base,
virSysinfoBaseBoardDef **baseBoard, virSysinfoBaseBoardDef **baseBoard,
size_t *nbaseBoard) size_t *nbaseBoard)
@ -827,7 +823,6 @@ virSysinfoParseX86BaseBoard(const char *base,
*nbaseBoard = nboards; *nbaseBoard = nboards;
*baseBoard = g_steal_pointer(&boards); *baseBoard = g_steal_pointer(&boards);
return 0;
} }
@ -1006,7 +1001,7 @@ virSysinfoParseOEMStrings(const char *base,
} }
static int static void
virSysinfoParseX86Processor(const char *base, virSysinfoDef *ret) virSysinfoParseX86Processor(const char *base, virSysinfoDef *ret)
{ {
const char *cur, *tmp_base; const char *cur, *tmp_base;
@ -1102,11 +1097,9 @@ virSysinfoParseX86Processor(const char *base, virSysinfoDef *ret)
base += strlen("Processor Information"); base += strlen("Processor Information");
} }
return 0;
} }
static int static void
virSysinfoParseX86Memory(const char *base, virSysinfoDef *ret) virSysinfoParseX86Memory(const char *base, virSysinfoDef *ret)
{ {
const char *cur, *tmp_base; const char *cur, *tmp_base;
@ -1197,8 +1190,6 @@ virSysinfoParseX86Memory(const char *base, virSysinfoDef *ret)
next: next:
base += strlen("Memory Device"); base += strlen("Memory Device");
} }
return 0;
} }
virSysinfoDef * virSysinfoDef *
@ -1223,8 +1214,7 @@ virSysinfoReadDMI(void)
if (virSysinfoParseX86System(outbuf, &ret->system) < 0) if (virSysinfoParseX86System(outbuf, &ret->system) < 0)
return NULL; return NULL;
if (virSysinfoParseX86BaseBoard(outbuf, &ret->baseBoard, &ret->nbaseBoard) < 0) virSysinfoParseX86BaseBoard(outbuf, &ret->baseBoard, &ret->nbaseBoard);
return NULL;
if (virSysinfoParseX86Chassis(outbuf, &ret->chassis) < 0) if (virSysinfoParseX86Chassis(outbuf, &ret->chassis) < 0)
return NULL; return NULL;
@ -1234,13 +1224,11 @@ virSysinfoReadDMI(void)
ret->nprocessor = 0; ret->nprocessor = 0;
ret->processor = NULL; ret->processor = NULL;
if (virSysinfoParseX86Processor(outbuf, ret) < 0) virSysinfoParseX86Processor(outbuf, ret);
return NULL;
ret->nmemory = 0; ret->nmemory = 0;
ret->memory = NULL; ret->memory = NULL;
if (virSysinfoParseX86Memory(outbuf, ret) < 0) virSysinfoParseX86Memory(outbuf, ret);
return NULL;
return g_steal_pointer(&ret); return g_steal_pointer(&ret);
} }