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 711547 - win32: silence some build warnings
win32: silence some build warnings
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-11-06 13:15 UTC by Marc-Andre Lureau
Modified: 2018-05-24 15:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
win32: silence deprecation warning (1.97 KB, patch)
2013-11-06 13:15 UTC, Marc-Andre Lureau
none Details | Review
win32: silence a mingw warning (1.18 KB, patch)
2013-11-06 13:15 UTC, Marc-Andre Lureau
reviewed Details | Review
win32: silence build warning (2.37 KB, patch)
2013-11-06 13:15 UTC, Marc-Andre Lureau
committed Details | Review
win32: silence build warning (1.27 KB, patch)
2013-11-06 13:15 UTC, Marc-Andre Lureau
committed Details | Review
win32: silence build warning (1.16 KB, patch)
2013-11-06 13:15 UTC, Marc-Andre Lureau
committed Details | Review
Expand forced 32-bit GStatBuf definition to mingw-w64 (875 bytes, patch)
2014-03-02 18:41 UTC, LRN
reviewed Details | Review
Use 64-bit stat function for GLocalFile size calculation, not g_l?stat (1.92 KB, patch)
2014-03-02 19:00 UTC, LRN
none Details | Review
Fix warnings (uninitialized variables), unused variable (2.00 KB, patch)
2014-03-02 19:04 UTC, LRN
none Details | Review
Silence some uncontroversial warnings (1.54 KB, patch)
2014-08-02 12:37 UTC, LRN
committed Details | Review
Silence a controversial warning in win_iconv (877 bytes, patch)
2014-08-02 12:38 UTC, LRN
committed Details | Review
Fix the thumbnail verification test on Windows (1.02 KB, patch)
2015-04-22 08:59 UTC, Fan, Chun-wei
committed Details | Review

Description Marc-Andre Lureau 2013-11-06 13:15:37 UTC
ssia
Comment 1 Marc-Andre Lureau 2013-11-06 13:15:40 UTC
Created attachment 259071 [details] [review]
win32: silence deprecation warning

gwin32.c: In function 'g_win32_get_package_installation_subdirectory':
gwin32.c:486:3: warning: 'g_win32_get_package_installation_directory' is deprecated (declared at gwin32.c:402) [-Wdeprecated-declarations]
   prefix = g_win32_get_package_installation_directory (package, dll_name);
Comment 2 Marc-Andre Lureau 2013-11-06 13:15:45 UTC
Created attachment 259072 [details] [review]
win32: silence a mingw warning

gstdio.c: In function 'g_stat':
gstdio.c:496:3: warning: passing argument 2 of '_wstat' from
incompatible pointer type [enabled by default]
   retval = _wstat (wfilename, buf);
   ^
In file included from gstdio.c:27:0:
/usr/i686-w64-mingw32/sys-root/mingw/include/sys/stat.h:126:66: note:
expected 'struct _stat *' but argument is of type 'struct GStatBuf *'
   _CRTIMP int __cdecl _wstat32(const wchar_t *_Name,struct
   _stat32 *_Stat);
Comment 3 Marc-Andre Lureau 2013-11-06 13:15:49 UTC
Created attachment 259073 [details] [review]
win32: silence build warning

glocalfileinfo.c: In function '_g_local_file_info_get':
glocalfileinfo.c:1955:11: warning: passing argument 3 of
'get_thumbnail_attributes' from incompatible pointer type [enabled by
default]
           get_thumbnail_attributes (path, info, &statbuf);
           ^
glocalfileinfo.c:1285:1: note: expected 'const struct GStatBuf *' but
argument is of type 'struct _stati64 *'
 get_thumbnail_attributes (const char     *path,
Comment 4 Marc-Andre Lureau 2013-11-06 13:15:53 UTC
Created attachment 259074 [details] [review]
win32: silence build warning

gdbusauthmechanismexternal.c: In function 'mechanism_client_initiate':
gdbusauthmechanismexternal.c:355:3: warning: 'initial_response' may be
used uninitialized in this function [-Wmaybe-uninitialized]
   return initial_response;
   ^
gdbusauthmechanismexternal.c:332:10: note: 'initial_response' was
declared here
Comment 5 Marc-Andre Lureau 2013-11-06 13:15:57 UTC
Created attachment 259075 [details] [review]
win32: silence build warning

glocalfile.c: In function 'g_local_file_measure_size_of_file':
glocalfile.c:2654:3: warning: passing argument 2 of 'g_lstat' from
incompatible pointer type [enabled by default]
   if (g_lstat (name->data, &buf) != 0)
   ^
In file included from glocalfile.c:68:0:
../glib/gstdio.h:135:5: note: expected 'struct GStatBuf *' but argument
is of type 'struct _stati64 *'
Comment 6 Dan Winship 2013-11-06 17:28:34 UTC
Comment on attachment 259071 [details] [review]
win32: silence deprecation warning

>-  prefix = g_win32_get_package_installation_directory (package, dll_name);
>+  prefix = _g_win32_get_package_installation_directory (package, dll_name);

an easier fix is:

 +  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
    prefix = g_win32_get_package_installation_directory (package, dll_name);
 +  G_GNUC_END_IGNORE_DEPRECATIONS
Comment 7 Dan Winship 2013-11-06 17:30:05 UTC
Comment on attachment 259073 [details] [review]
win32: silence build warning

seems right
Comment 8 Dan Winship 2013-11-06 17:31:06 UTC
Comment on attachment 259075 [details] [review]
win32: silence build warning

>-  struct stat buf;
>+  GStatBuf buf;

not GLocalFileStat?
Comment 9 Dan Winship 2013-11-06 17:31:34 UTC
Comment on attachment 259072 [details] [review]
win32: silence a mingw warning

(I have no clue on this one...)
Comment 10 LRN 2014-01-23 15:58:33 UTC
This may be related to https://bugzilla.gnome.org/show_bug.cgi?id=669818

Anyway, the stat warning is more than just a warning.
What some people don't quite get is that mingw-w64 supports LFS, and supported it for some time (a couple of years, roughly).
LFS is controlled by an intricate set of macros, and there's a blog post[1] i did to explore and systematize this, but in a nutshell: normal autotooled software packages will end up using LFS, with "struct stat" having 64-bit st_size field, regardless of OS bitness, while time fields (an issue orthogonal to LFS) will be 32-bit on 32-bit OS and 64-bit on 64-bit OS.

gstdio.h, as of March 2010, typedefs GStatBuf as "struct stat" instead of "struct _stat". Which means that GStatBuf will have LFS, if configure is used (I.e. glib is built in MSYS, or cross-compiled from GNU/Linux or Cygwin). "struct _stat" would not have had this problem, as it has 32-bit st_size field, always.

Therefore, i think that the patch for gstdio.h (which adds mingw to the group of platforms for which struct _stat32 is used instead of struct stat) is correct.

[1] https://gnunet.org/content/sorting-out-stat-thing
Comment 11 LRN 2014-03-02 18:35:06 UTC
OK, the patch can be improved slightly by swapping __MINGW32__ for __MINGW64_VERSION_MAJOR (because there's no "_stat32" in mingw.org as far as i can see).
Comment 12 LRN 2014-03-02 18:41:12 UTC
Created attachment 270707 [details] [review]
Expand forced 32-bit GStatBuf definition to mingw-w64
Comment 13 LRN 2014-03-02 19:00:59 UTC
Created attachment 270710 [details] [review]
Use 64-bit stat function for GLocalFile size calculation, not g_l?stat

g_stat() is 32-bit only (see the other patch), whereas GLocalFileStat is
always 64-bit. g_lstat() just calls g_stat() on W32, so that's not an option.
Comment 14 LRN 2014-03-02 19:04:22 UTC
Created attachment 270711 [details] [review]
Fix warnings (uninitialized variables), unused variable

Since this bug is about silencing warnings, here's a patch that silences
various warnings:

* struct in_addr ip4addr; is unused on W32 (inet_aton() is not called)
* poll_timer is not initialized (gcc is not smart enough to understand that
  all branches where poll_timer are used also have it initialized)
* hmodule is not initialized (same as poll_timer)
* wc is not initialized (initialize it to something that fails)
Comment 15 Fan, Chun-wei 2014-05-12 09:25:18 UTC
Review of attachment 259073 [details] [review]:

Hi,

Unfortunately this breaks the thumbnail-verification test on Windows... When I reverted this patch, the test runs successfully (albeit with a C4133 warning when building GIO, which I think should be like the warning that Marc-Andre is getting)
Comment 16 Paolo Borelli 2014-08-02 09:22:46 UTC
Review of attachment 270711 [details] [review]:

The pacthes for gresolver, gmain and gutils are obvious and should be pushed right away.

The one for win_iconv looks ok to me, but I am not familiar enough with that code to say if I am missing something
Comment 17 LRN 2014-08-02 11:19:28 UTC
(In reply to comment #16)
> Review of attachment 270711 [details] [review]:
> 
> The pacthes for gresolver, gmain and gutils are obvious and should be pushed
> right away.
> 
> The one for win_iconv looks ok to me, but I am not familiar enough with that
> code to say if I am missing something

AFAIU, utf32_mbtowc() converts a multibyte character (stored in buf, up to 4 bytes long) to a wide character.
It knows two codepage groups - 12000 and 12001, with different endianness. If codepage group is 12000, it forms an UCS4 char in LE. If codepage group is 12001, it forms the UCS4 char in BE.
It then checks that the UCS4 char is in legal range, then calls ucs4_to_utf16() on it.

The problem is that there are other codepage groups beside 12000 and 12001.
Now, i haven't checked the code thoroughly, but it appears that glib *first* checks the codepage, then assigns one of the conversion functions (such as utf32_mbtowc) to a placeholder variable, which later is called. So it seems that it's guaranteed that utf32_mbtowc() will only be called for codepage groups 12000 and 12001 (but gcc doesn't get it, sadly).

Thus initializing uint wc to 0xD800 just placates gcc, wc never actually gets used without being set. If your conscience is still troubled, it should be possible to add an assert that crashes if cv->codepage is not 12000 or 12001.
Comment 18 Paolo Borelli 2014-08-02 12:30:12 UTC
I think the explanation makes sense. I'd still prefer the two patches to be pushed separately so that the one that's more controversial is easier to bisect if that's ever needed. Anyway go ahead.
Comment 19 LRN 2014-08-02 12:37:36 UTC
Created attachment 282329 [details] [review]
Silence some uncontroversial warnings
Comment 20 LRN 2014-08-02 12:38:14 UTC
Created attachment 282330 [details] [review]
Silence a controversial warning in win_iconv
Comment 21 LRN 2014-08-02 12:39:56 UTC
Attachment 282329 [details] pushed as 42ddcc6 - Silence some uncontroversial warnings
Attachment 282330 [details] pushed as 7e0cb48 - Silence a controversial warning in win_iconv
Comment 22 LRN 2015-04-19 01:49:56 UTC
Comment on attachment 270710 [details] [review]
Use 64-bit stat function for GLocalFile size calculation, not g_l?stat

Obsoleting this attachment (committed, but in another bug).
Comment 23 Fan, Chun-wei 2015-04-22 08:59:25 UTC
Created attachment 302130 [details] [review]
Fix the thumbnail verification test on Windows

Hi,

For me, first I would like to make sure things are also functional with Visual Studio builds after items in this patch :).

(In reply to Fan, Chun-wei from comment #15)
> Review of attachment 259073 [details] [review] [review]:
> 
> Hi,
> 
> Unfortunately this breaks the thumbnail-verification test on Windows... When
> I reverted this patch, the test runs successfully (albeit with a C4133
> warning when building GIO, which I think should be like the warning that
> Marc-Andre is getting)

Probably the above item didn't reach people, but I think I have a fix for it, for the test itself...

Make sure that the types in the test are in-line with the updates we have in attachment 259073 [details] [review].

With blessings, thank you!
Comment 24 Fan, Chun-wei 2015-04-22 09:15:13 UTC
Review of attachment 270707 [details] [review]:

Hi,

I would definitely not be the best person to say whether this or attachment 259072 [details] [review] is better, as probably people know that I am more Visual Studio-centered.

As with attachment 259072 [details] [review], I guess this narrows down to the MinGW situation, which AFAICT is not in a very uniform situation (and is in a situation that I am not familiar with, due to the existence of original mingw.org and mingw-w64, which actually complicated things for the right (or better) check macro.  I think the best way to go with this is to see whether there are still many people trying to build with mingw.org, and go with the macro that most GCC-Windows (be it mingw.org or mingw-w64) will use, and possibly let people know in some sort of README.win32 (or so), that if they choose to go with the GCC route, they are recommended (or down the road, required, even) to use that flavour of GCC-Windows.

My take on this.

With blessings, thank you!
Comment 25 Fan, Chun-wei 2015-04-22 09:16:03 UTC
Review of attachment 259072 [details] [review]:

(Please see my review of 270707 about my take on this).
Comment 26 LRN 2015-04-22 09:54:23 UTC
(In reply to Fan, Chun-wei from comment #24)
> Review of attachment 270707 [details] [review] [review]:
> 
> Hi,
> 
> I would definitely not be the best person to say whether this or attachment
> 259072 [details] [review] is better, as probably people know that I am more
> Visual Studio-centered.
> 
> As with attachment 259072 [details] [review] [review], I guess this narrows down to
> the MinGW situation, which AFAICT is not in a very uniform situation (and is
> in a situation that I am not familiar with, due to the existence of original
> mingw.org and mingw-w64, which actually complicated things for the right (or
> better) check macro.  I think the best way to go with this is to see whether
> there are still many people trying to build with mingw.org, and go with the
> macro that most GCC-Windows (be it mingw.org or mingw-w64) will use, and
> possibly let people know in some sort of README.win32 (or so), that if they
> choose to go with the GCC route, they are recommended (or down the road,
> required, even) to use that flavour of GCC-Windows.

AFAIU, this actually is not about choosing the right macro to identify MinGW. This is about choosing the right macro to identify mingw-w64, because this condition must not come true for mingw.org, because there's no "_stat32" in mingw.org as far as i can see. I don't have a functioning mingw.org installation to test this though. Anyway, if my understanding is correct and mingw.org has no _stat32, then using __MINGW64_VERSION_MAJOR is the right thing to do. If mingw.org has _stat32, then __MINGW32__ is the macro to use. All boils down to this.
Comment 27 LRN 2015-04-22 09:56:38 UTC
Review of attachment 302130 [details] [review]:

This, obviously, is correct.
Comment 28 Fan, Chun-wei 2015-04-22 11:03:54 UTC
Review of attachment 302130 [details] [review]:

Hello LRN,

Thanks for checking out the patch, the patch was pushed as 10b5a8be (master) and 5afaa31 (glib-2-44).

(In reply to LRN from comment #26)
> AFAIU, this actually is not about choosing the right macro to identify
> MinGW. This is about choosing the right macro to identify mingw-w64, because
> this condition must not come true for mingw.org, because there's no
> "_stat32" in mingw.org as far as i can see. I don't have a functioning
> mingw.org installation to test this though. Anyway, if my understanding is
> correct and mingw.org has no _stat32, then using __MINGW64_VERSION_MAJOR is
> the right thing to do. If mingw.org has _stat32, then __MINGW32__ is the
> macro to use. All boils down to this.

Yup, this is what I am getting at in comments 24/25.  Thanks for making the issue more clear to people.

With blessings, thank you!
Comment 29 GNOME Infrastructure Team 2018-05-24 15:50:18 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/777.