mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-23 03:42:19 +00:00
lib: Substitute some STREQLEN with STRPREFIX
There are few cases where STREQLEN() is called like this: STREQLEN(var, string, strlen(string)) which is the same as STRPREFIX(var, string). Use STRPREFIX() because it is more obvious what the check is doing. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
0ad938adc0
commit
d3b2d5158a
@ -950,7 +950,7 @@ xenParseXLUSBController(virConfPtr conf, virDomainDefPtr def)
|
|||||||
else
|
else
|
||||||
usbctrl_type = VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2;
|
usbctrl_type = VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2;
|
||||||
} else {
|
} else {
|
||||||
if (STREQLEN(type, "qusb", 4)) {
|
if (STRPREFIX(type, "qusb")) {
|
||||||
if (usbctrl_version == 1)
|
if (usbctrl_version == 1)
|
||||||
usbctrl_type = VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1;
|
usbctrl_type = VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1;
|
||||||
else
|
else
|
||||||
|
@ -938,7 +938,7 @@ virCgroupV2GetBlkioDeviceReadIops(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
tmp += strlen(name);
|
tmp += strlen(name);
|
||||||
|
|
||||||
if (STREQLEN(tmp, "max", 3)) {
|
if (STRPREFIX(tmp, "max")) {
|
||||||
*riops = 0;
|
*riops = 0;
|
||||||
} else if (virStrToLong_ui(tmp, &tmp, 10, riops) < 0) {
|
} else if (virStrToLong_ui(tmp, &tmp, 10, riops) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1007,7 +1007,7 @@ virCgroupV2GetBlkioDeviceWriteIops(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
tmp += strlen(name);
|
tmp += strlen(name);
|
||||||
|
|
||||||
if (STREQLEN(tmp, "max", 3)) {
|
if (STRPREFIX(tmp, "max")) {
|
||||||
*wiops = 0;
|
*wiops = 0;
|
||||||
} else if (virStrToLong_ui(tmp, &tmp, 10, wiops) < 0) {
|
} else if (virStrToLong_ui(tmp, &tmp, 10, wiops) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1076,7 +1076,7 @@ virCgroupV2GetBlkioDeviceReadBps(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
tmp += strlen(name);
|
tmp += strlen(name);
|
||||||
|
|
||||||
if (STREQLEN(tmp, "max", 3)) {
|
if (STRPREFIX(tmp, "max")) {
|
||||||
*rbps = 0;
|
*rbps = 0;
|
||||||
} else if (virStrToLong_ull(tmp, &tmp, 10, rbps) < 0) {
|
} else if (virStrToLong_ull(tmp, &tmp, 10, rbps) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1145,7 +1145,7 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group,
|
|||||||
}
|
}
|
||||||
tmp += strlen(name);
|
tmp += strlen(name);
|
||||||
|
|
||||||
if (STREQLEN(tmp, "max", 3)) {
|
if (STRPREFIX(tmp, "max")) {
|
||||||
*wbps = 0;
|
*wbps = 0;
|
||||||
} else if (virStrToLong_ull(tmp, &tmp, 10, wbps) < 0) {
|
} else if (virStrToLong_ull(tmp, &tmp, 10, wbps) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1578,7 +1578,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STREQLEN(str, "max", 3)) {
|
if (STRPREFIX(str, "max")) {
|
||||||
*cfs_quota = VIR_CGROUP_CPU_QUOTA_MAX;
|
*cfs_quota = VIR_CGROUP_CPU_QUOTA_MAX;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2568,7 +2568,6 @@ static char **
|
|||||||
vshReadlineCommandGenerator(const char *text)
|
vshReadlineCommandGenerator(const char *text)
|
||||||
{
|
{
|
||||||
size_t grp_list_index = 0, cmd_list_index = 0;
|
size_t grp_list_index = 0, cmd_list_index = 0;
|
||||||
size_t len = strlen(text);
|
|
||||||
const char *name;
|
const char *name;
|
||||||
const vshCmdGrp *grp;
|
const vshCmdGrp *grp;
|
||||||
const vshCmdDef *cmds;
|
const vshCmdDef *cmds;
|
||||||
@ -2588,7 +2587,7 @@ vshReadlineCommandGenerator(const char *text)
|
|||||||
if (cmds[cmd_list_index++].flags & VSH_CMD_FLAG_ALIAS)
|
if (cmds[cmd_list_index++].flags & VSH_CMD_FLAG_ALIAS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (STREQLEN(name, text, len)) {
|
if (STRPREFIX(name, text)) {
|
||||||
if (VIR_REALLOC_N(ret, ret_size + 2) < 0) {
|
if (VIR_REALLOC_N(ret, ret_size + 2) < 0) {
|
||||||
g_strfreev(ret);
|
g_strfreev(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user