mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
util: Add virFileReadValueUllongQuiet
Use function virFileReadValueUllongQuiet to read unsigned long long value without error report. Signed-off-by: Yang Fei <yangfei85@huawei.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d2ce164ee2
commit
b8674109ee
@ -2244,6 +2244,7 @@ virFileReadValueScaledInt;
|
||||
virFileReadValueString;
|
||||
virFileReadValueUint;
|
||||
virFileReadValueUllong;
|
||||
virFileReadValueUllongQuiet;
|
||||
virFileRelLinkPointsTo;
|
||||
virFileRemove;
|
||||
virFileRemoveLastComponent;
|
||||
|
@ -4065,6 +4065,30 @@ virFileReadValueUllong(unsigned long long *value, const char *format, ...)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
virFileReadValueUllongQuiet(unsigned long long *value, const char *format, ...)
|
||||
{
|
||||
g_autofree char *str = NULL;
|
||||
g_autofree char *path = NULL;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
path = g_strdup_vprintf(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (!virFileExists(path))
|
||||
return -2;
|
||||
|
||||
if (virFileReadAllQuiet(path, VIR_INT64_STR_BUFLEN, &str) < 0)
|
||||
return -1;
|
||||
|
||||
virStringTrimOptionalNewline(str);
|
||||
|
||||
if (virStrToLong_ullp(str, NULL, 10, value) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* virFileReadValueScaledInt:
|
||||
|
@ -339,6 +339,8 @@ int virFileReadValueUint(unsigned int *value, const char *format, ...)
|
||||
G_GNUC_PRINTF(2, 3);
|
||||
int virFileReadValueUllong(unsigned long long *value, const char *format, ...)
|
||||
G_GNUC_PRINTF(2, 3);
|
||||
int virFileReadValueUllongQuiet(unsigned long long *value, const char *format, ...)
|
||||
G_GNUC_PRINTF(2, 3);
|
||||
int virFileReadValueBitmap(virBitmap **value, const char *format, ...)
|
||||
G_GNUC_PRINTF(2, 3);
|
||||
int virFileReadValueScaledInt(unsigned long long *value, const char *format, ...)
|
||||
|
Loading…
Reference in New Issue
Block a user