From 2cbbf2a166cba72b94e80eb55f029e1a4901823e Mon Sep 17 00:00:00 2001 From: Ruben Kerkhof Date: Sat, 15 Dec 2018 18:57:17 +0100 Subject: [PATCH] postgresql plugin: fix some stylistic issues --- src/postgresql.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/postgresql.c b/src/postgresql.c index ae887a17..e6278062 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -511,14 +511,14 @@ static int c_psql_exec_query(c_psql_database_t *db, udb_query_t *q, } column_num = PQnfields(res); - column_names = (char **)calloc(column_num, sizeof(char *)); - if (NULL == column_names) { + column_names = calloc(column_num, sizeof(*column_names)); + if (column_names == NULL) { log_err("calloc failed."); BAIL_OUT(-1); } - column_values = (char **)calloc(column_num, sizeof(char *)); - if (NULL == column_values) { + column_values = calloc(column_num, sizeof(*column_values)); + if (column_values == NULL) { log_err("calloc failed."); BAIL_OUT(-1); } @@ -976,9 +976,9 @@ static int config_query_param_add(udb_query_t *q, oconfig_item_t *ci) { c_psql_param_t *tmp; data = udb_query_get_user_data(q); - if (NULL == data) { + if (data == NULL) { data = calloc(1, sizeof(*data)); - if (NULL == data) { + if (data == NULL) { log_err("Out of memory."); return -1; } @@ -989,7 +989,7 @@ static int config_query_param_add(udb_query_t *q, oconfig_item_t *ci) { } tmp = realloc(data->params, (data->params_num + 1) * sizeof(*data->params)); - if (NULL == tmp) { + if (tmp == NULL) { log_err("Out of memory."); return -1; } @@ -1176,9 +1176,7 @@ static int c_psql_config_database(oconfig_item_t *ci) { } if (db->queries_num > 0) { - db->q_prep_areas = (udb_query_preparation_area_t **)calloc( - db->queries_num, sizeof(*db->q_prep_areas)); - + db->q_prep_areas = calloc(db->queries_num, sizeof(*db->q_prep_areas)); if (db->q_prep_areas == NULL) { log_err("Out of memory."); c_psql_database_delete(db); -- 2.11.0