size_t j;
const char *name;
const char *last_name = NULL;
- int type;
size_t nkeys = 0;
size_t nkeysalloc = 0;
g_autofree virTypedParameterPtr sorted = NULL;
name = va_arg(ap, const char *);
while (name) {
- type = va_arg(ap, int);
+ int type = va_arg(ap, int);
VIR_RESIZE_N(keys, nkeysalloc, nkeys, 1);
if (virStrcpyStatic(keys[nkeys].field, name) < 0) {
if (STRNEQ(sorted[i].field, keys[j].field)) {
j++;
} else {
+ const char *expecttype = virTypedParameterTypeToString(keys[j].type);
+ int type = sorted[i].type;
+
if (STREQ_NULLABLE(last_name, sorted[i].field) &&
!(keys[j].value.i & VIR_TYPED_PARAM_MULTIPLE)) {
virReportError(VIR_ERR_INVALID_ARG,
sorted[i].field);
return -1;
}
- if (sorted[i].type != keys[j].type) {
+
+ if (keys[j].type == VIR_TYPED_PARAM_UNSIGNED &&
+ (type == VIR_TYPED_PARAM_UINT ||
+ type == VIR_TYPED_PARAM_ULLONG)) {
+ type = VIR_TYPED_PARAM_UNSIGNED;
+ expecttype = "uint, ullong";
+ }
+
+ if (type != keys[j].type) {
const char *badtype;
badtype = virTypedParameterTypeToString(sorted[i].type);
badtype = virTypedParameterTypeToString(0);
virReportError(VIR_ERR_INVALID_ARG,
_("invalid type '%1$s' for parameter '%2$s', expected '%3$s'"),
- badtype, sorted[i].field,
- virTypedParameterTypeToString(keys[j].type));
+ badtype, sorted[i].field, expecttype);
return -1;
}
last_name = sorted[i].field;
#include "internal.h"
#include "virenum.h"
+
+/**
+ * VIR_TYPED_PARAM_UNSIGNED:
+ *
+ * Special typed parameter type only used with virTypedParamsValidate to
+ * indicate that both VIR_TYPED_PARAM_UINT and VIR_TYPED_PARAM_ULLONG types
+ * are acceptable for given value.
+ */
+#define VIR_TYPED_PARAM_UNSIGNED (VIR_TYPED_PARAM_LAST + 1)
/**
* VIR_TYPED_PARAM_MULTIPLE:
*