From 0faf7d933f625eb1668dcaa518b472f722b53a55 Mon Sep 17 00:00:00 2001 From: Peter Geoghegan Date: Thu, 22 Sep 2022 13:59:20 -0700 Subject: [PATCH] Harmonize parameter names in contrib code. Make sure that function declarations use names that exactly match the corresponding names from function definitions in contrib code. Like other recent commits that cleaned up function parameter names, this commit was written with help from clang-tidy. Author: Peter Geoghegan Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com --- contrib/amcheck/verify_nbtree.c | 2 +- contrib/cube/cube.c | 2 +- contrib/dblink/dblink.c | 2 +- contrib/fuzzystrmatch/dmetaphone.c | 2 +- contrib/intarray/_int.h | 2 +- contrib/intarray/_int_selfuncs.c | 4 ++-- contrib/intarray/_int_tool.c | 4 ++-- contrib/ltree/ltree.h | 2 +- contrib/oid2name/oid2name.c | 14 ++++++------ contrib/pgcrypto/mbuf.h | 18 +++++++-------- contrib/pgcrypto/pgcrypto.c | 3 ++- contrib/pgcrypto/pgp.h | 32 +++++++++++++-------------- contrib/pgcrypto/px-crypt.h | 6 ++--- contrib/pgcrypto/px.h | 2 +- contrib/postgres_fdw/deparse.c | 2 +- contrib/postgres_fdw/postgres_fdw.c | 2 +- contrib/postgres_fdw/postgres_fdw.h | 2 +- contrib/seg/seg.c | 2 +- contrib/seg/segdata.h | 2 +- contrib/tablefunc/tablefunc.c | 6 ++--- contrib/test_decoding/test_decoding.c | 6 ++--- 21 files changed, 59 insertions(+), 58 deletions(-) diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c index 798adc5bc5..9021d156eb 100644 --- a/contrib/amcheck/verify_nbtree.c +++ b/contrib/amcheck/verify_nbtree.c @@ -159,7 +159,7 @@ static void bt_child_highkey_check(BtreeCheckState *state, Page loaded_child, uint32 target_level); static void bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit, - BlockNumber targetblock, Page target); + BlockNumber blkno, Page page); static void bt_tuple_present_callback(Relation index, ItemPointer tid, Datum *values, bool *isnull, bool tupleIsAlive, void *checkstate); diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c index 6e01800a4a..01c6a9c556 100644 --- a/contrib/cube/cube.c +++ b/contrib/cube/cube.c @@ -96,7 +96,7 @@ int32 cube_cmp_v0(NDBOX *a, NDBOX *b); bool cube_contains_v0(NDBOX *a, NDBOX *b); bool cube_overlap_v0(NDBOX *a, NDBOX *b); NDBOX *cube_union_v0(NDBOX *a, NDBOX *b); -void rt_cube_size(NDBOX *a, double *sz); +void rt_cube_size(NDBOX *a, double *size); NDBOX *g_cube_binary_union(NDBOX *r1, NDBOX *r2, int *sizep); bool g_cube_leaf_consistent(NDBOX *key, NDBOX *query, StrategyNumber strategy); bool g_cube_internal_consistent(NDBOX *key, NDBOX *query, StrategyNumber strategy); diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 41cf45e878..9eef417c47 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -114,7 +114,7 @@ static void dblink_security_check(PGconn *conn, remoteConn *rconn); static void dblink_res_error(PGconn *conn, const char *conname, PGresult *res, bool fail, const char *fmt,...) pg_attribute_printf(5, 6); static char *get_connect_string(const char *servername); -static char *escape_param_str(const char *from); +static char *escape_param_str(const char *str); static void validate_pkattnums(Relation rel, int2vector *pkattnums_arg, int32 pknumatts_arg, int **pkattnums, int *pknumatts); diff --git a/contrib/fuzzystrmatch/dmetaphone.c b/contrib/fuzzystrmatch/dmetaphone.c index 6f4d2b730e..f8f2c2b447 100644 --- a/contrib/fuzzystrmatch/dmetaphone.c +++ b/contrib/fuzzystrmatch/dmetaphone.c @@ -117,7 +117,7 @@ The remaining code is authored by Andrew Dunstan and #include /* prototype for the main function we got from the perl module */ -static void DoubleMetaphone(char *, char **); +static void DoubleMetaphone(char *str, char **codes); #ifndef DMETAPHONE_MAIN diff --git a/contrib/intarray/_int.h b/contrib/intarray/_int.h index 304c29525c..a52ec38ba4 100644 --- a/contrib/intarray/_int.h +++ b/contrib/intarray/_int.h @@ -114,7 +114,7 @@ ArrayType *new_intArrayType(int num); ArrayType *copy_intArrayType(ArrayType *a); ArrayType *resize_intArrayType(ArrayType *a, int num); int internal_size(int *a, int len); -ArrayType *_int_unique(ArrayType *a); +ArrayType *_int_unique(ArrayType *r); int32 intarray_match_first(ArrayType *a, int32 elem); ArrayType *intarray_add_elem(ArrayType *a, int32 elem); ArrayType *intarray_concat_arrays(ArrayType *a, ArrayType *b); diff --git a/contrib/intarray/_int_selfuncs.c b/contrib/intarray/_int_selfuncs.c index 3d8ff6781b..6d5f6cc70e 100644 --- a/contrib/intarray/_int_selfuncs.c +++ b/contrib/intarray/_int_selfuncs.c @@ -34,8 +34,8 @@ PG_FUNCTION_INFO_V1(_int_contained_joinsel); PG_FUNCTION_INFO_V1(_int_matchsel); -static Selectivity int_query_opr_selec(ITEM *item, Datum *values, float4 *freqs, - int nmncelems, float4 minfreq); +static Selectivity int_query_opr_selec(ITEM *item, Datum *mcelems, float4 *mcefreqs, + int nmcelems, float4 minfreq); static int compare_val_int4(const void *a, const void *b); /* diff --git a/contrib/intarray/_int_tool.c b/contrib/intarray/_int_tool.c index 8ed4d63fc3..5ab6eb81e8 100644 --- a/contrib/intarray/_int_tool.c +++ b/contrib/intarray/_int_tool.c @@ -382,14 +382,14 @@ intarray_concat_arrays(ArrayType *a, ArrayType *b) } ArrayType * -int_to_intset(int32 n) +int_to_intset(int32 elem) { ArrayType *result; int32 *aa; result = new_intArrayType(1); aa = ARRPTR(result); - aa[0] = n; + aa[0] = elem; return result; } diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h index 3dd99ca684..40aed0ca0c 100644 --- a/contrib/ltree/ltree.h +++ b/contrib/ltree/ltree.h @@ -206,7 +206,7 @@ bool ltree_execute(ITEM *curitem, void *checkval, int ltree_compare(const ltree *a, const ltree *b); bool inner_isparent(const ltree *c, const ltree *p); -bool compare_subnode(ltree_level *t, char *q, int len, +bool compare_subnode(ltree_level *t, char *qn, int len, int (*cmpptr) (const char *, const char *, size_t), bool anyend); ltree *lca_inner(ltree **a, int len); int ltree_strncasecmp(const char *a, const char *b, size_t s); diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c index 32d5444831..4edf02d9c7 100644 --- a/contrib/oid2name/oid2name.c +++ b/contrib/oid2name/oid2name.c @@ -48,15 +48,15 @@ struct options /* function prototypes */ static void help(const char *progname); -void get_opts(int, char **, struct options *); +void get_opts(int argc, char **argv, struct options *my_opts); void add_one_elt(char *eltname, eary *eary); char *get_comma_elts(eary *eary); -PGconn *sql_conn(struct options *); -int sql_exec(PGconn *, const char *sql, bool quiet); -void sql_exec_dumpalldbs(PGconn *, struct options *); -void sql_exec_dumpalltables(PGconn *, struct options *); -void sql_exec_searchtables(PGconn *, struct options *); -void sql_exec_dumpalltbspc(PGconn *, struct options *); +PGconn *sql_conn(struct options *my_opts); +int sql_exec(PGconn *conn, const char *todo, bool quiet); +void sql_exec_dumpalldbs(PGconn *conn, struct options *opts); +void sql_exec_dumpalltables(PGconn *conn, struct options *opts); +void sql_exec_searchtables(PGconn *conn, struct options *opts); +void sql_exec_dumpalltbspc(PGconn *conn, struct options *opts); /* function to parse command line options and check for some usage errors. */ void diff --git a/contrib/pgcrypto/mbuf.h b/contrib/pgcrypto/mbuf.h index adb18430b7..97873c931f 100644 --- a/contrib/pgcrypto/mbuf.h +++ b/contrib/pgcrypto/mbuf.h @@ -82,33 +82,33 @@ int mbuf_avail(MBuf *mbuf); int mbuf_size(MBuf *mbuf); int mbuf_grab(MBuf *mbuf, int len, uint8 **data_p); int mbuf_steal_data(MBuf *mbuf, uint8 **data_p); -int mbuf_append(MBuf *dst, const uint8 *buf, int cnt); +int mbuf_append(MBuf *dst, const uint8 *buf, int len); int mbuf_free(MBuf *mbuf); /* * Push filter */ -int pushf_create(PushFilter **res, const PushFilterOps *ops, void *init_arg, - PushFilter *next); +int pushf_create(PushFilter **mp_p, const PushFilterOps *op, + void *init_arg, PushFilter *next); int pushf_write(PushFilter *mp, const uint8 *data, int len); void pushf_free_all(PushFilter *mp); void pushf_free(PushFilter *mp); int pushf_flush(PushFilter *mp); -int pushf_create_mbuf_writer(PushFilter **mp_p, MBuf *mbuf); +int pushf_create_mbuf_writer(PushFilter **res, MBuf *dst); /* * Pull filter */ -int pullf_create(PullFilter **res, const PullFilterOps *ops, +int pullf_create(PullFilter **pf_p, const PullFilterOps *op, void *init_arg, PullFilter *src); -int pullf_read(PullFilter *mp, int len, uint8 **data_p); -int pullf_read_max(PullFilter *mp, int len, +int pullf_read(PullFilter *pf, int len, uint8 **data_p); +int pullf_read_max(PullFilter *pf, int len, uint8 **data_p, uint8 *tmpbuf); -void pullf_free(PullFilter *mp); +void pullf_free(PullFilter *pf); int pullf_read_fixed(PullFilter *src, int len, uint8 *dst); -int pullf_create_mbuf_reader(PullFilter **pf_p, MBuf *mbuf); +int pullf_create_mbuf_reader(PullFilter **mp_p, MBuf *src); #define GETBYTE(pf, dst) \ do { \ diff --git a/contrib/pgcrypto/pgcrypto.c b/contrib/pgcrypto/pgcrypto.c index f0ac625040..8f882f4c68 100644 --- a/contrib/pgcrypto/pgcrypto.c +++ b/contrib/pgcrypto/pgcrypto.c @@ -45,7 +45,8 @@ PG_MODULE_MAGIC; /* private stuff */ typedef int (*PFN) (const char *name, void **res); -static void *find_provider(text *name, PFN pf, const char *desc, int silent); +static void *find_provider(text *name, PFN provider_lookup, const char *desc, + int silent); /* SQL function: hash(bytea, text) returns bytea */ PG_FUNCTION_INFO_V1(pg_digest); diff --git a/contrib/pgcrypto/pgp.h b/contrib/pgcrypto/pgp.h index 805f01af5b..cb8b32aba0 100644 --- a/contrib/pgcrypto/pgp.h +++ b/contrib/pgcrypto/pgp.h @@ -236,9 +236,9 @@ struct PGP_PubKey int can_encrypt; }; -int pgp_init(PGP_Context **ctx); +int pgp_init(PGP_Context **ctx_p); int pgp_encrypt(PGP_Context *ctx, MBuf *src, MBuf *dst); -int pgp_decrypt(PGP_Context *ctx, MBuf *src, MBuf *dst); +int pgp_decrypt(PGP_Context *ctx, MBuf *msrc, MBuf *mdst); int pgp_free(PGP_Context *ctx); int pgp_get_digest_code(const char *name); @@ -246,7 +246,7 @@ int pgp_get_cipher_code(const char *name); const char *pgp_get_digest_name(int code); int pgp_set_cipher_algo(PGP_Context *ctx, const char *name); -int pgp_set_s2k_mode(PGP_Context *ctx, int type); +int pgp_set_s2k_mode(PGP_Context *ctx, int mode); int pgp_set_s2k_count(PGP_Context *ctx, int count); int pgp_set_s2k_cipher_algo(PGP_Context *ctx, const char *name); int pgp_set_s2k_digest_algo(PGP_Context *ctx, const char *name); @@ -259,22 +259,22 @@ int pgp_set_text_mode(PGP_Context *ctx, int mode); int pgp_set_unicode_mode(PGP_Context *ctx, int mode); int pgp_get_unicode_mode(PGP_Context *ctx); -int pgp_set_symkey(PGP_Context *ctx, const uint8 *key, int klen); +int pgp_set_symkey(PGP_Context *ctx, const uint8 *key, int len); int pgp_set_pubkey(PGP_Context *ctx, MBuf *keypkt, - const uint8 *key, int klen, int pubtype); + const uint8 *key, int key_len, int pubtype); int pgp_get_keyid(MBuf *pgp_data, char *dst); /* internal functions */ -int pgp_load_digest(int c, PX_MD **res); -int pgp_load_cipher(int c, PX_Cipher **res); -int pgp_get_cipher_key_size(int c); -int pgp_get_cipher_block_size(int c); +int pgp_load_digest(int code, PX_MD **res); +int pgp_load_cipher(int code, PX_Cipher **res); +int pgp_get_cipher_key_size(int code); +int pgp_get_cipher_block_size(int code); int pgp_s2k_fill(PGP_S2K *s2k, int mode, int digest_algo, int count); int pgp_s2k_read(PullFilter *src, PGP_S2K *s2k); -int pgp_s2k_process(PGP_S2K *s2k, int cipher, const uint8 *key, int klen); +int pgp_s2k_process(PGP_S2K *s2k, int cipher, const uint8 *key, int key_len); typedef struct PGP_CFB PGP_CFB; int pgp_cfb_create(PGP_CFB **ctx_p, int algo, @@ -316,11 +316,11 @@ int pgp_mpi_write(PushFilter *dst, PGP_MPI *n); int pgp_mpi_hash(PX_MD *md, PGP_MPI *n); unsigned pgp_mpi_cksum(unsigned cksum, PGP_MPI *n); -int pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *m, - PGP_MPI **c1, PGP_MPI **c2); -int pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *c1, PGP_MPI *c2, - PGP_MPI **m); -int pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *m, PGP_MPI **c); -int pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *c, PGP_MPI **m); +int pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *_m, + PGP_MPI **c1_p, PGP_MPI **c2_p); +int pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *_c1, PGP_MPI *_c2, + PGP_MPI **msg_p); +int pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *_m, PGP_MPI **c_p); +int pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *_c, PGP_MPI **m_p); extern struct PullFilterOps pgp_decrypt_filter; diff --git a/contrib/pgcrypto/px-crypt.h b/contrib/pgcrypto/px-crypt.h index 08001a81f5..54de806965 100644 --- a/contrib/pgcrypto/px-crypt.h +++ b/contrib/pgcrypto/px-crypt.h @@ -48,8 +48,8 @@ /* * main interface */ -char *px_crypt(const char *psw, const char *salt, char *buf, unsigned buflen); -int px_gen_salt(const char *salt_type, char *dst, int rounds); +char *px_crypt(const char *psw, const char *salt, char *buf, unsigned len); +int px_gen_salt(const char *salt_type, char *buf, int rounds); /* * internal functions @@ -77,6 +77,6 @@ char *px_crypt_des(const char *key, const char *setting); /* crypt-md5.c */ char *px_crypt_md5(const char *pw, const char *salt, - char *dst, unsigned dstlen); + char *passwd, unsigned dstlen); #endif /* _PX_CRYPT_H */ diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h index 4ef40f3f1c..471bb4ec72 100644 --- a/contrib/pgcrypto/px.h +++ b/contrib/pgcrypto/px.h @@ -176,7 +176,7 @@ int px_find_combo(const char *name, PX_Combo **res); void px_THROW_ERROR(int err) pg_attribute_noreturn(); const char *px_strerror(int err); -const char *px_resolve_alias(const PX_Alias *aliases, const char *name); +const char *px_resolve_alias(const PX_Alias *list, const char *name); void px_set_debug_handler(void (*handler) (const char *)); diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c index a9766f9734..09f37fb77a 100644 --- a/contrib/postgres_fdw/deparse.c +++ b/contrib/postgres_fdw/deparse.c @@ -149,7 +149,7 @@ static void deparseReturningList(StringInfo buf, RangeTblEntry *rte, static void deparseColumnRef(StringInfo buf, int varno, int varattno, RangeTblEntry *rte, bool qualify_col); static void deparseRelation(StringInfo buf, Relation rel); -static void deparseExpr(Expr *expr, deparse_expr_cxt *context); +static void deparseExpr(Expr *node, deparse_expr_cxt *context); static void deparseVar(Var *node, deparse_expr_cxt *context); static void deparseConst(Const *node, deparse_expr_cxt *context, int showtype); static void deparseParam(Param *node, deparse_expr_cxt *context); diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index b76818f7fd..dd858aba03 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -457,7 +457,7 @@ static PgFdwModifyState *create_foreign_modify(EState *estate, Plan *subplan, char *query, List *target_attrs, - int len, + int values_end, bool has_returning, List *retrieved_attrs); static TupleTableSlot **execute_foreign_modify(EState *estate, diff --git a/contrib/postgres_fdw/postgres_fdw.h b/contrib/postgres_fdw/postgres_fdw.h index 21f2b20ce8..a11d45bedf 100644 --- a/contrib/postgres_fdw/postgres_fdw.h +++ b/contrib/postgres_fdw/postgres_fdw.h @@ -226,7 +226,7 @@ extern EquivalenceMember *find_em_for_rel_target(PlannerInfo *root, RelOptInfo *rel); extern List *build_tlist_to_deparse(RelOptInfo *foreignrel); extern void deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, - RelOptInfo *foreignrel, List *tlist, + RelOptInfo *rel, List *tlist, List *remote_conds, List *pathkeys, bool has_final_sort, bool has_limit, bool is_subquery, diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c index 4a8e2be329..cb677e0ae5 100644 --- a/contrib/seg/seg.c +++ b/contrib/seg/seg.c @@ -92,7 +92,7 @@ PG_FUNCTION_INFO_V1(seg_different); /* ** Auxiliary functions */ -static int restore(char *s, float val, int n); +static int restore(char *result, float val, int n); /***************************************************************************** diff --git a/contrib/seg/segdata.h b/contrib/seg/segdata.h index 9488bf3a81..f4eafc865d 100644 --- a/contrib/seg/segdata.h +++ b/contrib/seg/segdata.h @@ -12,7 +12,7 @@ typedef struct SEG } SEG; /* in seg.c */ -extern int significant_digits(const char *str); +extern int significant_digits(const char *s); /* in segscan.l */ extern int seg_yylex(void); diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index e308228bde..b967e6d4be 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -51,9 +51,9 @@ static Tuplestorestate *get_crosstab_tuplestore(char *sql, HTAB *crosstab_hash, TupleDesc tupdesc, bool randomAccess); -static void validateConnectbyTupleDesc(TupleDesc tupdesc, bool show_branch, bool show_serial); -static bool compatCrosstabTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2); -static void compatConnectbyTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2); +static void validateConnectbyTupleDesc(TupleDesc td, bool show_branch, bool show_serial); +static bool compatCrosstabTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc); +static void compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc); static void get_normal_pair(float8 *x1, float8 *x2); static Tuplestorestate *connectby(char *relname, char *key_fld, diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c index 3f90ffa32d..e0fd6f1765 100644 --- a/contrib/test_decoding/test_decoding.c +++ b/contrib/test_decoding/test_decoding.c @@ -60,7 +60,7 @@ static void pg_output_begin(LogicalDecodingContext *ctx, static void pg_decode_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr commit_lsn); static void pg_decode_change(LogicalDecodingContext *ctx, - ReorderBufferTXN *txn, Relation rel, + ReorderBufferTXN *txn, Relation relation, ReorderBufferChange *change); static void pg_decode_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, @@ -69,7 +69,7 @@ static void pg_decode_truncate(LogicalDecodingContext *ctx, static bool pg_decode_filter(LogicalDecodingContext *ctx, RepOriginId origin_id); static void pg_decode_message(LogicalDecodingContext *ctx, - ReorderBufferTXN *txn, XLogRecPtr message_lsn, + ReorderBufferTXN *txn, XLogRecPtr lsn, bool transactional, const char *prefix, Size sz, const char *message); static bool pg_decode_filter_prepare(LogicalDecodingContext *ctx, @@ -109,7 +109,7 @@ static void pg_decode_stream_change(LogicalDecodingContext *ctx, Relation relation, ReorderBufferChange *change); static void pg_decode_stream_message(LogicalDecodingContext *ctx, - ReorderBufferTXN *txn, XLogRecPtr message_lsn, + ReorderBufferTXN *txn, XLogRecPtr lsn, bool transactional, const char *prefix, Size sz, const char *message); static void pg_decode_stream_truncate(LogicalDecodingContext *ctx,