LLVM 15 on FreeBSD support for sane-backends 1.1.1
Details are here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268771
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);
^~~~~~~~~~~~~~~~~~~~~
/usr/local/include/png.h:2120:42: note: passing argument to parameter 'name' here
png_inforp info_ptr, png_const_charp name, int compression_type,
^
jpegtopdf.c:204:5: error: incompatible pointer to integer conversion assigning to 'long' from 'char *(int, int)' [-Wint-conversion]
tz = timezone;
^ ~~~~~~~~
1 error generated.
1 warning and 1 error generated.
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.
Patch:
--- frontend/jpegtopdf.c.orig
+++ frontend/jpegtopdf.c
@@ -201,7 +201,11 @@ static SANE_Int _get_current_time( struct tm *pt, SANE
goto EXIT;
}
/* get time difference ( OHH'mm' ) */
+#ifdef __FreeBSD__
+ tz = -pt->tm_gmtoff;
+#else
tz = timezone;
+#endif
if ( tz > 0 ) {
*sign_c = '-';
}
--- frontend/scanimage.c.orig
+++ frontend/scanimage.c
@@ -39,6 +39,9 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>