Hello,

I think I've managed to improve pg_bsd_indent's handling of two types of cases.

The first are like in this example:
-       hashp = (HTAB *) DynaHashAlloc(sizeof(HTAB) + strlen(tabname) +1);
+       hashp = (HTAB *) DynaHashAlloc(sizeof(HTAB) + strlen(tabname) + 1);
Pristine pg_bsd_indent is inconsistent in masking parentheses as those that are part of a cast and those that "are part of sizeof": seeing a type name following an lparen it always masks that lparen as a part of a cast; seeing an rparen it only removes the bit if it doesn't overlap with sizeof_mask. In the example above, "(HTAB" started both "cast parens" and "sizeof parens" at the same time, and the immediately following rparen ended only the "sizeof parens". According to indent, the cast-to type then ends at "tabname)" and what follows is the cast's operand, including the + operator; in that case it's assumed to be unary and not binary, which is why indent doesn't add the space after it.
The fix was to make it consistent about masking parens:
-                                       ps.cast_mask |= 1 << ps.p_l_follow;
+                                       ps.cast_mask |= (1 << ps.p_l_follow & 
~ps.sizeof_mask);

The second type of cases are like this:
-       nse = palloc(offsetof(PLpgSQL_nsitem, name) +strlen(name) + 1);
+       nse = palloc(offsetof(PLpgSQL_nsitem, name) + strlen(name) + 1);
pg_bsd_indent simply hasn't been taught that a parenthesized type name following the offsetof macro and then an lparen is another exception to the rule of thumb that a construction like that generally means a cast.

You'll also notice other, seemingly unrelated changes, most notably the rearrangement in numbers assigned to keywords. I've done it that way so that it was easier and simpler to keep the -bs option functioning as designed.

I've also renamed "sizeof_mask" to "not_cast_mask", because I think the latter is a better description of what the mask does (it prevents interpreting parenthesized type names as a cast where they aren't, namely where they follow sizeof or offsetof; I haven't done any support for function declarators and I don't plan to - the fact that pg_bsd_indent thinks that "(int" in "char func(int);" begins a cast is amusing but it seems harmless for now).

I'm attaching the patch for pg_bsd_indent and also a full diff that shows the change in its behavior when run against PG's sources.
diff -Burw indent.c indent.c
--- indent.c	2014-01-31 04:06:43.000000000 +0100
+++ indent.c	2016-05-22 19:24:01.666077311 +0200
@@ -568,7 +568,9 @@
 						 * happy */
 			if (ps.want_blank && *token != '[' &&
 			    (ps.last_token != ident || proc_calls_space
-				|| (ps.its_a_keyword && (!ps.sizeof_keyword || Bill_Shannon))))
+			    /* offsetof (1) is never allowed a space; sizeof (2) iff -bs;
+			     * all other keywords (>2) always get a space before lparen */
+				|| (ps.keyword + Bill_Shannon > 2)))
 				*e_code++ = ' ';
 			if (ps.in_decl && !ps.block_init) {
 				if (troff && !ps.dumped_decl_indent && !is_procname && ps.last_token == decl) {
@@ -601,17 +603,19 @@
 							 * structure decl or
 							 * initialization */
 			}
-			if (ps.sizeof_keyword)
-				ps.sizeof_mask |= 1 << ps.p_l_follow;
+			/* a parenthesized type name following sizeof or offsetof is not
+			 * a cast */
+			if (ps.keyword == 1 || ps.keyword == 2)
+				ps.not_cast_mask |= 1 << ps.p_l_follow;
 			break;
 
 		case rparen:	/* got a ')' or ']' */
 			rparen_count--;
-			if (ps.cast_mask & (1 << ps.p_l_follow) & ~ps.sizeof_mask) {
+			if (ps.cast_mask & (1 << ps.p_l_follow) & ~ps.not_cast_mask) {
 				ps.last_u_d = true;
 				ps.cast_mask &= (1 << ps.p_l_follow) - 1;
 			}
-			ps.sizeof_mask &= (1 << ps.p_l_follow) - 1;
+			ps.not_cast_mask &= (1 << ps.p_l_follow) - 1;
 			if (--ps.p_l_follow < 0) {
 				ps.p_l_follow = 0;
 				diag(0, "Extra %c", *token);
@@ -780,7 +784,7 @@
 			if (ps.last_token == rparen && rparen_count == 0)
 				ps.in_parameter_declaration = 0;
 			ps.cast_mask = 0;
-			ps.sizeof_mask = 0;
+			ps.not_cast_mask = 0;
 			ps.block_init = 0;
 			ps.block_init_level = 0;
 			ps.just_saw_decl--;
@@ -1042,7 +1046,7 @@
 	copy_id:
 			if (ps.want_blank)
 				*e_code++ = ' ';
-			if (troff && ps.its_a_keyword) {
+			if (troff && ps.keyword) {
 				e_code = chfont(&bodyf, &keywordf, e_code);
 				for (t_ptr = token; *t_ptr; ++t_ptr) {
 					CHECK_SIZE_CODE;
diff -Burw indent_globs.h indent_globs.h
--- indent_globs.h	2005-11-15 01:30:24.000000000 +0100
+++ indent_globs.h	2016-05-22 19:23:45.067093287 +0200
@@ -255,10 +255,10 @@
 				 * comment. In that case, the first non-blank
 				 * char should be lined up with the comment / */
 	int     comment_delta, n_comment_delta;
-	int     cast_mask;	/* indicates which close parens close off
-				 * casts */
-	int     sizeof_mask;	/* indicates which close parens close off
-				 * sizeof''s */
+	int     cast_mask;	/* indicates which close parens potentially
+				 * close off casts */
+	int     not_cast_mask;	/* indicates which close parens definitely
+				 * close off something else than casts */
 	int     block_init;	/* true iff inside a block initialization */
 	int     block_init_level;	/* The level of brace nesting in an
 					 * initialization */
@@ -327,8 +327,7 @@
 	int     else_if;	/* True iff else if pairs should be handled
 				 * specially */
 	int     decl_indent;	/* column to indent declared identifiers to */
-	int     its_a_keyword;
-	int     sizeof_keyword;
+	int     keyword; /* the type of a keyword or 0 */
 	int     dumped_decl_indent;
 	float   case_indent;	/* The distance to indent case labels from the
 				 * switch statement */
Binary files indent.o and indent.o differ
Binary files io.o and io.o differ
diff -Burw lexi.c lexi.c
--- lexi.c	2005-11-15 01:30:24.000000000 +0100
+++ lexi.c	2016-05-22 19:24:06.591072566 +0200
@@ -95,13 +95,13 @@
 
 struct templ specials[16384] =
 {
-	{"switch", 1},
-	{"case", 2},
-	{"break", 0},
+	{"switch", 7},
+	{"case", 8},
+	{"break", 9},
 	{"struct", 3},
 	{"union", 3},
 	{"enum", 3},
-	{"default", 2},
+	{"default", 8},
 	{"int", 4},
 	{"char", 4},
 	{"float", 4},
@@ -115,14 +115,15 @@
 	{"global", 4},
 	{"extern", 4},
 	{"void", 4},
-	{"goto", 0},
-	{"return", 0},
+	{"goto", 9},
+	{"return", 9},
 	{"if", 5},
 	{"while", 5},
 	{"for", 5},
 	{"else", 6},
 	{"do", 6},
-	{"sizeof", 7},
+	{"sizeof", 2},
+	{"offsetof", 1},
 	{0, 0}
 };
 
@@ -262,8 +263,7 @@
 			if (++buf_ptr >= buf_end)
 				fill_buffer();
 		}
-		ps.its_a_keyword = false;
-		ps.sizeof_keyword = false;
+		ps.keyword = 0;
 		if (l_struct) {	/* if last token was 'struct', then this token
 				 * should be treated as a declaration */
 			l_struct = false;
@@ -297,12 +297,12 @@
 		}
 		if (p->rwd) {	/* we have a keyword */
 	found_keyword:
-			ps.its_a_keyword = true;
+			ps.keyword = p->rwcode;
 			ps.last_u_d = true;
 			switch (p->rwcode) {
-			case 1:/* it is a switch */
+			case 7:/* it is a switch */
 				return (swstmt);
-			case 2:/* a case or default */
+			case 8:/* a case or default */
 				return (casestmt);
 
 			case 3:/* a "struct" */
@@ -316,7 +316,11 @@
 				 */
 			case 4:/* one of the declaration keywords */
 				if (ps.p_l_follow) {
-					ps.cast_mask |= 1 << ps.p_l_follow;
+					/* A type name following an lparen is a cast unless it's
+					 * a part of a function declarator, or an operand of the
+					 * sizeof operator, or an argument of the offsetof macro
+					 */
+					ps.cast_mask |= (1 << ps.p_l_follow & ~ps.not_cast_mask);
 					break;	/* inside parens: cast */
 				}
 				last_code = decl;
@@ -328,8 +332,6 @@
 			case 6:/* do, else */
 				return (sp_nparen);
 
-			case 7:
-				ps.sizeof_keyword = true;
 			default:	/* all others are treated like any
 					 * other identifier */
 				return (ident);
@@ -357,7 +359,7 @@
 		    && (ps.last_token == rparen || ps.last_token == semicolon ||
 			ps.last_token == decl ||
 			ps.last_token == lbrace || ps.last_token == rbrace)) {
-			ps.its_a_keyword = true;
+			ps.keyword = 4; /* a type name */
 			ps.last_u_d = true;
 			last_code = decl;
 			return decl;
diff -ur 2/contrib/fuzzystrmatch/fuzzystrmatch.c 3/contrib/fuzzystrmatch/fuzzystrmatch.c
--- 2/contrib/fuzzystrmatch/fuzzystrmatch.c	2016-05-22 09:47:04.223053228 +0200
+++ 3/contrib/fuzzystrmatch/fuzzystrmatch.c	2016-05-22 19:31:41.150634978 +0200
@@ -388,7 +388,7 @@
 	/*-- 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
 	{
diff -ur 2/contrib/pg_trgm/trgm_op.c 3/contrib/pg_trgm/trgm_op.c
--- 2/contrib/pg_trgm/trgm_op.c	2016-05-22 09:47:03.424053922 +0200
+++ 3/contrib/pg_trgm/trgm_op.c	2016-05-22 19:31:40.328635769 +0200
@@ -325,7 +325,7 @@
 
 	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 @@
 	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 @@
 
 	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);
 
diff -ur 2/contrib/pg_visibility/pg_visibility.c 3/contrib/pg_visibility/pg_visibility.c
--- 2/contrib/pg_visibility/pg_visibility.c	2016-05-22 09:47:03.371053968 +0200
+++ 3/contrib/pg_visibility/pg_visibility.c	2016-05-22 19:31:40.276635820 +0200
@@ -301,7 +301,7 @@
 	rel = relation_open(relid, AccessShareLock);
 
 	nblocks = RelationGetNumberOfBlocks(rel);
-	info = palloc0(offsetof(vbits, bits) +nblocks);
+	info = palloc0(offsetof(vbits, bits) + nblocks);
 	info->next = 0;
 	info->count = nblocks;
 
diff -ur 2/contrib/spi/timetravel.c 3/contrib/spi/timetravel.c
--- 2/contrib/spi/timetravel.c	2016-05-22 09:47:02.096055076 +0200
+++ 3/contrib/spi/timetravel.c	2016-05-22 19:31:39.046637004 +0200
@@ -460,7 +460,7 @@
 			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;
diff -ur 2/src/backend/access/common/reloptions.c 3/src/backend/access/common/reloptions.c
--- 2/src/backend/access/common/reloptions.c	2016-05-22 09:47:01.656055458 +0200
+++ 3/src/backend/access/common/reloptions.c	2016-05-22 19:31:38.634637400 +0200
@@ -1277,33 +1277,33 @@
 	static const relopt_parse_elt tab[] = {
 		{"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)},
 		{"autovacuum_enabled", RELOPT_TYPE_BOOL,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, enabled)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)},
 		{"autovacuum_vacuum_threshold", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_threshold)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_threshold)},
 		{"autovacuum_analyze_threshold", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, analyze_threshold)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_threshold)},
 		{"autovacuum_vacuum_cost_delay", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_cost_delay)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_delay)},
 		{"autovacuum_vacuum_cost_limit", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_cost_limit)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_cost_limit)},
 		{"autovacuum_freeze_min_age", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_min_age)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_min_age)},
 		{"autovacuum_freeze_max_age", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_max_age)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_max_age)},
 		{"autovacuum_freeze_table_age", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, freeze_table_age)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, freeze_table_age)},
 		{"autovacuum_multixact_freeze_min_age", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, multixact_freeze_min_age)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_min_age)},
 		{"autovacuum_multixact_freeze_max_age", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, multixact_freeze_max_age)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_max_age)},
 		{"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, multixact_freeze_table_age)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_table_age)},
 		{"log_autovacuum_min_duration", RELOPT_TYPE_INT,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, log_min_duration)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_min_duration)},
 		{"autovacuum_vacuum_scale_factor", RELOPT_TYPE_REAL,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_scale_factor)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, vacuum_scale_factor)},
 		{"autovacuum_analyze_scale_factor", RELOPT_TYPE_REAL,
-		offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, analyze_scale_factor)},
+		offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, analyze_scale_factor)},
 		{"user_catalog_table", RELOPT_TYPE_BOOL,
 		offsetof(StdRdOptions, user_catalog_table)},
 		{"parallel_degree", RELOPT_TYPE_INT,
diff -ur 2/src/backend/access/gin/gindatapage.c 3/src/backend/access/gin/gindatapage.c
--- 2/src/backend/access/gin/gindatapage.c	2016-05-22 09:47:01.544055555 +0200
+++ 3/src/backend/access/gin/gindatapage.c	2016-05-22 19:31:38.493637536 +0200
@@ -390,7 +390,7 @@
 		if (offset != maxoff + 1)
 			memmove(ptr + sizeof(PostingItem),
 					ptr,
-					(maxoff - offset + 1) *sizeof(PostingItem));
+					(maxoff - offset + 1) * sizeof(PostingItem));
 	}
 	memcpy(ptr, data, sizeof(PostingItem));
 
diff -ur 2/src/backend/access/transam/xlog.c 3/src/backend/access/transam/xlog.c
--- 2/src/backend/access/transam/xlog.c	2016-05-22 09:46:59.522057311 +0200
+++ 3/src/backend/access/transam/xlog.c	2016-05-22 19:31:36.446639506 +0200
@@ -4703,7 +4703,7 @@
 
 	/* WAL insertion locks. Ensure they're aligned to the full padded size */
 	allocptr += sizeof(WALInsertLockPadded) -
-		((uintptr_t) allocptr) %sizeof(WALInsertLockPadded);
+		((uintptr_t) allocptr) % sizeof(WALInsertLockPadded);
 	WALInsertLocks = XLogCtl->Insert.WALInsertLocks =
 		(WALInsertLockPadded *) allocptr;
 	allocptr += sizeof(WALInsertLockPadded) * NUM_XLOGINSERT_LOCKS;
diff -ur 2/src/backend/lib/binaryheap.c 3/src/backend/lib/binaryheap.c
--- 2/src/backend/lib/binaryheap.c	2016-05-22 09:46:56.162060229 +0200
+++ 3/src/backend/lib/binaryheap.c	2016-05-22 19:31:32.874642945 +0200
@@ -35,7 +35,7 @@
 	int			sz;
 	binaryheap *heap;
 
-	sz = offsetof(binaryheap, bh_nodes) +sizeof(Datum) * capacity;
+	sz = offsetof(binaryheap, bh_nodes) + sizeof(Datum) * capacity;
 	heap = (binaryheap *) palloc(sz);
 	heap->bh_space = capacity;
 	heap->bh_compare = compare;
diff -ur 2/src/backend/postmaster/pgstat.c 3/src/backend/postmaster/pgstat.c
--- 2/src/backend/postmaster/pgstat.c	2016-05-22 09:46:53.037062944 +0200
+++ 3/src/backend/postmaster/pgstat.c	2016-05-22 19:31:29.862645845 +0200
@@ -1027,7 +1027,7 @@
 		if (msg.m_nentries >= PGSTAT_NUM_TABPURGE)
 		{
 			len = offsetof(PgStat_MsgTabpurge, m_tableid[0])
-				+msg.m_nentries * sizeof(Oid);
+				+ msg.m_nentries * sizeof(Oid);
 
 			pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE);
 			msg.m_databaseid = MyDatabaseId;
@@ -1043,7 +1043,7 @@
 	if (msg.m_nentries > 0)
 	{
 		len = offsetof(PgStat_MsgTabpurge, m_tableid[0])
-			+msg.m_nentries * sizeof(Oid);
+			+ msg.m_nentries * sizeof(Oid);
 
 		pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE);
 		msg.m_databaseid = MyDatabaseId;
@@ -1087,7 +1087,7 @@
 			if (f_msg.m_nentries >= PGSTAT_NUM_FUNCPURGE)
 			{
 				len = offsetof(PgStat_MsgFuncpurge, m_functionid[0])
-					+f_msg.m_nentries * sizeof(Oid);
+					+ f_msg.m_nentries * sizeof(Oid);
 
 				pgstat_send(&f_msg, len);
 
@@ -1101,7 +1101,7 @@
 		if (f_msg.m_nentries > 0)
 		{
 			len = offsetof(PgStat_MsgFuncpurge, m_functionid[0])
-				+f_msg.m_nentries * sizeof(Oid);
+				+ f_msg.m_nentries * sizeof(Oid);
 
 			pgstat_send(&f_msg, len);
 		}
@@ -1204,7 +1204,7 @@
 	msg.m_tableid[0] = relid;
 	msg.m_nentries = 1;
 
-	len = offsetof(PgStat_MsgTabpurge, m_tableid[0]) +sizeof(Oid);
+	len = offsetof(PgStat_MsgTabpurge, m_tableid[0]) + sizeof(Oid);
 
 	pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE);
 	msg.m_databaseid = MyDatabaseId;
diff -ur 2/src/backend/postmaster/syslogger.c 3/src/backend/postmaster/syslogger.c
--- 2/src/backend/postmaster/syslogger.c	2016-05-22 09:46:52.823063130 +0200
+++ 3/src/backend/postmaster/syslogger.c	2016-05-22 19:31:29.656646043 +0200
@@ -785,7 +785,7 @@
 	int			dest = LOG_DESTINATION_STDERR;
 
 	/* While we have enough for a header, process data... */
-	while (count >= (int) (offsetof(PipeProtoHeader, data) +1))
+	while (count >= (int) (offsetof(PipeProtoHeader, data) + 1))
 	{
 		PipeProtoHeader p;
 		int			chunklen;
diff -ur 2/src/backend/replication/slot.c 3/src/backend/replication/slot.c
--- 2/src/backend/replication/slot.c	2016-05-22 09:46:52.303063581 +0200
+++ 3/src/backend/replication/slot.c	2016-05-22 19:31:29.062646615 +0200
@@ -140,7 +140,7 @@
 
 	ReplSlotIOLWLockTranche.name = "replication_slot_io";
 	ReplSlotIOLWLockTranche.array_base =
-		((char *) ReplicationSlotCtl) + offsetof(ReplicationSlotCtlData, replication_slots) +offsetof(ReplicationSlot, io_in_progress_lock);
+		((char *) ReplicationSlotCtl) + offsetof(ReplicationSlotCtlData, replication_slots) + offsetof(ReplicationSlot, io_in_progress_lock);
 	ReplSlotIOLWLockTranche.array_stride = sizeof(ReplicationSlot);
 	LWLockRegisterTranche(LWTRANCHE_REPLICATION_SLOT_IO_IN_PROGRESS,
 						  &ReplSlotIOLWLockTranche);
diff -ur 2/src/backend/storage/ipc/dsm.c 3/src/backend/storage/ipc/dsm.c
--- 2/src/backend/storage/ipc/dsm.c	2016-05-22 09:46:51.781064035 +0200
+++ 3/src/backend/storage/ipc/dsm.c	2016-05-22 19:31:28.561647097 +0200
@@ -1040,5 +1040,5 @@
 dsm_control_bytes_needed(uint32 nitems)
 {
 	return offsetof(dsm_control_header, item)
-		+sizeof(dsm_control_item) * (uint64) nitems;
+		+ sizeof(dsm_control_item) * (uint64) nitems;
 }
diff -ur 2/src/backend/storage/ipc/shm_mq.c 3/src/backend/storage/ipc/shm_mq.c
--- 2/src/backend/storage/ipc/shm_mq.c	2016-05-22 09:46:51.531064252 +0200
+++ 3/src/backend/storage/ipc/shm_mq.c	2016-05-22 19:31:28.395647257 +0200
@@ -364,7 +364,7 @@
 	{
 		Assert(mqh->mqh_partial_bytes < sizeof(Size));
 		res = shm_mq_send_bytes(mqh, sizeof(Size) - mqh->mqh_partial_bytes,
-								((char *) &nbytes) +mqh->mqh_partial_bytes,
+								((char *) &nbytes) + mqh->mqh_partial_bytes,
 								nowait, &bytes_written);
 		mqh->mqh_partial_bytes += bytes_written;
 		if (res != SHM_MQ_SUCCESS)
diff -ur 2/src/backend/storage/ipc/shm_toc.c 3/src/backend/storage/ipc/shm_toc.c
--- 2/src/backend/storage/ipc/shm_toc.c	2016-05-22 09:46:51.509064271 +0200
+++ 3/src/backend/storage/ipc/shm_toc.c	2016-05-22 19:31:28.373647278 +0200
@@ -96,7 +96,7 @@
 	total_bytes = vtoc->toc_total_bytes;
 	allocated_bytes = vtoc->toc_allocated_bytes;
 	nentry = vtoc->toc_nentry;
-	toc_bytes = offsetof(shm_toc, toc_entry) +nentry * sizeof(shm_toc_entry)
+	toc_bytes = offsetof(shm_toc, toc_entry) + nentry * sizeof(shm_toc_entry)
 		+ allocated_bytes;
 
 	/* Check for memory exhaustion and overflow. */
@@ -132,7 +132,7 @@
 	nentry = vtoc->toc_nentry;
 	SpinLockRelease(&toc->toc_mutex);
 
-	toc_bytes = offsetof(shm_toc, toc_entry) +nentry * sizeof(shm_toc_entry);
+	toc_bytes = offsetof(shm_toc, toc_entry) + nentry * sizeof(shm_toc_entry);
 	Assert(allocated_bytes + BUFFERALIGN(toc_bytes) <= total_bytes);
 	return total_bytes - (allocated_bytes + BUFFERALIGN(toc_bytes));
 }
@@ -176,7 +176,7 @@
 	total_bytes = vtoc->toc_total_bytes;
 	allocated_bytes = vtoc->toc_allocated_bytes;
 	nentry = vtoc->toc_nentry;
-	toc_bytes = offsetof(shm_toc, toc_entry) +nentry * sizeof(shm_toc_entry)
+	toc_bytes = offsetof(shm_toc, toc_entry) + nentry * sizeof(shm_toc_entry)
 		+ allocated_bytes;
 
 	/* Check for memory exhaustion and overflow. */
diff -ur 2/src/backend/utils/adt/geo_ops.c 3/src/backend/utils/adt/geo_ops.c
--- 2/src/backend/utils/adt/geo_ops.c	2016-05-22 09:46:49.753065796 +0200
+++ 3/src/backend/utils/adt/geo_ops.c	2016-05-22 19:31:26.697648892 +0200
@@ -1333,7 +1333,7 @@
 	}
 
 	base_size = sizeof(path->p[0]) * npts;
-	size = offsetof(PATH, p) +base_size;
+	size = offsetof(PATH, p) + base_size;
 
 	/* Check for integer overflow */
 	if (base_size / npts != sizeof(path->p[0]) || size <= base_size)
@@ -1403,7 +1403,7 @@
 				(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
 			 errmsg("invalid number of points in external \"path\" value")));
 
-	size = offsetof(PATH, p) +sizeof(path->p[0]) * npts;
+	size = offsetof(PATH, p) + sizeof(path->p[0]) * npts;
 	path = (PATH *) palloc(size);
 
 	SET_VARSIZE(path, size);
@@ -3423,7 +3423,7 @@
 						"polygon", str)));
 
 	base_size = sizeof(poly->p[0]) * npts;
-	size = offsetof(POLYGON, p) +base_size;
+	size = offsetof(POLYGON, p) + base_size;
 
 	/* Check for integer overflow */
 	if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
@@ -3478,7 +3478,7 @@
 				(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
 		  errmsg("invalid number of points in external \"polygon\" value")));
 
-	size = offsetof(POLYGON, p) +sizeof(poly->p[0]) * npts;
+	size = offsetof(POLYGON, p) + sizeof(poly->p[0]) * npts;
 	poly = (POLYGON *) palloc0(size);	/* zero any holes */
 
 	SET_VARSIZE(poly, size);
@@ -4235,7 +4235,7 @@
 		PG_RETURN_NULL();
 
 	base_size = sizeof(p1->p[0]) * (p1->npts + p2->npts);
-	size = offsetof(PATH, p) +base_size;
+	size = offsetof(PATH, p) + base_size;
 
 	/* Check for integer overflow */
 	if (base_size / sizeof(p1->p[0]) != (p1->npts + p2->npts) ||
@@ -4377,7 +4377,7 @@
 	 * Never overflows: the old size fit in MaxAllocSize, and the new size is
 	 * just a small constant larger.
 	 */
-	size = offsetof(POLYGON, p) +sizeof(poly->p[0]) * path->npts;
+	size = offsetof(POLYGON, p) + sizeof(poly->p[0]) * path->npts;
 	poly = (POLYGON *) palloc(size);
 
 	SET_VARSIZE(poly, size);
@@ -4452,7 +4452,7 @@
 	int			size;
 
 	/* map four corners of the box to a polygon */
-	size = offsetof(POLYGON, p) +sizeof(poly->p[0]) * 4;
+	size = offsetof(POLYGON, p) + sizeof(poly->p[0]) * 4;
 	poly = (POLYGON *) palloc(size);
 
 	SET_VARSIZE(poly, size);
@@ -4486,7 +4486,7 @@
 	 * Never overflows: the old size fit in MaxAllocSize, and the new size is
 	 * smaller by a small constant.
 	 */
-	size = offsetof(PATH, p) +sizeof(path->p[0]) * poly->npts;
+	size = offsetof(PATH, p) + sizeof(path->p[0]) * poly->npts;
 	path = (PATH *) palloc(size);
 
 	SET_VARSIZE(path, size);
@@ -5164,7 +5164,7 @@
 				 errmsg("must request at least 2 points")));
 
 	base_size = sizeof(poly->p[0]) * npts;
-	size = offsetof(POLYGON, p) +base_size;
+	size = offsetof(POLYGON, p) + base_size;
 
 	/* Check for integer overflow */
 	if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
diff -ur 2/src/backend/utils/cache/catcache.c 3/src/backend/utils/cache/catcache.c
--- 2/src/backend/utils/cache/catcache.c	2016-05-22 09:46:46.925068252 +0200
+++ 3/src/backend/utils/cache/catcache.c	2016-05-22 19:31:23.932651553 +0200
@@ -1592,7 +1592,7 @@
 		oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
 		nmembers = list_length(ctlist);
 		cl = (CatCList *)
-			palloc(offsetof(CatCList, members) +nmembers * sizeof(CatCTup *));
+			palloc(offsetof(CatCList, members) + nmembers * sizeof(CatCTup *));
 		heap_copytuple_with_tuple(ntp, &cl->tuple);
 		MemoryContextSwitchTo(oldcxt);
 		heap_freetuple(ntp);
diff -ur 2/src/backend/utils/fmgr/dfmgr.c 3/src/backend/utils/fmgr/dfmgr.c
--- 2/src/backend/utils/fmgr/dfmgr.c	2016-05-22 09:46:46.511068612 +0200
+++ 3/src/backend/utils/fmgr/dfmgr.c	2016-05-22 19:31:23.584651888 +0200
@@ -209,7 +209,7 @@
 		 * File not loaded yet.
 		 */
 		file_scanner = (DynamicFileList *)
-			malloc(offsetof(DynamicFileList, filename) +strlen(libname) + 1);
+			malloc(offsetof(DynamicFileList, filename) + strlen(libname) + 1);
 		if (file_scanner == NULL)
 			ereport(ERROR,
 					(errcode(ERRCODE_OUT_OF_MEMORY),
diff -ur 2/src/backend/utils/hash/dynahash.c 3/src/backend/utils/hash/dynahash.c
--- 2/src/backend/utils/hash/dynahash.c	2016-05-22 09:46:46.432068680 +0200
+++ 3/src/backend/utils/hash/dynahash.c	2016-05-22 19:31:23.508651962 +0200
@@ -333,7 +333,7 @@
 	}
 
 	/* Initialize the hash header, plus a copy of the table name */
-	hashp = (HTAB *) DynaHashAlloc(sizeof(HTAB) + strlen(tabname) +1);
+	hashp = (HTAB *) DynaHashAlloc(sizeof(HTAB) + strlen(tabname) + 1);
 	MemSet(hashp, 0, sizeof(HTAB));
 
 	hashp->tabname = (char *) (hashp + 1);
diff -ur 2/src/common/exec.c 3/src/common/exec.c
--- 2/src/common/exec.c	2016-05-22 09:46:42.860071783 +0200
+++ 3/src/common/exec.c	2016-05-22 19:31:19.763655567 +0200
@@ -678,7 +678,7 @@
 
 	/* Figure out the size of the new ACL */
 	dwNewAclSize = asi.AclBytesInUse + sizeof(ACCESS_ALLOWED_ACE) +
-		GetLengthSid(pTokenUser->User.Sid) -sizeof(DWORD);
+		GetLengthSid(pTokenUser->User.Sid) - sizeof(DWORD);
 
 	/* Allocate the ACL buffer & initialize it */
 	pacl = (PACL) LocalAlloc(LPTR, dwNewAclSize);
diff -ur 2/src/fe_utils/simple_list.c 3/src/fe_utils/simple_list.c
--- 2/src/fe_utils/simple_list.c	2016-05-22 09:46:42.651071964 +0200
+++ 3/src/fe_utils/simple_list.c	2016-05-22 19:31:19.541655780 +0200
@@ -65,7 +65,7 @@
 	SimpleStringListCell *cell;
 
 	cell = (SimpleStringListCell *)
-		pg_malloc(offsetof(SimpleStringListCell, val) +strlen(val) + 1);
+		pg_malloc(offsetof(SimpleStringListCell, val) + strlen(val) + 1);
 
 	cell->next = NULL;
 	cell->touched = false;
diff -ur 2/src/interfaces/ecpg/preproc/output.c 3/src/interfaces/ecpg/preproc/output.c
--- 2/src/interfaces/ecpg/preproc/output.c	2016-05-22 09:46:34.437079098 +0200
+++ 3/src/interfaces/ecpg/preproc/output.c	2016-05-22 19:31:11.317663697 +0200
@@ -96,7 +96,7 @@
 		)
 	{
 		/* "* 2" here is for escaping '\' and '"' below */
-		char	   *line = mm_alloc(strlen("\n#line %d \"%s\"\n") + sizeof(int) * CHAR_BIT * 10 / 3 + strlen(input_filename) *2);
+		char	   *line = mm_alloc(strlen("\n#line %d \"%s\"\n") + sizeof(int) * CHAR_BIT * 10 / 3 + strlen(input_filename) * 2);
 		char	   *src,
 				   *dest;
 
diff -ur 2/src/interfaces/libpq/fe-exec.c 3/src/interfaces/libpq/fe-exec.c
--- 2/src/interfaces/libpq/fe-exec.c	2016-05-22 09:46:34.144079353 +0200
+++ 3/src/interfaces/libpq/fe-exec.c	2016-05-22 19:31:11.004663999 +0200
@@ -939,7 +939,7 @@
 	 * Store new info as a single malloc block
 	 */
 	pstatus = (pgParameterStatus *) malloc(sizeof(pgParameterStatus) +
-										   strlen(name) +strlen(value) + 2);
+										   strlen(name) + strlen(value) + 2);
 	if (pstatus)
 	{
 		char	   *ptr;
diff -ur 2/src/pl/plpgsql/src/pl_funcs.c 3/src/pl/plpgsql/src/pl_funcs.c
--- 2/src/pl/plpgsql/src/pl_funcs.c	2016-05-22 09:46:33.621079807 +0200
+++ 3/src/pl/plpgsql/src/pl_funcs.c	2016-05-22 19:31:10.275664700 +0200
@@ -97,7 +97,7 @@
 	/* first item added must be a label */
 	Assert(ns_top != NULL || itemtype == PLPGSQL_NSTYPE_LABEL);
 
-	nse = palloc(offsetof(PLpgSQL_nsitem, name) +strlen(name) + 1);
+	nse = palloc(offsetof(PLpgSQL_nsitem, name) + strlen(name) + 1);
 	nse->itemtype = itemtype;
 	nse->itemno = itemno;
 	nse->prev = ns_top;
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to