From d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb Mon Sep 17 00:00:00 2001 From: ng0 Date: Sun, 8 Sep 2019 12:33:09 +0000 Subject: uncrustify as demanded. --- src/pq/pq.c | 156 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 78 insertions(+), 78 deletions(-) (limited to 'src/pq/pq.c') diff --git a/src/pq/pq.c b/src/pq/pq.c index df5ef17ad..a581b4277 100644 --- a/src/pq/pq.c +++ b/src/pq/pq.c @@ -1,22 +1,22 @@ /* - This file is part of GNUnet - Copyright (C) 2014, 2015, 2016 GNUnet e.V. + This file is part of GNUnet + Copyright (C) 2014, 2015, 2016 GNUnet e.V. - GNUnet is free software: you can redistribute it and/or modify it - under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, - or (at your option) any later version. + GNUnet is free software: you can redistribute it and/or modify it + under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, + or (at your option) any later version. - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Affero General Public License for more details. + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . SPDX-License-Identifier: AGPL3.0-or-later -*/ + */ /** * @file pq/pq.c * @brief helper functions for libpq (PostGres) interactions @@ -38,20 +38,20 @@ * @return postgres result */ PGresult * -GNUNET_PQ_exec_prepared (PGconn *db_conn, - const char *name, - const struct GNUNET_PQ_QueryParam *params) +GNUNET_PQ_exec_prepared(PGconn *db_conn, + const char *name, + const struct GNUNET_PQ_QueryParam *params) { unsigned int len; unsigned int i; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Running prepared statement `%s' on %p\n", - name, - db_conn); + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, + "Running prepared statement `%s' on %p\n", + name, + db_conn); /* count the number of parameters */ len = 0; - for (i=0;0 != params[i].num_params;i++) + for (i = 0; 0 != params[i].num_params; i++) len += params[i].num_params; /* new scope to allow stack allocation without alloca */ @@ -70,42 +70,42 @@ GNUNET_PQ_exec_prepared (PGconn *db_conn, off = 0; soff = 0; - for (i=0;0 != params[i].num_params;i++) - { - const struct GNUNET_PQ_QueryParam *x = ¶ms[i]; - - ret = x->conv (x->conv_cls, - x->data, - x->size, - ¶m_values[off], - ¶m_lengths[off], - ¶m_formats[off], - x->num_params, - &scratch[soff], - len - soff); - if (ret < 0) + for (i = 0; 0 != params[i].num_params; i++) { - for (off = 0; off < soff; off++) - GNUNET_free (scratch[off]); - return NULL; + const struct GNUNET_PQ_QueryParam *x = ¶ms[i]; + + ret = x->conv(x->conv_cls, + x->data, + x->size, + ¶m_values[off], + ¶m_lengths[off], + ¶m_formats[off], + x->num_params, + &scratch[soff], + len - soff); + if (ret < 0) + { + for (off = 0; off < soff; off++) + GNUNET_free(scratch[off]); + return NULL; + } + soff += ret; + off += x->num_params; } - soff += ret; - off += x->num_params; - } - GNUNET_assert (off == len); - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, - "pq", - "Executing prepared SQL statement `%s'\n", - name); - res = PQexecPrepared (db_conn, - name, - len, - (const char **) param_values, - param_lengths, - param_formats, - 1); + GNUNET_assert(off == len); + GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, + "pq", + "Executing prepared SQL statement `%s'\n", + name); + res = PQexecPrepared(db_conn, + name, + len, + (const char **)param_values, + param_lengths, + param_formats, + 1); for (off = 0; off < soff; off++) - GNUNET_free (scratch[off]); + GNUNET_free(scratch[off]); return res; } } @@ -118,14 +118,14 @@ GNUNET_PQ_exec_prepared (PGconn *db_conn, * @param rs reult specification to clean up */ void -GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs) +GNUNET_PQ_cleanup_result(struct GNUNET_PQ_ResultSpec *rs) { unsigned int i; - for (i=0; NULL != rs[i].conv; i++) + for (i = 0; NULL != rs[i].conv; i++) if (NULL != rs[i].cleaner) - rs[i].cleaner (rs[i].cls, - rs[i].dst); + rs[i].cleaner(rs[i].cls, + rs[i].dst); } @@ -141,32 +141,32 @@ GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs) * #GNUNET_SYSERR if a result was invalid (non-existing field) */ int -GNUNET_PQ_extract_result (PGresult *result, - struct GNUNET_PQ_ResultSpec *rs, - int row) +GNUNET_PQ_extract_result(PGresult *result, + struct GNUNET_PQ_ResultSpec *rs, + int row) { unsigned int i; int ret; - for (i=0; NULL != rs[i].conv; i++) - { - struct GNUNET_PQ_ResultSpec *spec; - - spec = &rs[i]; - ret = spec->conv (spec->cls, - result, - row, - spec->fname, - &spec->dst_size, - spec->dst); - if (GNUNET_OK != ret) + for (i = 0; NULL != rs[i].conv; i++) { - GNUNET_PQ_cleanup_result (rs); - return GNUNET_SYSERR; + struct GNUNET_PQ_ResultSpec *spec; + + spec = &rs[i]; + ret = spec->conv(spec->cls, + result, + row, + spec->fname, + &spec->dst_size, + spec->dst); + if (GNUNET_OK != ret) + { + GNUNET_PQ_cleanup_result(rs); + return GNUNET_SYSERR; + } + if (NULL != spec->result_size) + *spec->result_size = spec->dst_size; } - if (NULL != spec->result_size) - *spec->result_size = spec->dst_size; - } return GNUNET_OK; } -- cgit v1.2.3