
On Fri, Apr 10, 2015 at 14:58:57 +0200, Ján Tomko wrote:
For future reuse in the snapshot XML. --- src/conf/storage_conf.c | 16 ++-------------- src/util/virstoragefile.c | 29 +++++++++++++++++++++++++++++ src/util/virstoragefile.h | 1 + 3 files changed, 32 insertions(+), 14 deletions(-)
...
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 96be02e..c1246e7 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2873,3 +2873,32 @@ virStorageFileGetRelativeBackingPath(virStorageSourcePtr top, VIR_FREE(tmp); return ret; } + + +/* + * virStorageFileCheckCompat + */ +bool +virStorageFileCheckCompat(const char *compat) +{ + char **version; + unsigned int result; + bool ret; + + if (!compat) + return true; + + version = virStringSplit(compat, ".", 2); + if (!version || !version[1] || + virStrToLong_ui(version[0], NULL, 10, &result) < 0 || + virStrToLong_ui(version[1], NULL, 10, &result) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("forbidden characters in 'compat' attribute")); + goto cleanup;
Functions that set errors usually return an integer despite only returning two possible values in total.
+ } + ret = true; + + cleanup: + virStringFreeList(version); + return ret; +}
ACK if you change the return type to 'int' or add a documentation comment explaining when the error is set. Peter