Re: [HACKERS] Comparison with true in source code

2010-11-14 Thread Robert Haas
On Wed, Nov 3, 2010 at 9:45 PM, Itagaki Takahiro
itagaki.takah...@gmail.com wrote:
 On Wed, Nov 3, 2010 at 2:19 AM, Michael Meskes mes...@postgresql.org wrote:
 On Mon, Nov 01, 2010 at 12:17:02PM +0900, Itagaki Takahiro wrote:
 There are some == true in the codes, but they might not be safe
 because all non-zero values are true in C. Is it worth cleaning up them?

 Here is a proposed cleanup that replaces boolean == true with boolean.
 I didn't touch == false unless they are not in pairs of comparisons
 with true because comparison with false is a valid C code.

 Note that I also changed boolean != true in pg_upgrade,
 but I didn't change ones in xlog.c because it might check
 corrupted fields in control files.

 src/interfaces/ecpg/preproc/ecpg.c(310):
    ptr2ext[3] = (header_mode == true) ? 'h' : 'c';
 I actually see no reason why these variables are not defined as bool instead 
 of
 int, so I changed this. Hopefully I found all of them.

 I added an additional cleanup to 'header_mode' in ecpg; I changed the type
 from bool to char to hold 'h' or 'c'. Do you think it is reasonable?

I looked at this but found that part a bit too clever for its own good.

So committed the rest, plus an additional one-line change to psql's
print.c to avoid making the two accesses to format-wrap_right_pointer
inconsistent with each other.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Comparison with true in source code

2010-11-14 Thread Itagaki Takahiro
On Mon, Nov 15, 2010 at 11:13, Robert Haas robertmh...@gmail.com wrote:
 I added an additional cleanup to 'header_mode' in ecpg; I changed the type
 from bool to char to hold 'h' or 'c'. Do you think it is reasonable?

 I looked at this but found that part a bit too clever for its own good.

 So committed the rest, plus an additional one-line change to psql's
 print.c to avoid making the two accesses to format-wrap_right_pointer
 inconsistent with each other.

Thanks!

-- 
Itagaki Takahiro

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Comparison with true in source code

2010-11-04 Thread Robert Haas
On Wed, Nov 3, 2010 at 6:45 PM, Itagaki Takahiro
itagaki.takah...@gmail.com wrote:
 On Wed, Nov 3, 2010 at 2:19 AM, Michael Meskes mes...@postgresql.org wrote:
 On Mon, Nov 01, 2010 at 12:17:02PM +0900, Itagaki Takahiro wrote:
 There are some == true in the codes, but they might not be safe
 because all non-zero values are true in C. Is it worth cleaning up them?

 Here is a proposed cleanup that replaces boolean == true with boolean.
 I didn't touch == false unless they are not in pairs of comparisons
 with true because comparison with false is a valid C code.

It looks like you have one or two irrelevant whitespace changes in ecpg.c.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Comparison with true in source code

2010-11-03 Thread Itagaki Takahiro
On Wed, Nov 3, 2010 at 2:19 AM, Michael Meskes mes...@postgresql.org wrote:
 On Mon, Nov 01, 2010 at 12:17:02PM +0900, Itagaki Takahiro wrote:
 There are some == true in the codes, but they might not be safe
 because all non-zero values are true in C. Is it worth cleaning up them?

Here is a proposed cleanup that replaces boolean == true with boolean.
I didn't touch == false unless they are not in pairs of comparisons
with true because comparison with false is a valid C code.

Note that I also changed boolean != true in pg_upgrade,
but I didn't change ones in xlog.c because it might check
corrupted fields in control files.

 src/interfaces/ecpg/preproc/ecpg.c(310):
ptr2ext[3] = (header_mode == true) ? 'h' : 'c';
 I actually see no reason why these variables are not defined as bool instead 
 of
 int, so I changed this. Hopefully I found all of them.

I added an additional cleanup to 'header_mode' in ecpg; I changed the type
from bool to char to hold 'h' or 'c'. Do you think it is reasonable?

-- 
Itagaki Takahiro


bool_eq_true_cleanup.patch
Description: Binary data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Comparison with true in source code

2010-11-02 Thread Michael Meskes
On Mon, Nov 01, 2010 at 12:17:02PM +0900, Itagaki Takahiro wrote:
 There are some == true in the codes, but they might not be safe
 because all non-zero values are true in C. Is it worth cleaning up them?
 ...
 src/interfaces/ecpg/ecpglib/connect.c(168):   if (con-autocommit ==
 true  strncmp(mode, off, strlen(off)) == 0)
 src/interfaces/ecpg/preproc/ecpg.addons(356): if (compat ==
 ECPG_COMPAT_INFORMIX_SE  autocommit == true)
 src/interfaces/ecpg/preproc/ecpg.c(310):  
 ptr2ext[3] = (header_mode
 == true) ? 'h' : 'c';
 src/interfaces/ecpg/preproc/ecpg.c(327):  
 ptr2ext[1] = (header_mode
 == true) ? 'h' : 'c';

I actually see no reason why these variables are not defined as bool instead of
int, so I changed this. Hopefully I found all of them.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers