mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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
|
/* Return a non-NULL string representation of a typed parameter; exit on
|
||||||
* if we are out of memory. */
|
* unknown type. */
|
||||||
char *
|
char *
|
||||||
vshGetTypedParamValue(vshControl *ctl, virTypedParameterPtr item)
|
vshGetTypedParamValue(vshControl *ctl, virTypedParameterPtr item)
|
||||||
{
|
{
|
||||||
char *str = NULL;
|
|
||||||
|
|
||||||
switch (item->type) {
|
switch (item->type) {
|
||||||
case VIR_TYPED_PARAM_INT:
|
case VIR_TYPED_PARAM_INT:
|
||||||
str = g_strdup_printf("%d", item->value.i);
|
return g_strdup_printf("%d", item->value.i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_TYPED_PARAM_UINT:
|
case VIR_TYPED_PARAM_UINT:
|
||||||
str = g_strdup_printf("%u", item->value.ui);
|
return g_strdup_printf("%u", item->value.ui);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_TYPED_PARAM_LLONG:
|
case VIR_TYPED_PARAM_LLONG:
|
||||||
str = g_strdup_printf("%lld", item->value.l);
|
return g_strdup_printf("%lld", item->value.l);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_TYPED_PARAM_ULLONG:
|
case VIR_TYPED_PARAM_ULLONG:
|
||||||
str = g_strdup_printf("%llu", item->value.ul);
|
return g_strdup_printf("%llu", item->value.ul);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_TYPED_PARAM_DOUBLE:
|
case VIR_TYPED_PARAM_DOUBLE:
|
||||||
str = g_strdup_printf("%f", item->value.d);
|
return g_strdup_printf("%f", item->value.d);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_TYPED_PARAM_BOOLEAN:
|
case VIR_TYPED_PARAM_BOOLEAN:
|
||||||
str = g_strdup(item->value.b ? _("yes") : _("no"));
|
return g_strdup(item->value.b ? _("yes") : _("no"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_TYPED_PARAM_STRING:
|
case VIR_TYPED_PARAM_STRING:
|
||||||
str = g_strdup(item->value.s);
|
return g_strdup(item->value.s);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
vshError(ctl, _("unimplemented parameter type %d"), item->type);
|
vshError(ctl, _("unimplemented parameter type %d"), item->type);
|
||||||
}
|
|
||||||
|
|
||||||
if (!str) {
|
|
||||||
vshError(ctl, "%s", _("Out of memory"));
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user