GCC Compiler warnings with GnuPG 1.4.1

Christian Biere christianbiere at gmx.de
Thu Apr 7 19:23:59 CEST 2005


Hi,

I get the following compiler warnings (using -W -Wall -Wformat=2)
with GnuPG 1.4.1 (on NetBSD 2.99.11 FWIIW):

g10.c:2269: warning: subscript has type `char'
g10.c:3851: warning: subscript has type `char'
g10.c:3851: warning: subscript has type `char'
g10.c:3870: warning: subscript has type `char'
g10.c:3899: warning: subscript has type `char'
g10.c:3932: warning: subscript has type `char'
keyserver.c:267: warning: subscript has type `char'

The first and the last do not look completely harmless (i.e., could
cause a crash) at a glance. The others are just "noise" and we
had this topic before. In my humble opinion, the additional occurence
of the first and the last warning since 1.2.hitme shows that it's
a bad idea to keep this noise around. (Do you use GCC with the
above options at all?)

If you think that casting to unsigned char is evil, I suggest
adding a function for this very purpose:

unsigned char
char_to_uchar(char *c) {
	return (unsigned char) *c;
}

This way you don't loose any compiler warnings an evil cast would
hide.

-- 
Christian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : /pipermail/attachments/20050407/ea282020/attachment.pgp


More information about the Gnupg-devel mailing list