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 700548 - ABI=x32 - gnome-desktop-thumbnail.c:1430:3: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'time_t' [-Werror=format=]
ABI=x32 - gnome-desktop-thumbnail.c:1430:3: error: format '%ld' expects argum...
Status: RESOLVED FIXED
Product: gnome-desktop
Classification: Core
Component: Thumbnail
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: Desktop Maintainers
Desktop Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-05-17 19:07 UTC by Alphat-PC
Modified: 2013-05-23 16:15 UTC
See Also:
GNOME target: ---
GNOME version: 3.7/3.8


Attachments
gnome-desktop-3.8.2-build.log (18.89 KB, text/plain)
2013-05-17 19:07 UTC, Alphat-PC
  Details
thumbnail: Fix compile-time warnings on x32 (2.51 KB, patch)
2013-05-23 15:06 UTC, Bastien Nocera
reviewed Details | Review
thumbnailer: Fix compile-time warning on x32 (1.38 KB, patch)
2013-05-23 15:46 UTC, Bastien Nocera
none Details | Review
thumbnailer: Fix compile-time warning on x32 (1.37 KB, patch)
2013-05-23 15:47 UTC, Bastien Nocera
committed Details | Review

Description Alphat-PC 2013-05-17 19:07:12 UTC
Created attachment 244572 [details]
gnome-desktop-3.8.2-build.log

libtool: compile:  x86_64-pc-linux-gnux32-gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I./libgsystem -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/libx32/glib-2.0/include -I/usr/include/gsettings-desktop-schemas -DG_LOG_DOMAIN=\"GnomeDesktop\" -DGNOMELOCALEDIR=\"/usr/share/locale\" -DISO_CODES_PREFIX=\"/usr\" -DLIBLOCALEDIR=\"/usr/lib/locale\" -DPNP_IDS=\"/usr/share/libgnome-desktop-3.0/pnp.ids\" -DXKB_BASE=\"/usr/share/X11/xkb\" -Wall -Wstrict-prototypes -Wnested-externs -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=pointer-arith -Werror=init-self -Werror=format-security -Werror=format=2 -Werror=missing-include-dirs -Wall -Wextra -ggdb -march=native -pipe -O3 -fno-tree-vectorize -frecord-gcc-switches -c gnome-desktop-thumbnail.c  -fPIC -DPIC -o .libs/gnome-desktop-thumbnail.o
...
...
gnome-desktop-thumbnail.c: In function 'gnome_desktop_thumbnail_factory_save_thumbnail':
gnome-desktop-thumbnail.c:1430:3: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'time_t' [-Werror=format=]
   g_snprintf (mtime_str, 21, "%ld",  original_mtime);
   ^
gnome-desktop-thumbnail.c: In function 'gnome_desktop_thumbnail_factory_create_failed_thumbnail':
gnome-desktop-thumbnail.c:1536:3: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'time_t' [-Werror=format=]
   g_snprintf (mtime_str, 21, "%ld",  mtime);
   ^
cc1: some warnings being treated as errors
make[2]: *** [gnome-desktop-thumbnail.lo] Error 1
Comment 1 Bastien Nocera 2013-05-21 06:56:38 UTC
time_t is a signed long on x86-64 and x32 (from a cursory glance at /usr/include/bits/typesizes.h [1]).
Why is it warning exactly?

[1]:
#define __TIME_T_TYPE           __SYSCALL_SLONG_TYPE
and
/* X32 kernel interface is 64-bit.  */
#if defined __x86_64__ && defined __ILP32__
# define __SYSCALL_SLONG_TYPE   __SQUAD_TYPE
Comment 2 Alphat-PC 2013-05-22 16:15:30 UTC
/usr/include/bits/typesizes.h:
...
29 /* X32 kernel interface is 64-bit.  */
30 #if defined __x86_64__ && defined __ILP32__
31 # define __SYSCALL_SLONG_TYPE   __SQUAD_TYPE
32 # define __SYSCALL_ULONG_TYPE   __UQUAD_TYPE
33 #else
34 # define __SYSCALL_SLONG_TYPE   __SLONGWORD_TYPE
35 # define __SYSCALL_ULONG_TYPE   __ULONGWORD_TYPE
36 #endif
...


x86:
sizeof(time_t) = sizeof(signed long int) = 4

amd64:
sizeof(time_t) = sizeof(signed long int) = 8

x32:
sizeof(time_t) = sizeof(signed long long int) = 8
Comment 3 Bastien Nocera 2013-05-23 15:06:12 UTC
Created attachment 245143 [details] [review]
thumbnail: Fix compile-time warnings on x32

Instead of trying to guess what the print format is for time_t,
use strftime to convert time_t to strings.
Comment 4 Colin Walters 2013-05-23 15:22:53 UTC
Review of attachment 245143 [details] [review]:

::: libgnome-desktop/gnome-desktop-thumbnail.c
@@ +108,3 @@
+
+	tmp = localtime (&time);
+	strftime (mtime_str, MTIME_STR_LEN, "%s", tmp);

Hm, strftime() uses the locale format.  That's unlikely to matter in general, but theoretically you could get e.g. Arabic numerals I think.

@@ +1440,3 @@
   close (tmp_fd);
+
+  time_t_to_str (original_mtime, mtime_str);

Personally I think it'd be easiest to just do:

g_snprintf (mtime_str, 21, "%" G_GUINT64_FORMAT, (guint64) original_mtime);
Comment 5 Bastien Nocera 2013-05-23 15:27:47 UTC
(In reply to comment #4)
<snip>
> g_snprintf (mtime_str, 21, "%" G_GUINT64_FORMAT, (guint64) original_mtime);

Probably, yeah.
Comment 6 Bastien Nocera 2013-05-23 15:46:32 UTC
Created attachment 245152 [details] [review]
thumbnailer: Fix compile-time warning on x32
Comment 7 Bastien Nocera 2013-05-23 15:47:10 UTC
Created attachment 245153 [details] [review]
thumbnailer: Fix compile-time warning on x32
Comment 8 Colin Walters 2013-05-23 16:10:08 UTC
Review of attachment 245153 [details] [review]:

Looks good.a
Comment 9 Bastien Nocera 2013-05-23 16:14:59 UTC
Attachment 245153 [details] pushed as a78ba21 - thumbnailer: Fix compile-time warning on x32