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 760178 - Fix -Werror build for clang
Fix -Werror build for clang
Product: libgweather
Classification: Core
Component: general
Other FreeBSD
: Normal normal
: future
Assigned To: libgweather-maint
Depends on:
Reported: 2016-01-05 19:20 UTC by Ting-Wei Lan
Modified: 2016-02-15 20:25 UTC
See Also:
GNOME target: ---
GNOME version: ---

build: Fix -Werror build for clang (2.48 KB, patch)
2016-01-05 19:23 UTC, Ting-Wei Lan
none Details | Review

Description Ting-Wei Lan 2016-01-05 19:20:54 UTC
I know --disable-Werror, but I think these warnings are easy to fix.

The attached patch fixes warnings showed by clang:

gweather-timezone.c:61:27: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
parse_tzdata (const char *tzname, time_t start, time_t end,
/usr/include/time.h:140:14: note: previous declaration is here
extern char *tzname[];
gweather-timezone.c:87:33: error: cast from 'char *' to 'guint32 *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
    timecnt = GUINT32_FROM_BE (*(guint32 *)(contents + TZ_TIMECNT_OFFSET));
/home/lantw44/gnome/devinstall/include/glib-2.0/glib/gtypes.h:352:46: note: expanded from macro 'GUINT32_FROM_BE'
#define GUINT32_FROM_BE(val)    (GUINT32_TO_BE (val))
/home/lantw44/gnome/devinstall/lib/glib-2.0/include/glibconfig.h:156:49: note: expanded from macro 'GUINT32_TO_BE'
#define GUINT32_TO_BE(val)      (GUINT32_SWAP_LE_BE (val))
/home/lantw44/gnome/devinstall/include/glib-2.0/glib/gtypes.h:313:67: note: expanded from macro 'GUINT32_SWAP_LE_BE'
#      define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val))
/home/lantw44/gnome/devinstall/include/glib-2.0/glib/gtypes.h:292:37: note: expanded from macro 'GUINT32_SWAP_LE_BE_X86_64'
         ({ guint32 __v, __x = ((guint32) (val));               \
gweather-timezone.c:115:23: error: cast from 'char *' to 'gint32 *' (aka 'int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
    initial_offset = *(gint32 *)(ttinfos +
gweather-timezone.c:124:19: error: cast from 'char *' to 'gint32 *' (aka 'int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
        second_offset = *(gint32 *)(ttinfos +
4 errors generated.
Comment 1 Ting-Wei Lan 2016-01-05 19:23:21 UTC
Created attachment 318286 [details] [review]
build: Fix -Werror build for clang

The argument tzname is renamed to tz_name to prevent confusion with
the global variable.
Comment 2 Giovanni Campagna 2016-02-15 20:25:34 UTC
Thanks for the patch, I applied it and it will be in the next release.