1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-25 20:23:07 +03:00

Initial pgindent run with pg_bsd_indent version 2.0.

The new indent version includes numerous fixes thanks to Piotr Stefaniak.
The main changes visible in this commit are:

* Nicer formatting of function-pointer declarations.
* No longer unexpectedly removes spaces in expressions using casts,
  sizeof, or offsetof.
* No longer wants to add a space in "struct structname *varname", as
  well as some similar cases for const- or volatile-qualified pointers.
* Declarations using PG_USED_FOR_ASSERTS_ONLY are formatted more nicely.
* Fixes bug where comments following declarations were sometimes placed
  with no space separating them from the code.
* Fixes some odd decisions for comments following case labels.
* Fixes some cases where comments following code were indented to less
  than the expected column 33.

On the less good side, it now tends to put more whitespace around typedef
names that are not listed in typedefs.list.  This might encourage us to
put more effort into typedef name collection; it's not really a bug in
indent itself.

There are more changes coming after this round, having to do with comment
indentation and alignment of lines appearing within parentheses.  I wanted
to limit the size of the diffs to something that could be reviewed without
one's eyes completely glazing over, so it seemed better to split up the
changes as much as practical.

Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2017-06-21 14:39:04 -04:00
parent 8ff6d4ec78
commit e3860ffa4d
379 changed files with 1725 additions and 1707 deletions

View File

@@ -75,7 +75,7 @@ _PG_init(void)
bl_relopt_tab[i + 1].optname = MemoryContextStrdup(TopMemoryContext,
buf);
bl_relopt_tab[i + 1].opttype = RELOPT_TYPE_INT;
bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[0]) +sizeof(int) * i;
bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[0]) + sizeof(int) * i;
}
}

View File

@@ -72,7 +72,7 @@ gbt_var_key_readable(const GBT_VARKEY *k)
* Create a leaf-entry to store in the index, from a single Datum.
*/
static GBT_VARKEY *
gbt_var_key_from_datum(const struct varlena * u)
gbt_var_key_from_datum(const struct varlena *u)
{
int32 lowersize = VARSIZE(u);
GBT_VARKEY *r;

View File

@@ -179,7 +179,7 @@ dblink_conn_not_avail(const char *conname)
static void
dblink_get_conn(char *conname_or_str,
PGconn *volatile * conn_p, char **conname_p, volatile bool *freeconn_p)
PGconn *volatile *conn_p, char **conname_p, volatile bool *freeconn_p)
{
remoteConn *rconn = getConnectionByName(conname_or_str);
PGconn *conn;
@@ -723,7 +723,7 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async)
/* shouldn't happen */
elog(ERROR, "wrong number of arguments");
}
else /* is_async */
else /* is_async */
{
/* get async result */
conname = text_to_cstring(PG_GETARG_TEXT_PP(0));

View File

@@ -389,7 +389,7 @@ _metaphone(char *word, /* IN */
/*-- Allocate memory for our phoned_phrase --*/
if (max_phonemes == 0)
{ /* Assume largest possible */
*phoned_word = palloc(sizeof(char) * strlen(word) +1);
*phoned_word = palloc(sizeof(char) * strlen(word) + 1);
}
else
{
@@ -722,7 +722,7 @@ _metaphone(char *word, /* IN */
End_Phoned_Word;
return (META_SUCCESS);
} /* END metaphone */
} /* END metaphone */
/*

View File

@@ -93,7 +93,7 @@ ginint4_queryextract(PG_FUNCTION_ARGS)
case RTOldContainsStrategyNumber:
if (*nentries > 0)
*searchMode = GIN_SEARCH_MODE_DEFAULT;
else /* everything contains the empty set */
else /* everything contains the empty set */
*searchMode = GIN_SEARCH_MODE_ALL;
break;
default:

View File

@@ -147,7 +147,7 @@ static struct
{
bool muse;
uint32 high_pos;
} SomeStack =
} SomeStack =
{
false, 0,

View File

@@ -57,7 +57,7 @@ void sql_exec_dumpalltbspc(PGconn *, struct options *);
/* function to parse command line options and check for some usage errors. */
void
get_opts(int argc, char **argv, struct options * my_opts)
get_opts(int argc, char **argv, struct options *my_opts)
{
int c;
const char *progname;
@@ -260,7 +260,7 @@ get_comma_elts(eary *eary)
/* establish connection with database. */
PGconn *
sql_conn(struct options * my_opts)
sql_conn(struct options *my_opts)
{
PGconn *conn;
bool have_password = false;
@@ -411,7 +411,7 @@ sql_exec(PGconn *conn, const char *todo, bool quiet)
* Dump all databases. There are no system objects to worry about.
*/
void
sql_exec_dumpalldbs(PGconn *conn, struct options * opts)
sql_exec_dumpalldbs(PGconn *conn, struct options *opts)
{
char todo[1024];
@@ -428,7 +428,7 @@ sql_exec_dumpalldbs(PGconn *conn, struct options * opts)
* Dump all tables, indexes and sequences in the current database.
*/
void
sql_exec_dumpalltables(PGconn *conn, struct options * opts)
sql_exec_dumpalltables(PGconn *conn, struct options *opts)
{
char todo[1024];
char *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" ";
@@ -460,7 +460,7 @@ sql_exec_dumpalltables(PGconn *conn, struct options * opts)
* given objects in the current database.
*/
void
sql_exec_searchtables(PGconn *conn, struct options * opts)
sql_exec_searchtables(PGconn *conn, struct options *opts)
{
char *todo;
char *qualifiers,
@@ -516,7 +516,7 @@ sql_exec_searchtables(PGconn *conn, struct options * opts)
CppAsString2(RELKIND_SEQUENCE) ","
CppAsString2(RELKIND_TOASTVALUE) ") AND\n"
" t.oid = CASE\n"
" WHEN reltablespace <> 0 THEN reltablespace\n"
" WHEN reltablespace <> 0 THEN reltablespace\n"
" ELSE dattablespace\n"
" END AND\n"
" (%s)\n"
@@ -530,7 +530,7 @@ sql_exec_searchtables(PGconn *conn, struct options * opts)
}
void
sql_exec_dumpalltbspc(PGconn *conn, struct options * opts)
sql_exec_dumpalltbspc(PGconn *conn, struct options *opts)
{
char todo[1024];

View File

@@ -250,7 +250,7 @@ typedef enum
PGSS_TRACK_NONE, /* track no statements */
PGSS_TRACK_TOP, /* only top level statements */
PGSS_TRACK_ALL /* all statements, including nested ones */
} PGSSTrackLevel;
} PGSSTrackLevel;
static const struct config_enum_entry track_options[] =
{

View File

@@ -325,7 +325,7 @@ generate_trgm(char *str, int slen)
protect_out_of_mem(slen);
trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) *3);
trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) * 3);
trg->flag = ARRKEY;
len = generate_trgm_only(GETARR(trg), str, slen);
@@ -572,8 +572,8 @@ calc_word_similarity(char *str1, int slen1, char *str2, int slen2,
protect_out_of_mem(slen1 + slen2);
/* Make positional trigrams */
trg1 = (trgm *) palloc(sizeof(trgm) * (slen1 / 2 + 1) *3);
trg2 = (trgm *) palloc(sizeof(trgm) * (slen2 / 2 + 1) *3);
trg1 = (trgm *) palloc(sizeof(trgm) * (slen1 / 2 + 1) * 3);
trg2 = (trgm *) palloc(sizeof(trgm) * (slen2 / 2 + 1) * 3);
len1 = generate_trgm_only(trg1, str1, slen1);
len2 = generate_trgm_only(trg2, str2, slen2);
@@ -806,7 +806,7 @@ generate_wildcard_trgm(const char *str, int slen)
protect_out_of_mem(slen);
trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) *3);
trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) * 3);
trg->flag = ARRKEY;
SET_VARSIZE(trg, TRGMHDRSIZE);

View File

@@ -481,7 +481,7 @@ collect_visibility_data(Oid relid, bool include_pd)
check_relation_relkind(rel);
nblocks = RelationGetNumberOfBlocks(rel);
info = palloc0(offsetof(vbits, bits) +nblocks);
info = palloc0(offsetof(vbits, bits) + nblocks);
info->next = 0;
info->count = nblocks;

View File

@@ -908,7 +908,7 @@ mp_int_sqr(mp_int a, mp_int c)
CHECK(a != NULL && c != NULL);
/* Get a temporary buffer big enough to hold the result */
osize = (mp_size) 4 *((MP_USED(a) + 1) / 2);
osize = (mp_size) 4 * ((MP_USED(a) + 1) / 2);
if (a == c)
{
@@ -1613,8 +1613,8 @@ mp_int_gcd(mp_int a, mp_int b, mp_int c)
CLEANUP:
mp_int_clear(&v);
V: mp_int_clear(&u);
U: mp_int_clear(&t);
V: mp_int_clear(&u);
U: mp_int_clear(&t);
return res;
}
@@ -3512,7 +3512,7 @@ s_outlen(mp_int z, mp_size r)
double raw;
bits = mp_int_count_bits(z);
raw = (double) bits *s_log2[r];
raw = (double) bits * s_log2[r];
return (int) (raw + 0.999999);
}

View File

@@ -61,6 +61,7 @@ typedef struct mpz
mp_size used;
mp_sign sign;
} mpz_t ,
*mp_int;
#define MP_DIGITS(Z) ((Z)->digits)
@@ -117,9 +118,9 @@ mp_result mp_int_mul_value(mp_int a, int value, mp_int c);
mp_result mp_int_mul_pow2(mp_int a, int p2, mp_int c);
mp_result mp_int_sqr(mp_int a, mp_int c); /* c = a * a */
mp_result mp_int_div(mp_int a, mp_int b, /* q = a / b */
mp_result mp_int_div(mp_int a, mp_int b, /* q = a / b */
mp_int q, mp_int r); /* r = a % b */
mp_result mp_int_div_value(mp_int a, int value, /* q = a / value */
mp_result mp_int_div_value(mp_int a, int value, /* q = a / value */
mp_int q, int *r); /* r = a % value */
mp_result mp_int_div_pow2(mp_int a, int p2, /* q = a / 2^p2 */
mp_int q, mp_int r); /* r = q % 2^p2 */

View File

@@ -318,7 +318,7 @@ rj_init(PX_Cipher *c, const uint8 *key, unsigned klen, const uint8 *iv)
}
static int
rj_real_init(struct int_ctx * cx, int dir)
rj_real_init(struct int_ctx *cx, int dir)
{
aes_set_key(&cx->ctx.rj, cx->keybuf, cx->keylen * 8, dir);
return 0;

View File

@@ -51,7 +51,7 @@ struct PushFilterOps
* copied (in-place) returns 0 on error
*/
int (*push) (PushFilter *next, void *priv,
const uint8 *src, int len);
const uint8 *src, int len);
int (*flush) (PushFilter *next, void *priv);
void (*free) (void *priv);
};
@@ -69,7 +69,7 @@ struct PullFilterOps
* use buf as work area if NULL in-place copy
*/
int (*pull) (void *priv, PullFilter *src, int len,
uint8 **data_p, uint8 *buf, int buflen);
uint8 **data_p, uint8 *buf, int buflen);
void (*free) (void *priv);
};

View File

@@ -460,7 +460,7 @@ mdcbuf_init(void **priv_p, void *arg, PullFilter *src)
}
static int
mdcbuf_finish(struct MDCBufData * st)
mdcbuf_finish(struct MDCBufData *st)
{
uint8 hash[20];
int res;
@@ -485,7 +485,7 @@ mdcbuf_finish(struct MDCBufData * st)
}
static void
mdcbuf_load_data(struct MDCBufData * st, uint8 *src, int len)
mdcbuf_load_data(struct MDCBufData *st, uint8 *src, int len)
{
uint8 *dst = st->pos + st->avail;
@@ -495,14 +495,14 @@ mdcbuf_load_data(struct MDCBufData * st, uint8 *src, int len)
}
static void
mdcbuf_load_mdc(struct MDCBufData * st, uint8 *src, int len)
mdcbuf_load_mdc(struct MDCBufData *st, uint8 *src, int len)
{
memmove(st->mdc_buf + st->mdc_avail, src, len);
st->mdc_avail += len;
}
static int
mdcbuf_refill(struct MDCBufData * st, PullFilter *src)
mdcbuf_refill(struct MDCBufData *st, PullFilter *src)
{
uint8 *data;
int res;

View File

@@ -132,7 +132,7 @@ struct debug_expect
};
static void
fill_expect(struct debug_expect * ex, int text_mode)
fill_expect(struct debug_expect *ex, int text_mode)
{
ex->debug = 0;
ex->expect = 0;
@@ -157,7 +157,7 @@ fill_expect(struct debug_expect * ex, int text_mode)
} while (0)
static void
check_expect(PGP_Context *ctx, struct debug_expect * ex)
check_expect(PGP_Context *ctx, struct debug_expect *ex)
{
EX_CHECK(cipher_algo);
EX_CHECK(s2k_mode);
@@ -179,7 +179,7 @@ show_debug(const char *msg)
static int
set_arg(PGP_Context *ctx, char *key, char *val,
struct debug_expect * ex)
struct debug_expect *ex)
{
int res = 0;
@@ -317,7 +317,7 @@ downcase_convert(const uint8 *s, int len)
static int
parse_args(PGP_Context *ctx, uint8 *args, int arg_len,
struct debug_expect * ex)
struct debug_expect *ex)
{
char *str = downcase_convert(args, arg_len);
char *key,
@@ -362,7 +362,7 @@ create_mbuf_from_vardata(text *data)
static void
init_work(PGP_Context **ctx_p, int is_text,
text *args, struct debug_expect * ex)
text *args, struct debug_expect *ex)
{
int err = pgp_init(ctx_p);

View File

@@ -74,7 +74,7 @@ struct px_crypt_algo
char *id;
unsigned id_len;
char *(*crypt) (const char *psw, const char *salt,
char *buf, unsigned len);
char *buf, unsigned len);
};
static const struct px_crypt_algo
@@ -115,7 +115,7 @@ struct generator
{
char *name;
char *(*gen) (unsigned long count, const char *input, int size,
char *output, int output_size);
char *output, int output_size);
int input_len;
int def_rounds;
int min_rounds;

View File

@@ -169,11 +169,11 @@ struct px_cipher
struct px_combo
{
int (*init) (PX_Combo *cx, const uint8 *key, unsigned klen,
const uint8 *iv, unsigned ivlen);
const uint8 *iv, unsigned ivlen);
int (*encrypt) (PX_Combo *cx, const uint8 *data, unsigned dlen,
uint8 *res, unsigned *rlen);
uint8 *res, unsigned *rlen);
int (*decrypt) (PX_Combo *cx, const uint8 *data, unsigned dlen,
uint8 *res, unsigned *rlen);
uint8 *res, unsigned *rlen);
unsigned (*encrypt_len) (PX_Combo *cx, unsigned dlen);
unsigned (*decrypt_len) (PX_Combo *cx, unsigned dlen);
void (*free) (PX_Combo *cx);

View File

@@ -44,8 +44,7 @@ typedef struct _rijndael_ctx
/* These are all based on 32 bit unsigned values and will therefore */
/* require endian conversions for big-endian architectures */
rijndael_ctx *
rijndael_set_key(rijndael_ctx *, const u4byte *, const u4byte, int);
rijndael_ctx *rijndael_set_key(rijndael_ctx *, const u4byte *, const u4byte, int);
void rijndael_encrypt(rijndael_ctx *, const u4byte *, u4byte *);
void rijndael_decrypt(rijndael_ctx *, const u4byte *, u4byte *);

View File

@@ -81,7 +81,7 @@ do { \
static void sha1_step(struct sha1_ctxt *);
static void
sha1_step(struct sha1_ctxt * ctxt)
sha1_step(struct sha1_ctxt *ctxt)
{
uint32 a,
b,
@@ -226,7 +226,7 @@ sha1_step(struct sha1_ctxt * ctxt)
/*------------------------------------------------------------*/
void
sha1_init(struct sha1_ctxt * ctxt)
sha1_init(struct sha1_ctxt *ctxt)
{
memset(ctxt, 0, sizeof(struct sha1_ctxt));
H(0) = 0x67452301;
@@ -237,7 +237,7 @@ sha1_init(struct sha1_ctxt * ctxt)
}
void
sha1_pad(struct sha1_ctxt * ctxt)
sha1_pad(struct sha1_ctxt *ctxt)
{
size_t padlen; /* pad length in bytes */
size_t padstart;
@@ -280,7 +280,7 @@ sha1_pad(struct sha1_ctxt * ctxt)
}
void
sha1_loop(struct sha1_ctxt * ctxt, const uint8 *input0, size_t len)
sha1_loop(struct sha1_ctxt *ctxt, const uint8 *input0, size_t len)
{
const uint8 *input;
size_t gaplen;
@@ -308,7 +308,7 @@ sha1_loop(struct sha1_ctxt * ctxt, const uint8 *input0, size_t len)
}
void
sha1_result(struct sha1_ctxt * ctxt, uint8 *digest0)
sha1_result(struct sha1_ctxt *ctxt, uint8 *digest0)
{
uint8 *digest;

View File

@@ -182,7 +182,7 @@ statapprox_heap(Relation rel, output_type *stat)
UnlockReleaseBuffer(buf);
}
stat->table_len = (uint64) nblocks *BLCKSZ;
stat->table_len = (uint64) nblocks * BLCKSZ;
stat->tuple_count = vac_estimate_reltuples(rel, false, nblocks, scanned,
stat->tuple_count + misc_count);

View File

@@ -62,7 +62,7 @@ typedef struct pgstattuple_type
} pgstattuple_type;
typedef void (*pgstat_page) (pgstattuple_type *, Relation, BlockNumber,
BufferAccessStrategy);
BufferAccessStrategy);
static Datum build_pgstattuple_type(pgstattuple_type *stat,
FunctionCallInfo fcinfo);
@@ -386,7 +386,7 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
heap_endscan(scan);
relation_close(rel, AccessShareLock);
stat.table_len = (uint64) nblocks *BLCKSZ;
stat.table_len = (uint64) nblocks * BLCKSZ;
return build_pgstattuple_type(&stat, fcinfo);
}
@@ -531,7 +531,7 @@ pgstat_index(Relation rel, BlockNumber start, pgstat_page pagefn,
/* Quit if we've scanned the whole relation */
if (blkno >= nblocks)
{
stat.table_len = (uint64) nblocks *BLCKSZ;
stat.table_len = (uint64) nblocks * BLCKSZ;
break;
}

View File

@@ -52,7 +52,7 @@ typedef struct
* command. Elsewhere (including the case of default) NULL.
*/
const char *createdb_dtemplate;
} sepgsql_context_info_t;
} sepgsql_context_info_t;
static sepgsql_context_info_t sepgsql_context_info;

View File

@@ -78,7 +78,7 @@ typedef struct
{
SubTransactionId subid;
char *label;
} pending_label;
} pending_label;
/*
* sepgsql_get_client_label
@@ -721,7 +721,7 @@ quote_object_name(const char *src1, const char *src2,
* catalog OID.
*/
static void
exec_object_restorecon(struct selabel_handle * sehnd, Oid catalogId)
exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
{
Relation rel;
SysScanDesc sscan;

View File

@@ -36,7 +36,7 @@ static struct
const char *av_name;
uint32 av_code;
} av[32];
} selinux_catalog[] =
} selinux_catalog[] =
{
{
@@ -732,7 +732,7 @@ void
sepgsql_compute_avd(const char *scontext,
const char *tcontext,
uint16 tclass,
struct av_decision * avd)
struct av_decision *avd)
{
const char *tclass_name;
security_class_t tclass_ex;

View File

@@ -235,7 +235,7 @@ extern void sepgsql_audit_log(bool denied,
extern void sepgsql_compute_avd(const char *scontext,
const char *tcontext,
uint16 tclass,
struct av_decision * avd);
struct av_decision *avd);
extern char *sepgsql_compute_create(const char *scontext,
const char *tcontext,

View File

@@ -45,7 +45,7 @@ typedef struct
/* true, if tcontext is valid */
char *ncontext; /* temporary scontext on execution of trusted
* procedure, or NULL elsewhere */
} avc_cache;
} avc_cache;
/*
* Declaration of static variables

View File

@@ -461,7 +461,7 @@ set_timetravel(PG_FUNCTION_ARGS)
s = rname = DatumGetCString(DirectFunctionCall1(nameout, NameGetDatum(relname)));
if (s)
{
pp = malloc(offsetof(TTOffList, name) +strlen(rname) + 1);
pp = malloc(offsetof(TTOffList, name) + strlen(rname) + 1);
if (pp)
{
pp->next = NULL;

View File

@@ -262,11 +262,11 @@ uuid_generate_internal(int v, unsigned char *ns, char *ptr, int len)
switch (v)
{
case 0: /* constant-value uuids */
case 0: /* constant-value uuids */
strlcpy(strbuf, ptr, 37);
break;
case 1: /* time/node-based uuids */
case 1: /* time/node-based uuids */
{
#ifdef HAVE_UUID_E2FS
uuid_t uu;
@@ -316,8 +316,8 @@ uuid_generate_internal(int v, unsigned char *ns, char *ptr, int len)
break;
}
case 3: /* namespace-based MD5 uuids */
case 5: /* namespace-based SHA1 uuids */
case 3: /* namespace-based MD5 uuids */
case 5: /* namespace-based SHA1 uuids */
{
dce_uuid_t uu;
#ifdef HAVE_UUID_BSD
@@ -373,7 +373,7 @@ uuid_generate_internal(int v, unsigned char *ns, char *ptr, int len)
break;
}
case 4: /* random uuid */
case 4: /* random uuid */
default:
{
#ifdef HAVE_UUID_E2FS

View File

@@ -47,7 +47,7 @@ struct _param
long transaction_limit;
};
static int vacuumlo(const char *database, const struct _param * param);
static int vacuumlo(const char *database, const struct _param *param);
static void usage(const char *progname);
@@ -56,7 +56,7 @@ static void usage(const char *progname);
* This vacuums LOs of one database. It returns 0 on success, -1 on failure.
*/
static int
vacuumlo(const char *database, const struct _param * param)
vacuumlo(const char *database, const struct _param *param)
{
PGconn *conn;
PGresult *res,

View File

@@ -720,7 +720,7 @@ xpath_table(PG_FUNCTION_ARGS)
/* Parse the document */
if (xmldoc)
doctree = xmlParseMemory(xmldoc, strlen(xmldoc));
else /* treat NULL as not well-formed */
else /* treat NULL as not well-formed */
doctree = NULL;
if (doctree == NULL)