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 660730 - Use of "struct stat" breaks Windows
Use of "struct stat" breaks Windows
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.2.x
Other Windows
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-10-03 00:36 UTC by Kean Johnston
Modified: 2011-10-12 03:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Change struct stat to use GStatBuf for portability (3.16 KB, patch)
2011-10-03 00:36 UTC, Kean Johnston
committed Details | Review

Description Kean Johnston 2011-10-03 00:36:20 UTC
Created attachment 198048 [details] [review]
Change struct stat to use GStatBuf for portability

There are a few places in GTK that use "struct stat" and then g_stat(), rather than using GStatBuf. This breaks things on Windows. Since the size of struct stat can vary depending on other flags specified, this has the potential to cause overwrites and is trivial to fix. Patch attached. The patch was generated against 3.2.0 but should apply to 3.0.x and 3.1.x too (if those versions are ever going to be revved).
Comment 1 Matthias Clasen 2011-10-03 11:56:10 UTC
Review of attachment 198048 [details] [review]:

Looks fine.
Comment 2 Fan, Chun-wei 2011-10-03 15:33:24 UTC
Hi Kean,

I have committed the patches for you in master, gtk-3-2 and gtk-3-0 as
eb8c2dfa, ff6983e4 and 7df27e2c respectively.  Thanks for these items.

If you don't mind, it would help (especially to keep your name on the commit)
if you could generate the patchset with git format-patch.

Thanks, and God bless!
Comment 3 Fan, Chun-wei 2011-10-03 15:34:03 UTC
Review of attachment 198048 [details] [review]:

Committed in master, gtk-3-2 and gtk-3-0 on Kean's behalf.
Comment 4 Dieter Verfaillie 2011-10-11 18:25:34 UTC
(In reply to comment #2)

> I have committed the patches for you in master, gtk-3-2 and gtk-3-0 as
> eb8c2dfa, ff6983e4 and 7df27e2c respectively.  Thanks for these items.

Those commits breaks the build with MinGW. Extract from build log for
the master branch:

make[4]: Leaving directory `/d/dev/gnome.org/gnome-windows/checkout/gtk+/git/build/modules/input'
  CCLD   libgtk-3.la
Creating library file: .libs/libgtk-3.dll.a.libs/libgtk_3_la-gtkiconcache.o: In function `gtk_icon_cache_new_for_path':
d:/dev/gnome.org/gnome-windows/checkout/gtk+/git/src/gtk/gtkiconcache.c:115: undefined reference to `_fstat32
'
collect2: ld returned 1 exit status
make[3]: *** [libgtk-3.la] Error 1


Relevant extract from /mingw/include/sys/stat.h:

#if __MSVCRT_VERSION__ >= 0x0800
_CRTIMP int __cdecl __MINGW_NOTHROW	_fstat32 (int, struct __stat32*);


MinGW by default defines __MSVCRT_VERSION__ to 0x0600 to be compatible
with older versions of msvcrt.dll...
Comment 5 Fan, Chun-wei 2011-10-12 03:30:04 UTC
Hi Dieter,

Thanks for the notes-the code is updated to redefine fstat as _fstat32 on
Windows only when Visual C++ 2005+ (_MSC_VER >= 1400) is used, or msvcrt80.dll
or later is used (__MSVCRT_VERSION__ >= 0x0800).  The code has been committed
to master, gtk-3-0 and gtk-3-2 as 5a13e08f, 4588df97 and a3344ef6 respectively.

Cheers, and God bless!