GNOME Bugzilla – 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=]
Last modified: 2013-05-23 16:15:06 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
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
/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
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.
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);
(In reply to comment #4) <snip> > g_snprintf (mtime_str, 21, "%" G_GUINT64_FORMAT, (guint64) original_mtime); Probably, yeah.
Created attachment 245152 [details] [review] thumbnailer: Fix compile-time warning on x32
Created attachment 245153 [details] [review] thumbnailer: Fix compile-time warning on x32
Review of attachment 245153 [details] [review]: Looks good.a
Attachment 245153 [details] pushed as a78ba21 - thumbnailer: Fix compile-time warning on x32