projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Treewide: replace ssnprintf with snprintf
[collectd.git]
/
src
/
postgresql.c
diff --git
a/src/postgresql.c
b/src/postgresql.c
index
3a388a5
..
a0a1a27
100644
(file)
--- a/
src/postgresql.c
+++ b/
src/postgresql.c
@@
-58,7
+58,7
@@
* is ignored. */
#define C_PSQL_PAR_APPEND(buf, buf_len, parameter, value) \
if ((0 < (buf_len)) && (NULL != (value)) && ('\0' != *(value))) { \
* is ignored. */
#define C_PSQL_PAR_APPEND(buf, buf_len, parameter, value) \
if ((0 < (buf_len)) && (NULL != (value)) && ('\0' != *(value))) { \
- int s = s
s
nprintf(buf, buf_len, " %s = '%s'", parameter, value); \
+ int s = snprintf(buf, buf_len, " %s = '%s'", parameter, value); \
if (0 < s) { \
buf += s; \
buf_len -= s; \
if (0 < s) { \
buf += s; \
buf_len -= s; \
@@
-322,7
+322,7
@@
static int c_psql_connect(c_psql_database_t *db) {
if ((!db) || (!db->database))
return -1;
if ((!db) || (!db->database))
return -1;
- status = s
s
nprintf(buf, buf_len, "dbname = '%s'", db->database);
+ status = snprintf(buf, buf_len, "dbname = '%s'", db->database);
if (0 < status) {
buf += status;
buf_len -= status;
if (0 < status) {
buf += status;
buf_len -= status;
@@
-407,7
+407,7
@@
static PGresult *c_psql_exec_query_params(c_psql_database_t *db, udb_query_t *q,
char interval[64];
if ((data == NULL) || (data->params_num == 0))
char interval[64];
if ((data == NULL) || (data->params_num == 0))
- return
(c_psql_exec_query_noparams(db, q)
);
+ return
c_psql_exec_query_noparams(db, q
);
assert(db->max_params_num >= data->params_num);
assert(db->max_params_num >= data->params_num);
@@
-424,7
+424,7
@@
static PGresult *c_psql_exec_query_params(c_psql_database_t *db, udb_query_t *q,
params[i] = db->user;
break;
case C_PSQL_PARAM_INTERVAL:
params[i] = db->user;
break;
case C_PSQL_PARAM_INTERVAL:
- s
s
nprintf(interval, sizeof(interval), "%.3f",
+ snprintf(interval, sizeof(interval), "%.3f",
(db->interval > 0) ? CDTIME_T_TO_DOUBLE(db->interval)
: plugin_get_interval());
params[i] = interval;
(db->interval > 0) ? CDTIME_T_TO_DOUBLE(db->interval)
: plugin_get_interval());
params[i] = interval;
@@
-438,8
+438,7
@@
static PGresult *c_psql_exec_query_params(c_psql_database_t *db, udb_query_t *q,
}
return PQexecParams(db->conn, udb_query_get_statement(q), data->params_num,
}
return PQexecParams(db->conn, udb_query_get_statement(q), data->params_num,
- NULL, (const char *const *)params, NULL, NULL,
- /* return text data */ 0);
+ NULL, (const char *const*)params, NULL, NULL, 0);
} /* c_psql_exec_query_params */
/* db->db_lock must be locked when calling this function */
} /* c_psql_exec_query_params */
/* db->db_lock must be locked when calling this function */
@@
-630,7
+629,7
@@
static char *values_name_to_sqlarray(const data_set_t *ds, char *string,
str_len = string_len;
for (size_t i = 0; i < ds->ds_num; ++i) {
str_len = string_len;
for (size_t i = 0; i < ds->ds_num; ++i) {
- int status = s
s
nprintf(str_ptr, str_len, ",'%s'", ds->ds[i].name);
+ int status = snprintf(str_ptr, str_len, ",'%s'", ds->ds[i].name);
if (status < 1)
return NULL;
if (status < 1)
return NULL;
@@
-668,9
+667,9
@@
static char *values_type_to_sqlarray(const data_set_t *ds, char *string,
int status;
if (store_rates)
int status;
if (store_rates)
- status = s
s
nprintf(str_ptr, str_len, ",'gauge'");
+ status = snprintf(str_ptr, str_len, ",'gauge'");
else
else
- status = s
s
nprintf(str_ptr, str_len, ",'%s'",
+ status = snprintf(str_ptr, str_len, ",'%s'",
DS_TYPE_TO_STRING(ds->ds[i].type));
if (status < 1) {
DS_TYPE_TO_STRING(ds->ds[i].type));
if (status < 1) {
@@
-723,7
+722,7
@@
static char *values_to_sqlarray(const data_set_t *ds, const value_list_t *vl,
if (ds->ds[i].type == DS_TYPE_GAUGE)
status =
if (ds->ds[i].type == DS_TYPE_GAUGE)
status =
- s
s
nprintf(str_ptr, str_len, "," GAUGE_FORMAT, vl->values[i].gauge);
+ snprintf(str_ptr, str_len, "," GAUGE_FORMAT, vl->values[i].gauge);
else if (store_rates) {
if (rates == NULL)
rates = uc_get_rate(ds, vl);
else if (store_rates) {
if (rates == NULL)
rates = uc_get_rate(ds, vl);
@@
-733,13
+732,13
@@
static char *values_to_sqlarray(const data_set_t *ds, const value_list_t *vl,
return NULL;
}
return NULL;
}
- status = s
s
nprintf(str_ptr, str_len, ",%lf", rates[i]);
+ status = snprintf(str_ptr, str_len, ",%lf", rates[i]);
} else if (ds->ds[i].type == DS_TYPE_COUNTER)
} else if (ds->ds[i].type == DS_TYPE_COUNTER)
- status = s
s
nprintf(str_ptr, str_len, ",%llu", vl->values[i].counter);
+ status = snprintf(str_ptr, str_len, ",%llu", vl->values[i].counter);
else if (ds->ds[i].type == DS_TYPE_DERIVE)
else if (ds->ds[i].type == DS_TYPE_DERIVE)
- status = s
s
nprintf(str_ptr, str_len, ",%" PRIi64, vl->values[i].derive);
+ status = snprintf(str_ptr, str_len, ",%" PRIi64, vl->values[i].derive);
else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
else if (ds->ds[i].type == DS_TYPE_ABSOLUTE)
- status = s
s
nprintf(str_ptr, str_len, ",%" PRIu64, vl->values[i].absolute);
+ status = snprintf(str_ptr, str_len, ",%" PRIu64, vl->values[i].absolute);
if (status < 1) {
str_len = 0;
if (status < 1) {
str_len = 0;
@@
-937,7
+936,7
@@
static int c_psql_shutdown(void) {
if (db->writers_num > 0) {
char cb_name[DATA_MAX_NAME_LEN];
if (db->writers_num > 0) {
char cb_name[DATA_MAX_NAME_LEN];
- s
s
nprintf(cb_name, sizeof(cb_name), "postgresql-%s", db->database);
+ snprintf(cb_name, sizeof(cb_name), "postgresql-%s", db->database);
if (!had_flush) {
plugin_unregister_flush("postgresql");
if (!had_flush) {
plugin_unregister_flush("postgresql");
@@
-1009,7
+1008,7
@@
static int config_query_param_add(udb_query_t *q, oconfig_item_t *ci) {
}
data->params_num++;
}
data->params_num++;
- return
(0)
;
+ return
0
;
} /* config_query_param_add */
static int config_query_callback(udb_query_t *q, oconfig_item_t *ci) {
} /* config_query_param_add */
static int config_query_callback(udb_query_t *q, oconfig_item_t *ci) {
@@
-1018,7
+1017,7
@@
static int config_query_callback(udb_query_t *q, oconfig_item_t *ci) {
log_err("Option not allowed within a Query block: `%s'", ci->key);
log_err("Option not allowed within a Query block: `%s'", ci->key);
- return
(-1)
;
+ return
-1
;
} /* config_query_callback */
static int config_add_writer(oconfig_item_t *ci, c_psql_writer_t *src_writers,
} /* config_query_callback */
static int config_add_writer(oconfig_item_t *ci, c_psql_writer_t *src_writers,
@@
-1195,7
+1194,7
@@
static int c_psql_config_database(oconfig_item_t *ci) {
}
}
}
}
- s
s
nprintf(cb_name, sizeof(cb_name), "postgresql-%s", db->instance);
+ snprintf(cb_name, sizeof(cb_name), "postgresql-%s", db->instance);
user_data_t ud = {.data = db, .free_func = c_psql_database_delete};
user_data_t ud = {.data = db, .free_func = c_psql_database_delete};