Package: dcraw
Version: 9.28-5
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch

Hi Filip,

In Ubuntu, dcraw was failing to build because of a local implementation of
memmem() whose prototype conflicts with the glibc prototype:

[...]
gcc -DPACKAGE_NAME=\"dcraw\" -DPACKAGE_TARNAME=\"dcraw\" 
-DPACKAGE_VERSION=\"9.28\" -DPACKAGE_STRING=\"dcraw\ 9.28\" 
-DPACKAGE_BUGREPORT=\"hr...@physics.muni.cz\" -DPACKAGE_URL=\"\" 
-DPACKAGE=\"dcraw\" -DVERSION=\"9.28\" -DHAVE_LIBM=1 -DHAVE_STDIO_H=1 
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 
-DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 
-DSTDC_HEADERS=1 -DHAVE_JPEGLIB_H=1 -DHAVE_LIBJPEG=1 -DHAVE_LCMS2_H=1 
-DHAVE_LIBLCMS2=1 -I.   -Wdate-time -D_FORTIFY_SOURCE=3  -g -O2 
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer 
-ffile-prefix-map=/<<PKGBUILDDIR>>=. -flto=auto -ffat-lto-objects 
-fstack-protector-strong -fstack-clash-protection -Wformat 
-Werror=format-security -fcf-protection 
-fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/dcraw-9.28-5build1 -O4 -c -o 
parse.o parse.c
[...]
parse.c:1216:7: error: conflicting types for ‘memmem’; have ‘char *(char *, 
size_t,  char *, size_t)’ {aka ‘char *(char *, long unsigned int,  char *, long 
unsigned int)’}
 1216 | char *memmem (char *haystack, size_t haystacklen,
      |       ^~~~~~
In file included from parse.c:13:
/usr/include/string.h:389:14: note: previous declaration of ‘memmem’ with type 
‘void *(const void *, size_t,  const void *, size_t)’ {aka ‘void *(const void 
*, long unsigned int,  const void *, long unsigned int)’}
  389 | extern void *memmem (const void *__haystack, size_t __haystacklen,
      |              ^~~~~~
[...]

  (https://launchpad.net/ubuntu/+source/dcraw/9.28-5build1/+build/28000832)

This is not currently a build failure in Debian, but that is strictly a
question of compiler behavior, and this may start to FTBFS in Debian at some
later point.

And anyway, there's no reason to reimplement memmem() here, it's probably
less performant than the version provided by glibc.

We have applied the attached patch in Ubuntu to fix the build failure.  I
think it would be a good idea to apply it in Debian as well.

Thanks for considering,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
diff -Nru dcraw-9.28/debian/patches/remove-duplicate-memmem.patch 
dcraw-9.28/debian/patches/remove-duplicate-memmem.patch
--- dcraw-9.28/debian/patches/remove-duplicate-memmem.patch     1969-12-31 
16:00:00.000000000 -0800
+++ dcraw-9.28/debian/patches/remove-duplicate-memmem.patch     2024-04-09 
16:49:27.000000000 -0700
@@ -0,0 +1,28 @@
+Description: don't reimplement memmem()
+ memmem() is implemented in glibc, don't have a redundant duplicate
+ implementation with a different prototype.
+Author: Steve Langasek <steve.langa...@canonical.com>
+Last-Update: 2024-04-09
+Forwarded: no
+
+Index: dcraw-9.28/parse.c
+===================================================================
+--- dcraw-9.28.orig/parse.c
++++ dcraw-9.28/parse.c
+@@ -1213,16 +1213,6 @@
+   }
+ }
+ 
+-char *memmem (char *haystack, size_t haystacklen,
+-              char *needle, size_t needlelen)
+-{
+-  char *c;
+-  for (c = haystack; c <= haystack + haystacklen - needlelen; c++)
+-    if (!memcmp (c, needle, needlelen))
+-      return c;
+-  return NULL;
+-}
+-
+ /*
+    Identify which camera created this file, and set global variables
+    accordingly.        Return nonzero if the file cannot be decoded.
diff -Nru dcraw-9.28/debian/patches/series dcraw-9.28/debian/patches/series
--- dcraw-9.28/debian/patches/series    2024-03-26 02:42:04.000000000 -0700
+++ dcraw-9.28/debian/patches/series    2024-04-09 16:48:07.000000000 -0700
@@ -8,3 +8,4 @@
 iowrap.diff
 0009-missing_headers.patch
 0010-Fuji-headers.patch
+remove-duplicate-memmem.patch

Reply via email to