[PATCH] Add a default case for switch over dc_family_t

Anton Lundin glance at acc.umu.se
Wed Apr 29 14:47:56 PDT 2015


This adds a default case which just errors out for the switch over
dc_family_t instead of checking a uninitialized variable if this was
ever called with something else than one of the expected dc-family
types.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 libdivecomputer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libdivecomputer.c b/libdivecomputer.c
index 069e87b..f07023f 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -963,6 +963,9 @@ dc_status_t libdc_buffer_parser(struct dive *dive, device_data_t *data, unsigned
 	case DC_FAMILY_HW_OSTC3:
 		rc = hw_ostc_parser_create (&parser, data->context, data->deviceid, 1);
 		break;
+	default:
+		report_error("Device type not handled!");
+		return DC_STATUS_UNSUPPORTED;
 	}
 	if  (rc != DC_STATUS_SUCCESS) {
 		report_error("Error creating parser.");
-- 
2.1.4



More information about the subsurface mailing list