Even if the compiler has validated that all enum constants have case
statements in a switch, it is not safe to omit a default: case
statement. When assigning a value to a variable / struct field that is
defined with an enum type, nothing prevents an invalid value being
assigned. So defensive code must assume existance of invalid values and
thus all switches should have a default: case.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/test/test_driver.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 043caa9762..6eabfc1cfa 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2921,6 +2921,8 @@ testNodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
VIR_NODE_CPU_STATS_IOWAIT, 763600000) < 0)
return -1;
break;
+ default:
+ break;
}
}
--
2.14.3