mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
vsh: Don't check for OOM in vshGetTypedParamValue()
Both function description and function itself mention check for OOM which can't happen really. There was a bug in glib where g_strdup_*() might have not aborted on OOM, but we have our own implementation when dealing with broken glib (see vir_g_strdup_printf()). Therefore, checking for OOM is redundant and can never be true. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
40f5c8679a
commit
bf9074c6a8
25
tools/vsh.c
25
tools/vsh.c
@ -1806,51 +1806,44 @@ vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout)
|
||||
* ---------------
|
||||
*/
|
||||
|
||||
/* Return a non-NULL string representation of a typed parameter; exit
|
||||
* if we are out of memory. */
|
||||
/* Return a non-NULL string representation of a typed parameter; exit on
|
||||
* unknown type. */
|
||||
char *
|
||||
vshGetTypedParamValue(vshControl *ctl, virTypedParameterPtr item)
|
||||
{
|
||||
char *str = NULL;
|
||||
|
||||
switch (item->type) {
|
||||
case VIR_TYPED_PARAM_INT:
|
||||
str = g_strdup_printf("%d", item->value.i);
|
||||
return g_strdup_printf("%d", item->value.i);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_UINT:
|
||||
str = g_strdup_printf("%u", item->value.ui);
|
||||
return g_strdup_printf("%u", item->value.ui);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_LLONG:
|
||||
str = g_strdup_printf("%lld", item->value.l);
|
||||
return g_strdup_printf("%lld", item->value.l);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_ULLONG:
|
||||
str = g_strdup_printf("%llu", item->value.ul);
|
||||
return g_strdup_printf("%llu", item->value.ul);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_DOUBLE:
|
||||
str = g_strdup_printf("%f", item->value.d);
|
||||
return g_strdup_printf("%f", item->value.d);
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_BOOLEAN:
|
||||
str = g_strdup(item->value.b ? _("yes") : _("no"));
|
||||
return g_strdup(item->value.b ? _("yes") : _("no"));
|
||||
break;
|
||||
|
||||
case VIR_TYPED_PARAM_STRING:
|
||||
str = g_strdup(item->value.s);
|
||||
return g_strdup(item->value.s);
|
||||
break;
|
||||
|
||||
default:
|
||||
vshError(ctl, _("unimplemented parameter type %d"), item->type);
|
||||
}
|
||||
|
||||
if (!str) {
|
||||
vshError(ctl, "%s", _("Out of memory"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user