Xymon Mailing List Archive search

Ton of "differ in signedness" warnings?

4 messages in this thread

list Cade Robinson · Wed, 17 Feb 2010 11:02:48 -0600 ·
When I compile I get a TON of "differ in signedness" warnings.
Everything compiles but I am wondering about the warnings.

Looking up the error it looks like "just ignore them" is the answer but
should I?

Why is there something like this:

unsigned char *message;

or 
static unsigned char *cause = NULL;

I am guessing these are strings - so why the unsigned?
list Rich Smrcina · Wed, 17 Feb 2010 11:30:49 -0600 ·
quoted from Cade Robinson
On 02/17/2010 11:02 AM, Cade Robinson wrote:
When I compile I get a TON of "differ in signedness" warnings.
Everything compiles but I am wondering about the warnings.

Looking up the error it looks like "just ignore them" is the answer 
but should I?

Why is there something like this:

unsigned char *message;

or
static unsigned char *cause = NULL;

I am guessing these are strings - so why the unsigned?

They look more ominous than they are.  We tend to ignore them.

-- 
Rich Smrcina
Phone: XXX-XXX-XXXX
http://www.linkedin.com/in/richsmrcina

Catch the WAVV! http://www.wavv.org
WAVV 2010 - Apr 9-13, 2010 Covington, KY
list Malcolm Hunter · Wed, 17 Feb 2010 18:45:39 +0100 ·
quoted from Rich Smrcina
Why is there something like this:

unsigned char *message;

or 
static unsigned char *cause = NULL;

I am guessing these are strings - so why the unsigned?
This thread may help explain:

http://bytes.com/topic/c/answers/61480-why-use-unsigned-char-ever

Malcolm


-- 
Technical copy-editor & proofreader

KDE Proofreading Team
KDE British English Translation Team

http://l10n.kde.org/team-infos.php?teamcode=en_GB

Facebook: http://www.facebook.com/FriendlyAtheist

NEU: Mit GMX DSL über 1000,- ¿ sparen!
http://portal.gmx.net/de/go/dsl02
list TJ Yang · Thu, 4 Mar 2010 10:07:39 -0600 ·
I really  don't like to  ignore the warning message from compiler.
so I am spending some effort (R2) on subject of gcc compilation warning message.
Hope to get rid all of them.

Fist challenge is "unsigned char" usage,

The question is  why Henrik decided to use "unsigned char" on
strings,array in hobbit source code ?
According  R1 book,

unsigned character is 1 byte long and value range to be 0 to 2^8 -1.
signed  character  is 1 byte long   and value range is  -2^7 to 2^7-1.

both signed and unsigned char are all 1 byte long, so saving space is
not a motive.

Is the intention of declaring unsigned char is to disallow minus
value(non-ASCII) in a character ?


R1: C a software engineering approach by Peter A. Darneil.
R2: http://en.wikibooks.org/wiki/System_Monitoring_with_Xymon/Developer_Guide#Compilation_Errors_and_Warning
R3: following two example diffs are illustration of places in src
using unsigned char.
<snip>
Index: client/clientupdate.c
===================================================================
--- client/clientupdate.c       (revision 6219)
+++ client/clientupdate.c       (working copy)
@@ -96,7 +96,7 @@
                        char tmpfn[PATH_MAX];
                        char *srcfn;
                        FILE *tmpfd, *srcfd;
-                       unsigned char buf[8192];
+                       char buf[8192];
                        long n;
                        struct stat st;
                        int cperr;
Index: client/logfetch.c
===================================================================
--- client/logfetch.c   (revision 6219)
+++ client/logfetch.c   (working copy)
@@ -431,7 +431,7 @@
        static char *result = NULL;
        digestctx_t *ctx;
        FILE *fd;
-       unsigned char buf[8192];
+       char buf[8192];
        int openerr, buflen;

         if ((ctx = digest_init(dtype)) == NULL) return "";
[tjyang at f12 4.3.0]$


On Wed, Feb 17, 2010 at 11:45 AM, Malcolm Hunter
quoted from Malcolm Hunter
<user-b3e590ffeb6d@xymon.invalid> wrote:
Why is there something like this:

unsigned char *message;

or
static unsigned char *cause = NULL;

I am guessing these are strings - so why the unsigned?
This thread may help explain:

http://bytes.com/topic/c/answers/61480-why-use-unsigned-char-ever

Malcolm


--
Technical copy-editor & proofreader

KDE Proofreading Team
KDE British English Translation Team

http://l10n.kde.org/team-infos.php?teamcode=en_GB

Facebook: http://www.facebook.com/FriendlyAtheist

NEU: Mit GMX DSL über 1000,- ¿ sparen!
http://portal.gmx.net/de/go/dsl02

-- 

T.J. Yang