Bug 2142273

Summary: lvm2-2.03.14: daemons/lvmpolld/lvmpolld-core.c: strerror_r on musl libc always returns int
Product: [Community] LVM and device-mapper Reporter: v
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: polldaemon QA Contact: cluster-qe <cluster-qe>
Status: POST --- Docs Contact:
Severity: high    
Priority: unspecified CC: agk, heinzm, jbrassow, msnitzer, okozina, prajnoha, zkabelac
Version: unspecifiedFlags: pm-rhel: lvm-technical-solution?
pm-rhel: lvm-test-coverage?
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description v 2022-11-12 14:08:33 UTC
Description of problem:
On musl libc *strerror_r* defined to return int even with _GNU_SOURCE:
```
/* /usr/include/string.h */
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
 || defined(_BSD_SOURCE)
// ...
int strerror_r (int, char *, size_t);
// ...
```

this causes compilation error:
```
lvmpolld-core.c:56:9: error: incompatible integer to pointer conversion returning 'int' from a
      function with result type 'const char *' [-Wint-conversion]
        return strerror_r(errnum, data->buf, sizeof(data->buf)); /* never returns NULL */
```

Version-Release number of selected component (if applicable):
2.03.14

How reproducible:
Always

Steps to Reproduce:
Try to build on musl libc


Expected results:
Successful build

Comment 1 Zdenek Kabelac 2022-11-14 10:58:37 UTC
Hmmm - seems like testing condition for _GNU_SOURCE could be improved and checked better if the system actually provides symbol in right variant.

It's worth to note lvm2 project is only supported for  glibc  - that fact it mostly works with i.e. 'musl C library' is mostly due to support from users using it - i.e. we can apply patches - however we do not have any system with such library present.

Comment 2 Zdenek Kabelac 2022-11-30 15:49:24 UTC
Upstream patch: https://listman.redhat.com/archives/lvm-devel/2022-November/024479.html