Open
Description
- Version of collectd: collectd-6.0 git
- Operating system / distribution: Fedora 38
Steps to reproduce
- Prepare
config.h
:./configure
- build (most of) collectd core files with stricter warnings:
for i in $(find src/ -mindepth 3 -name '*.c' | grep -v -e /dpdk/ -e format_json.c -e format_kairosdb.c -e _mock.c -e _test.c -e _windows.c); do \
echo "*** $i ***"; \
gcc -I. -Isrc -Isrc/daemon -Isrc/libcollectdclient -DHAVE_CONFIG_H -O3 -Werror -Wall -Wextra -Wno-missing-field-initializers -Wcast-align=strict -Wformat-security -Wnull-dereference -Wstrict-overflow=2 -Warray-bounds=2 -D_FORTIFY_SOURCE=2 -Wno-aggressive-loop-optimizations -c -o /dev/null $i; \
done
(I do not have compatible include files for the files I've left out, and warnings from mock/test/windows files were not that relevant. Proper warning analysis requires use of high optimization level.)
Actual output
Output shows few warnings:
*** src/utils/cmds/listval.c ***
*** src/utils/cmds/putnotif.c ***
*** src/utils/cmds/putval.c ***
*** src/utils/cmds/putmetric.c ***
*** src/utils/cmds/flush.c ***
*** src/utils/cmds/parse_option.c ***
*** src/utils/cmds/getthreshold.c ***
*** src/utils/cmds/getval.c ***
*** src/utils/cmds/cmds.c ***
*** src/utils/curl_stats/curl_stats.c ***
*** src/utils/resource_metrics/resource_metrics.c ***
*** src/utils/value_list/value_list.c ***
*** src/utils/format_json/open_telemetry.c ***
*** src/utils/ignorelist/ignorelist.c ***
*** src/utils/crc32/crc32.c ***
*** src/utils/format_influxdb/format_influxdb.c ***
*** src/utils/gce/gce.c ***
*** src/utils/avltree/avltree.c ***
*** src/utils/oauth/oauth.c ***
*** src/utils/taskstats/taskstats.c ***
*** src/utils/utf8/utf8.c ***
*** src/utils/ovs/ovs.c ***
src/utils/ovs/ovs.c: In function ‘ovs_yajl_gen_val’:
src/utils/ovs/ovs.c:365:13: error: potential null pointer dereference [-Werror=null-dereference]
365 | obj_len = YAJL_GET_OBJECT(jval)->len;
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/utils/ovs/ovs.c:368:41: error: potential null pointer dereference [-Werror=null-dereference]
368 | jobj_value = YAJL_GET_OBJECT(jval)->values[i];
| ^
src/utils/ovs/ovs.c:367:38: error: null pointer dereference [-Werror=null-dereference]
367 | obj_key = YAJL_GET_OBJECT(jval)->keys[i];
| ^
cc1: all warnings being treated as errors
*** src/utils/heap/heap.c ***
*** src/utils/format_graphite/format_graphite.c ***
*** src/utils/rrdcreate/rrdcreate.c ***
*** src/utils/match/match.c ***
*** src/utils/tail/tail.c ***
*** src/utils/strbuf/strbuf.c ***
*** src/utils/lookup/vl_lookup.c ***
*** src/utils/message_parser/message_parser.c ***
src/utils/message_parser/message_parser.c: In function ‘start_message_assembly’:
src/utils/message_parser/message_parser.c:91:25: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
91 | if (self->message_idx >= self->messages_max_len) {
| ^~
src/utils/message_parser/message_parser.c: In function ‘message_assembler’:
src/utils/message_parser/message_parser.c:150:42: error: unused parameter ‘row’ [-Werror=unused-parameter]
150 | static int message_assembler(const char *row, char *const *matches,
| ~~~~~~~~~~~~^~~
cc1: all warnings being treated as errors
*** src/utils/dmi/dmi.c ***
*** src/utils/dns/dns.c ***
src/utils/dns/dns.c: In function ‘ignore_list_add_name’:
src/utils/dns/dns.c:228:16: error: cast increases required alignment of target type [-Werror=cast-align]
228 | &((struct sockaddr_in *)ai_ptr->ai_addr)->sin_addr, 4);
| ^
src/utils/dns/dns.c:232:25: error: cast increases required alignment of target type [-Werror=cast-align]
232 | ignore_list_add(&((struct sockaddr_in6 *)ai_ptr->ai_addr)->sin6_addr);
| ^
cc1: all warnings being treated as errors
*** src/utils/db_query/db_query.c ***
*** src/utils/format_stackdriver/format_stackdriver.c ***
src/utils/format_stackdriver/format_stackdriver.c: In function ‘read_cumulative_state’:
src/utils/format_stackdriver/format_stackdriver.c:295:36: error: comparison of integer expressions of different signedness: ‘int64_t’ {aka ‘long int’} and ‘counter_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
295 | bool is_reset = *ret_start_value > m->value.counter;
| ^
cc1: all warnings being treated as errors
*** src/utils/metadata/meta_data.c ***
*** src/utils/common/common.c ***
*** src/utils/latency/latency.c ***
*** src/utils/latency/latency_config.c ***
*** src/utils/proc_pids/proc_pids.c ***
src/utils/proc_pids/proc_pids.c: In function ‘pids_list_contains_pid’:
src/utils/proc_pids/proc_pids.c:119:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
119 | for (int i = 0; i < list->size; i++)
| ^
src/utils/proc_pids/proc_pids.c: In function ‘pids_list_diff’:
src/utils/proc_pids/proc_pids.c:333:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
333 | for (int i = 0; i < proc->prev->size; i++)
| ^
src/utils/proc_pids/proc_pids.c:340:21: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
340 | for (int i = 0; i < proc->curr->size; i++)
| ^
cc1: all warnings being treated as errors
*** src/utils/mount/mount.c ***
*** src/utils/config_cores/config_cores.c ***