Use the new STRLIM macro and unify it with the empty string check.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_conf.c | 11 +++--------
.../machine-loadparm-s390-len-invalid.err | 2 +-
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0203d17e9d..c542782750 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6300,15 +6300,10 @@ virDomainDeviceLoadparmIsValid(const char *loadparm)
{
size_t i;
- if (virStringIsEmpty(loadparm)) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("loadparm cannot be an empty string"));
- return false;
- }
-
- if (strlen(loadparm) > 8) {
+ if (virStringIsEmpty(loadparm) || !STRLIM(loadparm, 8)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("loadparm '%s' exceeds 8 characters"),
loadparm);
+ _("loadparm value '%s' must be between 1 and 8
characters"),
+ loadparm);
return false;
}
diff --git a/tests/qemuxml2argvdata/machine-loadparm-s390-len-invalid.err
b/tests/qemuxml2argvdata/machine-loadparm-s390-len-invalid.err
index 9afaa68ae2..9fd0425f20 100644
--- a/tests/qemuxml2argvdata/machine-loadparm-s390-len-invalid.err
+++ b/tests/qemuxml2argvdata/machine-loadparm-s390-len-invalid.err
@@ -1 +1 @@
-internal error: loadparm 'LOADPARM1' exceeds 8 characters
+internal error: loadparm value 'LOADPARM1' must be between 1 and 8 characters
--
2.31.1