[Patch] Fixing signed vs. unsigned char* warnings

Peter McCurdy petermccurdy at alumni.uwaterloo.ca
Mon Sep 1 23:53:51 PDT 2008


So since I was a bit bored this weekend, and since my previous "fix
the time_t warnings" patch seemed to go over OK, I followed through on
my threat to start fixing the signed vs. unsigned char* compiler
warnings in dbus.  I have a patch series that gets rid of all the
relevant warnings; it doesn't go all the way to making DBusRealString
store a signed char* or otherwise completely cleanse unsigned char*s
from DBus, but it's a start.  In particular, it's a start that works,
is reasonably sane, gets rid of the vast majority of all the dbus
compiler warnings, and passes "make check".

Do these patches look vaguely sensible to everyone else?  There's
remarkably few code changes, the bits that aren't just "s/unsigned
char/char/" are commented in the patch files, and are hopefully fairly
obvious.  Note that I stayed the hell out of dbus-sha.c's innards; it
can keep using unsigned chars internally until doomsday, as far as I'm
concerned.  Messing with working crypto code for the sake of code
purity isn't something I'm into.  I just made the minimal changes
required (i.e. casting) to get the compiler to shut up; if you want
any more than that, you'll have to find someone braver than I.

Anyway, if these patches don't have any obvious glaring problems with
them, I'll go put them in a bug for proper tracking, and, ideally,
inclusion.  If there are any comments, questions, or requests at all
about these, I'm all ears.  For the record, they're done against the
version in git trunk.

For fun, and out of morbid curiosity, I did have a quick try at
changing DBusRealString to store a signed char*.  Let's just say that
the results were a lot more exciting than these patches.  In
particular, I had to actually change more code than these patches, in
scarier ways, and then make check still failed.  It seemed halfway
feasible though, if there was a strong desire for the patch.  As it
stands though, these patches at least do a half-decent job of getting
the unsigned chars out of the way, and, more importantly, open up the
path to use -Werror to catch future bugs.

Thanks.

Peter.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-some-signedness-warnings-in-the-dbus-marshal-bas.patch
Type: text/x-diff
Size: 2183 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20080902/1dbb702d/attachment-0005.patch 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Replace-unsigned-char-s-with-signed-char-s-in-dbus-d.patch
Type: text/x-diff
Size: 14666 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20080902/1dbb702d/attachment-0006.patch 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Get-rid-of-unsigned-char-s-in-dbus-marshal-validate.patch
Type: text/x-diff
Size: 4994 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20080902/1dbb702d/attachment-0007.patch 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Fix-signed-vs-unsigned-char-warnings-in-dbus-sha.c.patch
Type: text/x-diff
Size: 1967 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20080902/1dbb702d/attachment-0008.patch 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Fix-signed-vs.-unsigned-char-warnings-in-dbus-strin.patch
Type: text/x-diff
Size: 1585 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20080902/1dbb702d/attachment-0009.patch 


More information about the dbus mailing list