mate-desktop / mate-panel

MATE panel
https://mate-desktop.org
GNU General Public License v2.0
185 stars 118 forks source link

build failure on FreeBSD with Clang 15 - incompatible pointer to integer conversion on global `timezone` #1350

Open emaste opened 1 year ago

emaste commented 1 year ago

Expected behaviour

mate-panel builds successfully

Actual behaviour

  clock-location.c:454:22: error: incompatible pointer to integer conversion assigning to 'glong' (aka 'long') from 'char *(int, int)' [-Wint-conversion]
          sys_timezone = timezone;
                       ^ ~~~~~~~~
  clock-location.c:462:24: error: incompatible pointer to integer conversion assigning to 'glong' (aka 'long') from 'char *(int, int)' [-Wint-conversion]
          local_timezone = timezone;
                         ^ ~~~~~~~~

From the FreeBSD bug report:

This is because 'timezone' as a global external variable does not exist on FreeBSD: it is a glibc-ism. Use struct tm's tm_gmtoff field instead, which has its sign reversed from the glibc global. There is also no need to manually account for DST, as tm_gmtoff includes that.

Steps to reproduce the behaviour

Build mate-panel on FreeBSD with Clang 15 as the system compiler.

MATE general version

1.26.0

Package version

1.26.0

Distribution

FreeBSD

Link to bugreport of your Distribution (requirement)

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268795 (includes patch)

DimitryAndric commented 1 year ago

Note that the FreeBSD-specific fix uses #ifdef __FreeBSD__ to go into the code path that uses struct tm's tm_gmtoff field, but I think this might even be applicable to anything that isn't glibc. E.g., musl (on Linux) does not have a global timezone variable either.

Note also that recent versions of glibc seem to have added a tm_gmtoff field too, so maybe the whole messing with #ifdef is not really necessary anymore. I don't know when glibc introduced it, though.