[libvirt] [PATCH v2 02/42] util: handle missing switch enum cases
Ján Tomko
jtomko at redhat.com
Tue Feb 20 09:49:29 UTC 2018
On Thu, Feb 15, 2018 at 04:43:07PM +0000, Daniel P. Berrangé wrote:
>Ensure all enum cases are listed in switch statements.
>
>Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
>---
> src/util/virconf.c | 13 ++++++++++++-
> src/util/virfirewall.c | 7 +++++--
> src/util/virlog.c | 10 +++++++++-
> src/util/virnetdevvportprofile.c | 11 ++++++++++-
> 4 files changed, 36 insertions(+), 5 deletions(-)
>
>diff --git a/src/util/virconf.c b/src/util/virconf.c
>index a82a509ca3..af806dd735 100644
>--- a/src/util/virconf.c
>+++ b/src/util/virconf.c
>@@ -296,7 +296,10 @@ virConfSaveValue(virBufferPtr buf, virConfValuePtr val)
> virBufferAddLit(buf, " ]");
> break;
> }
>+ case VIR_CONF_LAST:
> default:
>+ virReportError(VIR_ERR_INTERNAL_ERROR,
>+ _("Unexpected conf value type %d"), val->type);
> return -1;
All these errors are presumably dead code that we only keep around in
case we broke something in other parts of the code.
Do we need specific user-friendly translated errors? Since we log the
function name as well, something like: "unhandled enum value %d" would
do.
Jan
> }
> return 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180220/2bce950e/attachment-0001.sig>
More information about the libvir-list
mailing list