diff options
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | ReleaseNotes.txt | 3 | ||||
-rwxr-xr-x | scripts/buildtests.sh | 11 | ||||
-rw-r--r-- | src/libical/icalcomponent.c | 2 | ||||
-rw-r--r-- | src/libical/icalparser.c | 4 | ||||
-rw-r--r-- | src/libical/icalrestriction.c.in | 25 | ||||
-rw-r--r-- | src/libical/icaltz-util.c | 4 | ||||
-rw-r--r-- | src/libicalss/icalssyacc.c | 9 | ||||
-rw-r--r-- | src/test/regression-component.c | 12 | ||||
-rw-r--r-- | src/test/regression-storage.c | 3 | ||||
-rw-r--r-- | src/test/stow.c | 4 |
11 files changed, 56 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f889f985..6ac0c7f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -510,6 +510,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang") check_c_compiler_flag(-Wsizeof-pointer-memaccess HAVE_GCC_POINTER_MEMACCESS) check_c_compiler_flag(-Wformat-security HAVE_GCC_FORMAT_SECURITY) check_c_compiler_flag(-Wredundant-decls HAVE_GCC_REDUNDANT_DECLS) + check_c_compiler_flag(-Wunreachable-code HAVE_GCC_UNREACHABLE_CODE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -Wno-deprecated -Wall -Wno-unknown-pragmas -Wextra -Winit-self -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wtype-limits -Wwrite-strings -Werror=return-type") if(HAVE_GCC_UNUSED_BUT_SET) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-but-set-variable") @@ -526,6 +527,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang") if(HAVE_GCC_REDUNDANT_DECLS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wredundant-decls") endif() + if(HAVE_GCC_UNREACHABLE_CODE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunreachable-code") + endif() if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE -D_GNU_SOURCE") endif() @@ -542,6 +546,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") check_cxx_compiler_flag(-Wreorder HAVE_GXX_REORDER) check_cxx_compiler_flag(-Wformat-security HAVE_GXX_FORMAT_SECURITY) check_cxx_compiler_flag(-Wredundant-decls HAVE_GXX_REDUNDANT_DECLS) + check_cxx_compiler_flag(-Wunreachable-code HAVE_GXX_UNREACHABLE_CODE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Weffc++ -Wno-deprecated -Wall -Wextra -Woverloaded-virtual -Winit-self -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wtype-limits -Wwrite-strings -Werror=return-type") if(HAVE_GXX_UNUSED_BUT_SET) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-variable") @@ -561,6 +566,9 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if(HAVE_GXX_REDUNDANT_DECLS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wredundant-decls") endif() + if(HAVE_GXX_UNREACHABLE_CODE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunreachable-code") + endif() if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_XOPEN_SOURCE=500 -D_DEFAULT_SOURCE -D_GNU_SOURCE") endif() diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 4d1cad00..98826346 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -9,7 +9,8 @@ Version 3.0.15 (UNRELEASED): to work properly between years 1902 and 10k. * Fix x-property comma handling and escaping * Built-in timezones updated to tzdata2022d (now with a VTIMEZONE for each time zone alias) - * Fix a fuzzer issue + * Fix fuzzer issues + * Handle unreachable-code compile warnings with clang Version 3.0.14 (05 February 2022): ---------------------------------- diff --git a/scripts/buildtests.sh b/scripts/buildtests.sh index b670ea09..c379ddce 100755 --- a/scripts/buildtests.sh +++ b/scripts/buildtests.sh @@ -553,6 +553,7 @@ then fi fi +DEFCMAKEOPTS="-DCMAKE_BUILD_TYPE=Debug" CMAKEOPTS="-DCMAKE_BUILD_TYPE=Debug -DGOBJECT_INTROSPECTION=False -DICAL_GLIB=False -DICAL_BUILD_DOCS=False" UUCCMAKEOPTS="$CMAKEOPTS -DCMAKE_DISABLE_FIND_PACKAGE_ICU=True" TZCMAKEOPTS="$CMAKEOPTS -DUSE_BUILTIN_TZDATA=True" @@ -570,7 +571,7 @@ CLANGTIDY test2 "$CMAKEOPTS" CLANGTIDY test2builtin "$TZCMAKEOPTS" #GCC based build tests -GCC_BUILD testgcc1 "" +GCC_BUILD testgcc1 "$DEFCMAKEOPTS" GCC_BUILD testgcc2 "$CMAKEOPTS" GCC_BUILD testgcc3 "$UUCCMAKEOPTS" GCC_BUILD testgcc4glib "$GLIBOPTS" @@ -584,7 +585,7 @@ GCC_BUILD testgcc1builtin "-DUSE_BUILTIN_TZDATA=True" GCC_BUILD testgcc2builtin "$TZCMAKEOPTS" #Ninja build tests -NINJA_GCC_BUILD testninjagcc1 "" +NINJA_GCC_BUILD testninjagcc1 "$DEFCMAKEOPTS" NINJA_GCC_BUILD testninjagcc2 "-DICAL_GLIB=True" NINJA_GCC_BUILD testninjagcc3 "-DICAL_GLIB=True -DICAL_GLIB_VAPI=ON -DGOBJECT_INTROSPECTION=True" NINJA_GCC_BUILD testninjagcc4 "-DSHARED_ONLY=True -DICAL_GLIB=False" @@ -593,7 +594,7 @@ NINJA_GCC_BUILD testninjagcc6 "-DSTATIC_ONLY=True -DICAL_GLIB=False" NINJA_GCC_BUILD testninjagcc7 "-DSTATIC_ONLY=True -DICAL_GLIB=True -DENABLE_GTK_DOC=False" NINJA_GCC_BUILD testninjagcc9 "-DSHARED_ONLY=True -DICAL_GLIB=True -DGOBJECT_INTROSPECTION=True -DICAL_GLIB_VAPI=ON" -CLANG_BUILD testclang1 "" +CLANG_BUILD testclang1 "$DEFCMAKEOPTS" CLANG_BUILD testclang2 "$CMAKEOPTS" CLANG_BUILD testclang3 "$UUCCMAKEOPTS" CLANG_BUILD testclang4glib "$GLIBOPTS" @@ -605,14 +606,14 @@ then fi #Address sanitizer -ASAN_BUILD test1asan "" +ASAN_BUILD test1asan "$DEFCMAKEOPTS" ASAN_BUILD test2asan "$CMAKEOPTS" ASAN_BUILD test3asan "$TZCMAKEOPTS" ASAN_BUILD test4asan "$UUCCMAKEOPTS" ASAN_BUILD test5asan "$GLIBOPTS" #Thread sanitizer -TSAN_BUILD test1tsan "" +TSAN_BUILD test1tsan "$DEFCMAKEOPTS" TSAN_BUILD test2tsan "$CMAKEOPTS" TSAN_BUILD test3tsan "$TZCMAKEOPTS" TSAN_BUILD test4tsan "$UUCCMAKEOPTS" diff --git a/src/libical/icalcomponent.c b/src/libical/icalcomponent.c index cef5df5d..bc160a04 100644 --- a/src/libical/icalcomponent.c +++ b/src/libical/icalcomponent.c @@ -865,7 +865,7 @@ void icalcomponent_foreach_recurrence(icalcomponent *comp, icaltimetype mystart = start; /* make sure we include any recurrence that ends in timespan */ - icaltime_adjust(&mystart, 0, 0, 0, -(int)dtduration); + icaltime_adjust(&mystart, 0, 0, 0, -(int)(long)dtduration); icalrecur_iterator_set_start(rrule_itr, mystart); } diff --git a/src/libical/icalparser.c b/src/libical/icalparser.c index ebb10970..5ddab29b 100644 --- a/src/libical/icalparser.c +++ b/src/libical/icalparser.c @@ -630,6 +630,7 @@ icalcomponent *icalparser_parse(icalparser *parser, icalparser_line_gen_func line_gen_func) { char *line; + unsigned int cnt = 0; icalcomponent *c = 0; icalcomponent *root = 0; icalerrorstate es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR); @@ -640,6 +641,7 @@ icalcomponent *icalparser_parse(icalparser *parser, icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR, ICAL_ERROR_NONFATAL); do { + cnt++; line = icalparser_get_line(parser, line_gen_func); if ((c = icalparser_add_line(parser, line)) != 0) { @@ -679,7 +681,7 @@ icalcomponent *icalparser_parse(icalparser *parser, icalmemory_free_buffer(line); cont = 1; } - } while (cont); + } while (cont && cnt < TMP_BUF_SIZE); icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR, es); diff --git a/src/libical/icalrestriction.c.in b/src/libical/icalrestriction.c.in index e36773f1..3931fcb0 100644 --- a/src/libical/icalrestriction.c.in +++ b/src/libical/icalrestriction.c.in @@ -331,19 +331,24 @@ static int icalrestriction_check_component(icalproperty_method method, icalcompo assert(compare != -1); if (compare == 0) { -#define TMP_BUF_SIZE 1024 +#if !defined(__COVERITY__) + /* Coverity doesn't think the memory allocated by icalparameter_new_xlicerrortype() + * is freed, even though it should be freed in icalproperty_free() + */ + #define TMP_BUF_SIZE 1024 char temp[TMP_BUF_SIZE]; icalproperty *errProp; - icalparameter *errParam; snprintf(temp, TMP_BUF_SIZE, "Failed iTIP restrictions for %s property. " "Expected %s instances of the property and got %d", icalenum_property_kind_to_string(kind), restr_string_map[restr], count); - errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP); - errProp = icalproperty_vanew_xlicerror(temp, errParam, 0); + errProp = + icalproperty_vanew_xlicerror( + temp, icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP), 0); icalcomponent_add_property(comp, errProp); icalproperty_free(errProp); +#endif } prop = icalcomponent_get_first_property(comp, kind); @@ -353,15 +358,19 @@ static int icalrestriction_check_component(icalproperty_method method, icalcompo } if (funcr != 0) { +#if !defined(__COVERITY__) + /* Coverity doesn't think the memory allocated by icalparameter_new_xlicerrortype() + * is freed, even though it should be freed in icalproperty_free() + */ icalproperty *errProp; - icalparameter *errParam; - errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP); - errProp = icalproperty_vanew_xlicerror(funcr, errParam, 0); + errProp = + icalproperty_vanew_xlicerror( + funcr, icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP), 0); icalcomponent_add_property(comp, errProp); icalproperty_free(errProp); - compare = 0; +#endif } valid = valid && compare; diff --git a/src/libical/icaltz-util.c b/src/libical/icaltz-util.c index 20642874..ab5b6f85 100644 --- a/src/libical/icaltz-util.c +++ b/src/libical/icaltz-util.c @@ -631,8 +631,8 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) /* Read the footer */ if (trans_size == 8 && - (footer[0] = fgetc(f)) == '\n' && - fgets(footer+1, (int) sizeof(footer)-1, f) && + (footer[0] = (char)fgetc(f)) == '\n' && + fgets(footer+1, (int)sizeof(footer)-1, f) && footer[strlen(footer)-1] == '\n') { tzstr = footer+1; } diff --git a/src/libicalss/icalssyacc.c b/src/libicalss/icalssyacc.c index 61b1f502..e386ad80 100644 --- a/src/libicalss/icalssyacc.c +++ b/src/libicalss/icalssyacc.c @@ -1317,6 +1317,7 @@ yyparse () YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); + /* coverity[OVERRUN] */ if (yyss + yystacksize - 1 <= yyssp) YYABORT; } @@ -1418,9 +1419,9 @@ yyreduce: users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ + /* coverity[uninit_use] */ yyval = yyvsp[1-yylen]; - YY_REDUCE_PRINT (yyn); switch (yyn) { @@ -1598,9 +1599,11 @@ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ - if (/*CONSTCOND*/ 0) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" + if (/*CONSTCOND*/ 0) goto yyerrorlab; - +#pragma clang diagnostic pop /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); diff --git a/src/test/regression-component.c b/src/test/regression-component.c index caed9af4..7efe3429 100644 --- a/src/test/regression-component.c +++ b/src/test/regression-component.c @@ -291,7 +291,7 @@ void create_new_component_with_va_args() static void print_span(int c, struct icaltime_span span) { - printf("span-->%d, %d\n", (int)span.start, (int)span.end); + printf("span-->%ld, %ld\n", (long)span.start, (long)span.end); if (span.start == 0) { printf("#%02d start: (empty)\n", c); } else { @@ -364,7 +364,7 @@ void test_icalcomponent_get_span() if (VERBOSE) print_span(tnum++, span); - int_is("floating time", (int)span.start, (int)tm1); + int_is("floating time", (int)(long)span.start, (int)(long)tm1); icalcomponent_free(c); @@ -448,7 +448,7 @@ void test_icalcomponent_get_span() if (VERBOSE) print_span(tnum++, span); - int_is("start == end", (int)span.start, (int)span.end); + int_is("start == end", (int)(long)span.start, (int)(long)span.end); icalcomponent_free(c); /** test 7 @@ -464,7 +464,7 @@ void test_icalcomponent_get_span() if (VERBOSE) print_span(tnum++, span); - int_is("UTC", (int)span.start, 973296000); + int_is("UTC", (int)(long)span.start, 973296000); icalcomponent_free(c); /** test 8 @@ -476,7 +476,7 @@ void test_icalcomponent_get_span() (void *)0); span = icalcomponent_get_span(c); - int_is("UTC #2", (int)span.start, 973296000); + int_is("UTC #2", (int)(long)span.start, 973296000); if (VERBOSE) print_span(tnum++, span); @@ -493,7 +493,7 @@ void test_icalcomponent_get_span() if (VERBOSE) print_span(tnum++, span); - int_is("start date only", (int)span.end, 973382399); + int_is("start date only", (int)(long)span.end, 973382399); icalcomponent_free(c); diff --git a/src/test/regression-storage.c b/src/test/regression-storage.c index 7ce594d2..eb11f6d5 100644 --- a/src/test/regression-storage.c +++ b/src/test/regression-storage.c @@ -305,6 +305,8 @@ void test_bdbset() return; // for now... TODO fix these broken tests.. +#pragma clang diagnostic push /* remove when/if we remove the proceeding return statement */ +#pragma clang diagnostic ignored "-Wunreachable-code" start = icaltime_from_timet_with_zone(time(0), 0, NULL); end = start; end.hour++; @@ -452,6 +454,7 @@ void test_bdbset() } icalset_free(cout); } +#pragma clang diagnostic pop } #endif diff --git a/src/test/stow.c b/src/test/stow.c index a02186ac..2d3e4473 100644 --- a/src/test/stow.c +++ b/src/test/stow.c @@ -183,8 +183,8 @@ char *make_mime(const char *to, const char *from, const char *subject, uname(&uts); srand((unsigned int)(time(0) << getpid())); - snprintf(content_id, TMPSIZE_SMALL, "%d-%d@%s", (int)time(0), rand(), uts.nodename); - snprintf(boundary, TMPSIZE_SMALL, "%d-%d-%s", (int)time(0), rand(), uts.nodename); + snprintf(content_id, TMPSIZE_SMALL, "%ld-%d@%s", (long)time(0), rand(), uts.nodename); + snprintf(boundary, TMPSIZE_SMALL, "%ld-%d-%s", (long)time(0), rand(), uts.nodename); //krazy:cond=style snprintf(mime_part_1, TMPSIZE, "Content-ID: %s\n\ Content-type: text/plain\n\ |