GNOME Bugzilla – Bug 660730
Use of "struct stat" breaks Windows
Last modified: 2011-10-12 03:30:04 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).
Review of attachment 198048 [details] [review]: Looks fine.
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!
Review of attachment 198048 [details] [review]: Committed in master, gtk-3-2 and gtk-3-0 on Kean's behalf.
(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...
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!