From 157f53df617fc2264f12b26fa52e55c1a37d12c8 Mon Sep 17 00:00:00 2001 From: Artur Zakirov Date: Wed, 18 Oct 2023 17:44:15 +0200 Subject: [PATCH] Issue #290: Fix cppcheck errors --- bin/pg_repack.c | 2 +- bin/pgut/pgut-fe.c | 1 - bin/pgut/pgut.c | 2 +- bin/pgut/pgut.h | 2 +- lib/repack.c | 7 ++++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/pg_repack.c b/bin/pg_repack.c index d47631b1..e2832358 100644 --- a/bin/pg_repack.c +++ b/bin/pg_repack.c @@ -871,7 +871,7 @@ repack_one_database(const char *orderby, char *errbuf, size_t errsize) { if (errbuf) snprintf(errbuf, errsize, - "internal error: bad parameters count: %i instead of %zi", + "internal error: bad parameters count: %i instead of %zu", iparam, num_params); goto cleanup; } diff --git a/bin/pgut/pgut-fe.c b/bin/pgut/pgut-fe.c index 8633ddac..b5a5af40 100644 --- a/bin/pgut/pgut-fe.c +++ b/bin/pgut/pgut-fe.c @@ -306,7 +306,6 @@ pgut_setopt(pgut_option *opt, const char *optarg, pgut_optsrc src) message = "a 32bit signed integer"; break; case 'l': - message = "a List"; simple_string_list_append(opt->var, optarg); return; case 'u': diff --git a/bin/pgut/pgut.c b/bin/pgut/pgut.c index c4cfbab5..43cfac62 100644 --- a/bin/pgut/pgut.c +++ b/bin/pgut/pgut.c @@ -1215,7 +1215,7 @@ pgut_atexit_push(pgut_atexit_callback callback, void *userdata) } void -pgut_atexit_pop(pgut_atexit_callback callback, void *userdata) +pgut_atexit_pop(const pgut_atexit_callback callback, const void *userdata) { pgut_atexit_item *item; pgut_atexit_item **prev; diff --git a/bin/pgut/pgut.h b/bin/pgut/pgut.h index 9253855b..7a19a2be 100644 --- a/bin/pgut/pgut.h +++ b/bin/pgut/pgut.h @@ -55,7 +55,7 @@ extern bool pgut_echo; extern void pgut_init(int argc, char **argv); extern void pgut_atexit_push(pgut_atexit_callback callback, void *userdata); -extern void pgut_atexit_pop(pgut_atexit_callback callback, void *userdata); +extern void pgut_atexit_pop(const pgut_atexit_callback callback, const void *userdata); extern void pgut_putenv(const char *key, const char *value); /* diff --git a/lib/repack.c b/lib/repack.c index 30354f93..51662b09 100644 --- a/lib/repack.c +++ b/lib/repack.c @@ -578,7 +578,8 @@ parse_indexdef(IndexDef *stmt, Oid index, Oid table) /* (columns) */ if ((sql = strchr(sql, '(')) == NULL) parse_error(index); - sql++; + else + sql++; stmt->columns = sql; if ((sql = skip_until(index, sql, ')')) == NULL) parse_error(index); @@ -962,7 +963,8 @@ repack_swap(PG_FUNCTION_ARGS) RENAME_INDEX(reltoastidxid1, name); CommandCounterIncrement(); } - else if (reltoastrelid1 != InvalidOid) + /* reltoastrelid1 != InvalidOid */ + else { char name[NAMEDATALEN]; int pid = getpid(); @@ -1104,7 +1106,6 @@ repack_drop(PG_FUNCTION_ARGS) SPI_OK_UTILITY, "DROP TABLE IF EXISTS repack.table_%u CASCADE", oid); - --numobj; } SPI_finish();