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@xxxxxxxxxx> --- src/libxl/xen_xl.c | 2 +- src/util/vircgroupv2.c | 10 +++++----- tools/vsh.c | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 941832ce4e..69b139354e 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -950,7 +950,7 @@ xenParseXLUSBController(virConfPtr conf, virDomainDefPtr def) else usbctrl_type = VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2; } else { - if (STREQLEN(type, "qusb", 4)) { + if (STRPREFIX(type, "qusb")) { if (usbctrl_version == 1) usbctrl_type = VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1; else diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 4a239f067a..49acd27714 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -938,7 +938,7 @@ virCgroupV2GetBlkioDeviceReadIops(virCgroupPtr group, } tmp += strlen(name); - if (STREQLEN(tmp, "max", 3)) { + if (STRPREFIX(tmp, "max")) { *riops = 0; } else if (virStrToLong_ui(tmp, &tmp, 10, riops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1007,7 +1007,7 @@ virCgroupV2GetBlkioDeviceWriteIops(virCgroupPtr group, } tmp += strlen(name); - if (STREQLEN(tmp, "max", 3)) { + if (STRPREFIX(tmp, "max")) { *wiops = 0; } else if (virStrToLong_ui(tmp, &tmp, 10, wiops) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1076,7 +1076,7 @@ virCgroupV2GetBlkioDeviceReadBps(virCgroupPtr group, } tmp += strlen(name); - if (STREQLEN(tmp, "max", 3)) { + if (STRPREFIX(tmp, "max")) { *rbps = 0; } else if (virStrToLong_ull(tmp, &tmp, 10, rbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1145,7 +1145,7 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group, } tmp += strlen(name); - if (STREQLEN(tmp, "max", 3)) { + if (STRPREFIX(tmp, "max")) { *wbps = 0; } else if (virStrToLong_ull(tmp, &tmp, 10, wbps) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1578,7 +1578,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group, return -1; } - if (STREQLEN(str, "max", 3)) { + if (STRPREFIX(str, "max")) { *cfs_quota = VIR_CGROUP_CPU_QUOTA_MAX; return 0; } diff --git a/tools/vsh.c b/tools/vsh.c index 0e2d4955b4..a242619b8a 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2568,7 +2568,6 @@ static char ** vshReadlineCommandGenerator(const char *text) { size_t grp_list_index = 0, cmd_list_index = 0; - size_t len = strlen(text); const char *name; const vshCmdGrp *grp; const vshCmdDef *cmds; @@ -2588,7 +2587,7 @@ vshReadlineCommandGenerator(const char *text) if (cmds[cmd_list_index++].flags & VSH_CMD_FLAG_ALIAS) continue; - if (STREQLEN(name, text, len)) { + if (STRPREFIX(name, text)) { if (VIR_REALLOC_N(ret, ret_size + 2) < 0) { g_strfreev(ret); return NULL; -- 2.26.2