Skip to content

Commit 4427d42

Browse files
cosmo0920edsiper
authored andcommitted
in_process_exporter_metrics: Initialize with NULL for flb_sds_t pointer variables (CID 507975)
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent ee797ab commit 4427d42

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

plugins/in_process_exporter_metrics/pe_process.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static void reset_proc_state(struct proc_state *state) {
276276
static int check_path_for_proc(struct flb_pe *ctx, const char *prefix, const char *path)
277277
{
278278
int len;
279-
flb_sds_t p;
279+
flb_sds_t p = NULL;
280280

281281
/* Compose the proc path */
282282
p = flb_sds_create(prefix);
@@ -303,8 +303,8 @@ static int check_path_for_proc(struct flb_pe *ctx, const char *prefix, const cha
303303

304304
static int get_name(const char *entry, char **out_name, char *id_entry)
305305
{
306-
flb_sds_t tmp;
307-
flb_sds_t tmp_name;
306+
flb_sds_t tmp = NULL;
307+
flb_sds_t tmp_name = NULL;
308308

309309
tmp = strdup(entry);
310310
tmp_name = strtok(tmp, ")");
@@ -324,8 +324,8 @@ static int process_proc_thread_io(struct flb_pe *ctx, uint64_t ts,
324324
struct flb_slist_entry *thread)
325325
{
326326
int ret;
327-
flb_sds_t tmp;
328-
flb_sds_t status;
327+
flb_sds_t tmp = NULL;
328+
flb_sds_t status = NULL;
329329
uint64_t val;
330330
struct mk_list io_list;
331331
struct mk_list *ihead;
@@ -382,9 +382,9 @@ static int process_proc_thread_status(struct flb_pe *ctx, uint64_t ts,
382382
struct flb_slist_entry *thread)
383383
{
384384
int ret;
385-
flb_sds_t tmp;
386-
flb_sds_t name;
387-
flb_sds_t status;
385+
flb_sds_t tmp = NULL;
386+
flb_sds_t name = NULL;
387+
flb_sds_t status = NULL;
388388
uint64_t val;
389389
struct mk_list status_list;
390390
struct mk_list *shead;
@@ -481,9 +481,9 @@ static int process_proc_thread_status(struct flb_pe *ctx, uint64_t ts,
481481
static int process_thread_update(struct flb_pe *ctx, uint64_t ts, flb_sds_t pid, flb_sds_t name)
482482
{
483483
int ret;
484-
flb_sds_t tmp;
485-
flb_sds_t thread_name;
486-
flb_sds_t tid_str;
484+
flb_sds_t tmp = NULL;
485+
flb_sds_t thread_name = NULL;
486+
flb_sds_t tid_str = NULL;
487487
uint64_t val;
488488
const char *pattern = "/[0-9]*";
489489
struct mk_list *head;
@@ -648,8 +648,8 @@ static int process_proc_io(struct flb_pe *ctx, uint64_t ts,
648648
struct flb_slist_entry *process)
649649
{
650650
int ret;
651-
flb_sds_t tmp;
652-
flb_sds_t status;
651+
flb_sds_t tmp = NULL;
652+
flb_sds_t status = NULL;
653653
uint64_t val;
654654
struct mk_list io_list;
655655
struct mk_list *ihead;
@@ -784,9 +784,9 @@ static int process_proc_fds(struct flb_pe *ctx, uint64_t ts,
784784
static int process_proc_status(struct flb_pe *ctx, uint64_t ts, flb_sds_t pid, struct flb_slist_entry *process)
785785
{
786786
int ret;
787-
flb_sds_t tmp;
788-
flb_sds_t name;
789-
flb_sds_t status;
787+
flb_sds_t tmp = NULL;
788+
flb_sds_t name = NULL;
789+
flb_sds_t status = NULL;
790790
uint64_t val;
791791
struct mk_list status_list;
792792
struct mk_list *shead;
@@ -881,8 +881,8 @@ static int process_proc_status(struct flb_pe *ctx, uint64_t ts, flb_sds_t pid, s
881881
static int process_proc_boot_time(struct flb_pe *ctx, uint64_t *out_boot_time)
882882
{
883883
int ret;
884-
flb_sds_t tmp;
885-
flb_sds_t status;
884+
flb_sds_t tmp = NULL;
885+
flb_sds_t status = NULL;
886886
uint64_t val;
887887
struct mk_list stat_list;
888888
struct mk_list *rshead;
@@ -923,12 +923,12 @@ static int process_proc_boot_time(struct flb_pe *ctx, uint64_t *out_boot_time)
923923
static int process_update(struct flb_pe *ctx)
924924
{
925925
int ret;
926-
flb_sds_t tmp;
927-
flb_sds_t name;
928-
flb_sds_t pid_str;
929-
flb_sds_t state_str;
930-
flb_sds_t ppid_str;
931-
flb_sds_t thread_str;
926+
flb_sds_t tmp = NULL;
927+
flb_sds_t name = NULL;
928+
flb_sds_t pid_str = NULL;
929+
flb_sds_t state_str = NULL;
930+
flb_sds_t ppid_str = NULL;
931+
flb_sds_t thread_str = NULL;
932932
struct mk_list *head;
933933
struct mk_list *ehead;
934934
struct mk_list procfs_list;

0 commit comments

Comments
 (0)