--- src/conf/domain_conf.c | 4 ++-- src/libvirt_private.syms | 2 +- src/util/virstring.c | 18 ++++++++++++++++++ src/util/virstring.h | 2 ++ src/util/virutil.c | 12 ------------ src/util/virutil.h | 2 -- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d2cf8d5..0320691 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7155,7 +7155,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } - if (!virStrIsPrint(vendor)) { + if (!virStringIsPrintable(vendor)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("disk vendor is not printable string")); goto error; @@ -7170,7 +7170,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } - if (!virStrIsPrint(product)) { + if (!virStringIsPrintable(product)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("disk product is not printable string")); goto error; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 068bc00..a79d85e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2265,6 +2265,7 @@ virStringFreeListCount; virStringGetFirstWithPrefix; virStringHasControlChars; virStringIsEmpty; +virStringIsPrintable; virStringJoin; virStringListLength; virStringReplace; @@ -2478,7 +2479,6 @@ virSetNonBlock; virSetSockReuseAddr; virSetUIDGID; virSetUIDGIDWithCaps; -virStrIsPrint; virTristateBoolTypeFromString; virTristateBoolTypeToString; virTristateSwitchTypeFromString; diff --git a/src/util/virstring.c b/src/util/virstring.c index 2d7fbf3..384e3f7 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -1048,3 +1048,21 @@ virStringToUpper(char **dst, const char *src) *dst = cap; return 1; } + + +/** + * virStrIsPrintable: + * + * Returns true @str contains only printable characters. + */ +bool +virStringIsPrintable(const char *str) +{ + size_t i; + + for (i = 0; str[i]; i++) + if (!c_isprint(str[i])) + return false; + + return true; +} diff --git a/src/util/virstring.h b/src/util/virstring.h index 16ed3b2..fd2868a 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -275,4 +275,6 @@ void virStringStripIPv6Brackets(char *str); bool virStringHasControlChars(const char *str); void virStringStripControlChars(char *str); +bool virStringIsPrintable(const char *str); + #endif /* __VIR_STRING_H__ */ diff --git a/src/util/virutil.c b/src/util/virutil.c index b401f8d..1b46ea1 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1600,18 +1600,6 @@ virValidateWWN(const char *wwn) return true; } -bool -virStrIsPrint(const char *str) -{ - size_t i; - - for (i = 0; str[i]; i++) - if (!c_isprint(str[i])) - return false; - - return true; -} - #if defined(major) && defined(minor) int virGetDeviceID(const char *path, int *maj, int *min) diff --git a/src/util/virutil.h b/src/util/virutil.h index b121de0..1e51a25 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -152,8 +152,6 @@ bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); bool virValidateWWN(const char *wwn); -bool virStrIsPrint(const char *str); - int virGetDeviceID(const char *path, int *maj, int *min); -- 2.8.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list