Fix warnings (#17940)
thiagoftsm committed
Jun 18, 2024 at 12:22 UTC
6bcfc4972b1ecd0fb325a14e56b4ac0d91558435
10 files changed
+26
-20
src/collectors/log2journal/log2journal-yaml.c
+1
-1
@@ -85,7 +85,7 @@ static void yaml_error_with_trace(yaml_parser_t *parser, yaml_event_t *event, si
85
#define yaml_parse(parser, event) yaml_parse_with_trace(parser, event, __LINE__, __FUNCTION__, __FILE__)
86
static bool yaml_parse_with_trace(yaml_parser_t *parser, yaml_event_t *event, size_t line __maybe_unused, const char *function __maybe_unused, const char *file __maybe_unused) {
87
if (!yaml_parser_parse(parser, event)) {
88
- yaml_error(parser, NULL, "YAML parser error %d", parser->error);
88
+ yaml_error(parser, NULL, "YAML parser error %u", parser->error);
89
return false;
90
}
91
src/collectors/network-viewer.plugin/network-viewer.c
+4
-4
@@ -125,10 +125,10 @@ static void local_socket_to_json_array(BUFFER *wb, LOCAL_SOCKET *n, uint64_t pro
125
}
126
buffer_json_add_array_item_string(wb, n->network_viewer.remote_address_space);
127
128
- uint16_t server_port;
129
- const char *server_address;
130
- const char *client_address_space;
131
- const char *server_address_space;
128
+ uint16_t server_port = 0;
129
+ const char *server_address = NULL;
130
+ const char *client_address_space = NULL;
131
+ const char *server_address_space = NULL;
132
switch (n->direction) {
133
case SOCKET_DIRECTION_LISTEN:
134
case SOCKET_DIRECTION_INBOUND:
src/collectors/plugins.d/local_listeners.c
+1
-1
@@ -64,7 +64,7 @@ static void print_local_listeners_debug(LS_STATE *ls __maybe_unused, LOCAL_SOCKE
64
(n->direction & (SOCKET_DIRECTION_LOCAL_INBOUND|SOCKET_DIRECTION_LOCAL_OUTBOUND)) ? "LOCAL," : "",
65
(n->direction == 0) ? "NONE," : "",
66
n->pid,
67
- n->state,
67
+ (unsigned int)n->state,
68
n->net_ns_inode,
69
local_address, n->local.port,
70
remote_address, n->remote.port,
src/collectors/proc.plugin/sys_block_zram.c
+3
-3
@@ -128,7 +128,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every)
128
rrdlabels_add(d->st_alloc_efficiency->rrdlabels, "device", name, RRDLABEL_SRC_AUTO);
129
}
130
131
-static int init_devices(DICTIONARY *devices, unsigned int zram_id, int update_every) {
131
+static int init_devices(DICTIONARY *devices, int update_every) {
132
int count = 0;
133
struct dirent *de;
134
struct stat st;
@@ -269,7 +269,7 @@ int do_sys_block_zram(int update_every, usec_t dt) {
269
procfile_close(ff);
270
271
devices = dictionary_create_advanced(DICT_OPTION_SINGLE_THREADED, &dictionary_stats_category_collectors, 0);
272
- device_count = init_devices(devices, (unsigned int)zram_id, update_every);
272
+ device_count = init_devices(devices, update_every);
273
}
274
275
if (unlikely(device_count < 1))
@@ -277,4 +277,4 @@ int do_sys_block_zram(int update_every, usec_t dt) {
277
278
dictionary_walkthrough_write(devices, collect_zram_metrics, devices);
279
return 0;
280
-}
\ No newline at end of file
280
+}
src/database/KolmogorovSmirnovDist.c
+2
-2
@@ -697,8 +697,8 @@ static double DurbinMatrix (int n, double d)
697
k = (int) (n * d) + 1;
698
m = 2 * k - 1;
699
h = k - n * d;
700
- H = (double *) malloc ((m * m) * sizeof (double));
701
- Q = (double *) malloc ((m * m) * sizeof (double));
700
+ H = (double *) calloc ((m * m), sizeof (double));
701
+ Q = (double *) calloc ((m * m), sizeof (double));
702
for (i = 0; i < m; i++)
703
for (j = 0; j < m; j++)
704
if (i - j + 1 < 0)
src/database/engine/datafile.c
+2
-2
@@ -245,7 +245,7 @@ int create_data_file(struct rrdengine_datafile *datafile)
245
uv_fs_t req;
246
uv_file file;
247
int ret, fd;
248
- struct rrdeng_df_sb *superblock;
248
+ struct rrdeng_df_sb *superblock = NULL;
249
uv_buf_t iov;
250
char path[RRDENG_PATH_MAX];
251
@@ -291,7 +291,7 @@ int create_data_file(struct rrdengine_datafile *datafile)
291
static int check_data_file_superblock(uv_file file)
292
{
293
int ret;
294
- struct rrdeng_df_sb *superblock;
294
+ struct rrdeng_df_sb *superblock = NULL;
295
uv_buf_t iov;
296
uv_fs_t req;
297
src/database/engine/dbengine-compression.c
+8
-2
@@ -60,8 +60,11 @@ size_t dbengine_max_compressed_size(size_t uncompressed_size, uint8_t algorithm)
60
case RRDENG_COMPRESSION_NONE:
61
return uncompressed_size;
62
63
- default:
63
+ default: {
64
fatal("DBENGINE: unknown compression algorithm %u", algorithm);
65
+ //we will never reach this point, but we have warnings from compiler
66
+ return 0;
67
+ }
68
}
69
}
70
@@ -117,8 +120,11 @@ size_t dbengine_compress(void *payload, size_t uncompressed_size, uint8_t algori
120
case RRDENG_COMPRESSION_NONE:
121
return 0;
122
120
- default:
123
+ default: {
124
fatal("DBENGINE: unknown compression algorithm %u", algorithm);
125
+ //we will never reach this point, but we have warnings from compiler
126
+ return 0;
127
+ }
128
}
129
}
130
src/database/engine/journalfile.c
+3
-3
@@ -573,7 +573,7 @@ int journalfile_create(struct rrdengine_journalfile *journalfile, struct rrdengi
573
uv_fs_t req;
574
uv_file file;
575
int ret, fd;
576
- struct rrdeng_jf_sb *superblock;
576
+ struct rrdeng_jf_sb *superblock = NULL;
577
uv_buf_t iov;
578
char path[RRDENG_PATH_MAX];
579
@@ -619,7 +619,7 @@ int journalfile_create(struct rrdengine_journalfile *journalfile, struct rrdengi
619
static int journalfile_check_superblock(uv_file file)
620
{
621
int ret;
622
- struct rrdeng_jf_sb *superblock;
622
+ struct rrdeng_jf_sb *superblock = NULL;
623
uv_buf_t iov;
624
uv_fs_t req;
625
@@ -811,7 +811,7 @@ static uint64_t journalfile_iterate_transactions(struct rrdengine_instance *ctx,
811
int ret;
812
uint64_t pos, pos_i, max_id, id;
813
unsigned size_bytes;
814
- void *buf;
814
+ void *buf = NULL;
815
uv_buf_t iov;
816
uv_fs_t req;
817
src/database/engine/pdc.c
+1
-1
@@ -1179,7 +1179,7 @@ static bool epdl_populate_pages_from_extent_data(
1179
1180
static inline void *datafile_extent_read(struct rrdengine_instance *ctx, uv_file file, unsigned pos, unsigned size_bytes)
1181
{
1182
- void *buffer;
1182
+ void *buffer = NULL;
1183
uv_fs_t request;
1184
1185
unsigned real_io_size = ALIGN_BYTES_CEILING(size_bytes);
src/health/health_dyncfg.c
+1
-1
@@ -152,7 +152,7 @@ static bool parse_config(json_object *jobj, const char *path, RRD_ALERT_PROTOTYP
152
}
153
154
static bool parse_prototype(json_object *jobj, const char *path, RRD_ALERT_PROTOTYPE *base, BUFFER *error, const char *name, bool strict) {
155
- int64_t version;
155
+ int64_t version = 0;
156
JSONC_PARSE_INT_OR_ERROR_AND_RETURN(jobj, path, "format_version", version, error, strict);
157
158
if(version != 1) {