Re: assorted code cleanup

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: assorted code cleanup
Date: 2017-08-21 05:11:44
Message-ID: CAB7nPqQHnB_qS41P+Vsi=CrE3L2rjp37F8WX-dJceLzEWO+rvw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 18, 2017 at 1:56 AM, Peter Eisentraut
<peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
> Here are a few assorted patches I made while working on the stdbool set,
> cleaning up various pieces of dead code and weird styles.
>
> - Drop excessive dereferencing of function pointers

- (*next_ProcessUtility_hook) (pstmt, queryString,
+ next_ProcessUtility_hook(pstmt, queryString,
context, params, queryEnv,
dest, completionTag);
But this... Personally I like the current grammar which allows one to
make the difference between a function call with something declared
locally and something that may be going to a custom code path. So I
think that you had better not update the system hooks that external
modules can use via shared_preload_libraries.

> - Remove endof macro

Its last use is 1aa58d3a from 2009.

> - Remove unnecessary casts

Those are also quite old things:
src/include/access/attnum.h: ((bool) ((attributeNumber) !=
InvalidAttrNumber))
src/include/access/attnum.h: ((bool) ((attributeNumber) > 0))
src/backend/utils/hash/dynahash.c: *foundPtr = (bool) (currBucket != NULL);
[... etc ...]

> - Remove unnecessary parentheses in return statements

So you would still keep parenthesis like here for simple expressions:
contrib/bloom/blutils.c: return (x - 1);
No objections.

Here are some more:
contrib/intarray/_int_bool.c: return (calcnot) ?
contrib/ltree/ltxtquery_op.c: return (calcnot) ?

And there are many "(0)" "S_ANYTHING" in src/interfaces/ecpg/test/ and
src/interfaces/ecpg/preproc/.

src/port/ stuff is better left off, good you did not touch it.

> - Remove our own definition of NULL

Fine. c.h uses once NULL before enforcing its definition.

> - fuzzystrmatch: Remove dead code

Those are remnants of a323ede, which missed to removed everything.
Looks good to me.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-08-21 05:23:02 Re: coverage analysis improvements
Previous Message Haribabu Kommi 2017-08-21 04:35:13 Re: Refactor handling of database attributes between pg_dump and pg_dumpall