checksum_impl.h fails cpluspluscheck

Started by Peter Eisentrautover 12 years ago3 messages
#1Peter Eisentraut
peter_e@gmx.net

./src/include/storage/checksum_impl.h: In function �uint32 pg_checksum_block(char*, uint32)�:
./src/include/storage/checksum_impl.h:154: warning: comparison between signed and unsigned integer expressions

We could exclude that file from the check, but it's also easy to fix by
making the variables unsigned:

diff --git a/src/include/storage/checksum_impl.h b/src/include/storage/checksum_impl.h
index ce1b124..7987b04 100644
--- a/src/include/storage/checksum_impl.h
+++ b/src/include/storage/checksum_impl.h
@@ -141,7 +141,7 @@ pg_checksum_block(char *data, uint32 size)
    uint32      sums[N_SUMS];
    uint32      (*dataArr)[N_SUMS] = (uint32 (*)[N_SUMS]) data;
    uint32      result = 0;
-   int         i,
+   unsigned int i,
                j;

/* ensure that the size is compatible with the algorithm */

Preferences?

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: checksum_impl.h fails cpluspluscheck

Peter Eisentraut <peter_e@gmx.net> writes:

./src/include/storage/checksum_impl.h: In function �uint32 pg_checksum_block(char*, uint32)�:
./src/include/storage/checksum_impl.h:154: warning: comparison between signed and unsigned integer expressions

We could exclude that file from the check, but it's also easy to fix by
making the variables unsigned:
...
Preferences?

Possibly use uint32 for consistency with the other vars in the function?
No real objection to unsigned int, though, since it's the same thing in
practice.

regards, tom lane

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

#3Peter Geoghegan
pg@heroku.com
In reply to: Peter Eisentraut (#1)
Re: checksum_impl.h fails cpluspluscheck

On Sat, Jun 29, 2013 at 8:55 PM, Peter Eisentraut <peter_e@gmx.net> wrote:

./src/include/storage/checksum_impl.h: In function ‘uint32 pg_checksum_block(char*, uint32)’:
./src/include/storage/checksum_impl.h:154: warning: comparison between signed and unsigned integer expressions

On the subject of checksum_impl.h, don't you think it's a bit
unfortunate that clients have to do this?:

+ // checksum_impl.h uses Assert, which doesn't work outside the server
+ #undef Assert
+ #define Assert(X)
+
+ #include "storage/checksum_impl.h"
+

Maybe external utilities ought to include another header that does all
of this for them?

--
Peter Geoghegan

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