[Bug 268771] graphics/sane-backends: fix build with clang 15

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 05 Jan 2023 17:50:32 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268771

            Bug ID: 268771
           Summary: graphics/sane-backends: fix build with clang 15
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: dim@FreeBSD.org
                CC: vvd@unislabs.com
             Flags: maintainer-feedback?(vvd@unislabs.com)
                CC: vvd@unislabs.com

During an exp-run for llvm 15 (see bug 265425), it turned out that
graphics/sane-backends failed to build with clang 15:

  jpegtopdf.c:204:5: error: incompatible pointer to integer conversion
assigning to 'long' from 'char *(int, int)' [-Wint-conversion]
          tz = timezone;
             ^ ~~~~~~~~
  scanimage.c:1248:42: warning: call to undeclared function 'basename'; ISO C99
and later do not support implicit function declarations
[-Wimplicit-function-declaration]
                png_set_iCCP(*png_ptr, *info_ptr, basename(icc_profile),
PNG_COMPRESSION_TYPE_BASE, icc_buffer, icc_size);
                                                  ^
  scanimage.c:1248:42: error: incompatible integer to pointer conversion
passing 'int' to parameter of type 'png_const_charp' (aka 'const char *')
[-Wint-conversion]
                png_set_iCCP(*png_ptr, *info_ptr, basename(icc_profile),
PNG_COMPRESSION_TYPE_BASE, icc_buffer, icc_size);
                                                ^~~~~~~~~~~~~~~~~~~~~

The jpegtopdf error 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 also has its sign reversed from the glibc global.

The scanimage error is because basename(3) is used without including
<libgen.h>. With glibc, basename() is declared in both string.h and
libgen.h, where the former gives you the GNU specific variant, and the latter
the POSIX variant.

-- 
You are receiving this mail because:
You are the assignee for the bug.