
On Tue, Feb 20, 2018 at 10:49:29AM +0100, Ján Tomko wrote:
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@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.
The function name only gets into the logs - not the error reporting, so if someone does get an error raised, I don't want it to be a totally generic message that could come from literally anywhere in the codebase. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|