From e4af758af9ae91ced926f0eb6e6fd307a1e6038b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Thu, 14 Jun 2018 23:00:43 +0200 Subject: [PATCH] Build with -Wswitch-default, and address warnings --- CMakeLists.txt | 2 +- src/cn-cbor.c | 4 ++++ src/cn-encoder.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e076dc8..32ac5b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ message ( "Build type: ${CMAKE_BUILD_TYPE}" ) if ( CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang" ) message ( STATUS "adding GCC/Clang options ") - add_definitions ( -std=gnu99 -Wall -Wextra -pedantic ) + add_definitions ( -std=gnu99 -Wall -Wextra -pedantic -Wswitch-default ) if ( fatal_warnings ) add_definitions ( -Werror ) endif () diff --git a/src/cn-cbor.c b/src/cn-cbor.c index 9093537..77aab40 100644 --- a/src/cn-cbor.c +++ b/src/cn-cbor.c @@ -162,6 +162,8 @@ static cn_cbor *decode_item (struct parse_buf *pb CBOR_CONTEXT, cn_cbor* top_par } else { CN_CBOR_FAIL(CN_CBOR_ERR_MT_UNDEF_FOR_INDEF); } + default: + break; } // process content switch (mt) { @@ -222,6 +224,8 @@ static cn_cbor *decode_item (struct parse_buf *pb CBOR_CONTEXT, cn_cbor* top_par break; default: cb->v.uint = val; } + default: + break; } fill: /* emulate loops */ if (parent->flags & CN_CBOR_FL_INDEF) { diff --git a/src/cn-encoder.c b/src/cn-encoder.c index d8a4d49..cb5d727 100644 --- a/src/cn-encoder.c +++ b/src/cn-encoder.c @@ -285,6 +285,8 @@ void _encoder_visitor(const cn_cbor *cb, int depth, void *context) case CN_CBOR_INVALID: ws->offset = -1; break; + default: + break; } }