Re: [PATCH v2 02/42] util: handle missing switch enum cases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
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;

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux