After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 788312 - Compiler warnings concerning signed and unsigned variables
Compiler warnings concerning signed and unsigned variables
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.9.4
Other Windows
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
: 680370 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2017-09-28 20:52 UTC by jpmugaas
Modified: 2019-01-30 11:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for 2.9.5 (13.01 KB, patch)
2017-09-28 20:52 UTC, jpmugaas
none Details | Review
Revised patch to address some comments made (12.72 KB, patch)
2017-09-30 17:08 UTC, jpmugaas
none Details | Review

Description jpmugaas 2017-09-28 20:52:37 UTC
Created attachment 360637 [details] [review]
Patch for 2.9.5

WHen compiling libxml2 - 2.9.5, I got some compiler warnings concerning signed and unsigned variables as well as warning having to do with typecasts involving "long".  The problem is that in Windows, long does does grow to 64-bits like it would in Linux.  A fix would be to change the typecasts to intptr_t in stdint.

I also tried to fix some some comparisons where signed values were compared with unsigned comparisons.  There might also some issues with format and some parameter types also looked at.

I did make a patch to try address some of this.  There also seems to be issues with fallthrough in case statements that I have not fixed.

Please review what I ahve in the patch.
Comment 1 Nick Wellnhofer 2017-09-30 14:33:09 UTC
libxml2 must support pre-C99 compilers without stdint.h, so we can't use intptr_t.
Comment 2 jpmugaas 2017-09-30 15:04:28 UTC
I wonder if you can use the autoconf macro — Macro: AC_TYPE_INTPTR_T

From: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Particular-Types.html

— Macro: AC_TYPE_INTPTR_T
If stdint.h or inttypes.h defines the type intptr_t, define HAVE_INTPTR_T. Otherwise, define intptr_t to a signed integer type wide enough to hold a pointer, if such a type exists.

There are some other macros that might also help such as AC_TYPE_UINTPTR_T.  The thing is that GCC 7.2.0 and 6.4.0 give warnings about using the long type in Windows for typecasting in Win64 for good reason.  The "long" type DOES not grow to 64-bits in Windows.

I did the issue with libxslt as well.
https://bugzilla.gnome.org/show_bug.cgi?id=788317
Comment 3 Nick Wellnhofer 2017-09-30 15:25:07 UTC
The build system for MSVC in win32 doesn't use autoconf, making this complicated. To fix the int-to-pointer casts, I'd suggest to use C89's ptrdiff_t instead of long. It's not guaranteed to be the size of a pointer but I'm not aware of a platform where it isn't.

xmlMemFree should simply print the pointer directly with the %p specifier.
Comment 4 jpmugaas 2017-09-30 17:08:02 UTC
Created attachment 360703 [details] [review]
Revised patch to address some comments made
Comment 5 Nick Wellnhofer 2017-10-09 15:12:32 UTC
I just landed a big set of commits that address various Windows issues. This should make many of the MinGW patches obsolete:

https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-libxml2

If there are any remaining issues, get in touch with me.
Comment 6 Nick Wellnhofer 2019-01-30 11:07:53 UTC
*** Bug 680370 has been marked as a duplicate of this bug. ***