Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 869404 - sys-fs/lvm2-2.03.14-r3: fails to build with clang (lvmpolld-core.c:56:9: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'const char *')
Summary: sys-fs/lvm2-2.03.14-r3: fails to build with clang (lvmpolld-core.c:56:9: erro...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: PATCH
: 881659 (view as bug list)
Depends on:
Blocks: systemwide-clang c99-porting
  Show dependency tree
 
Reported: 2022-09-10 00:50 UTC by gresskar1
Modified: 2022-11-18 17:59 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info / emerge -pqv / build.log (17b46aac-a36e-4ec8-965d-15453e195f56.txt,204.96 KB, text/plain)
2022-09-10 00:50 UTC, gresskar1
Details
strerror_r-lvmpolld-core.patch (file_869404.txt,853 bytes, patch)
2022-11-18 02:32 UTC, Sam James
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description gresskar1 2022-09-10 00:50:09 UTC
Created attachment 804328 [details]
emerge --info / emerge -pqv / build.log

sys-fs/lvm2-2.03.14-r3: fails to build with clang:

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 */
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-09-10 00:52:46 UTC
In future, please attach the build.log as an attachment, and paste emerge --info in the first comment (or a separate attachment if you wish).
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-11-17 15:01:11 UTC
*** Bug 881659 has been marked as a duplicate of this bug. ***
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-11-18 02:23:37 UTC
It's assuming the GNU variant of strerror_r: https://www.openwall.com/lists/musl/2018/08/05/2.
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-11-18 02:31:22 UTC
I think they try to do the right thing but I'm not sure it works properly:
```
static const char *_strerror_r(int errnum, struct lvmpolld_thread_data *data)
{
#ifdef _GNU_SOURCE
        return strerror_r(errnum, data->buf, sizeof(data->buf)); /* never returns NULL */
#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
        return strerror_r(errnum, data->buf, sizeof(data->buf)) ? "" : data->buf;
#else
#       warning "Can't decide proper strerror_r implementation. lvmpolld will not issue specific system error messages"
        return "";
#endif
}
```

_GNU_SOURCE being set does not guarantee that libc provides the interface it wants. It does on glibc, but not on musl.

configure.ac actually has AC_FUNC_STRERROR_R which does what they want!

From the autoconf manual:
"""

— Macro: AC_FUNC_STRERROR_R

    If strerror_r is available, define HAVE_STRERROR_R, and if it is declared, define HAVE_DECL_STRERROR_R. If it returns a char * message, define STRERROR_R_CHAR_P; otherwise it returns an int error number. The Thread-Safe Functions option of Posix requires strerror_r to return int, but many systems (including, for example, version 2.2.4 of the GNU C Library) return a char * value that is not necessarily equal to the buffer argument.

    The result of this macro is cached in the ac_cv_func_strerror_r_char_p variable. 
"""
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-11-18 02:32:37 UTC
Created attachment 833269 [details, diff]
strerror_r-lvmpolld-core.patch
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-11-18 02:32:50 UTC
Can someone try the patch I've attached? Thanks.
Comment 7 Sheng Yu 2022-11-18 13:19:32 UTC
(In reply to Sam James from comment #5)
> Created attachment 833269 [details, diff] [details, diff]
> strerror_r-lvmpolld-core.patch

Tested, works for me.
Comment 8 Larry the Git Cow gentoo-dev 2022-11-18 17:59:19 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=39e348fad976c54d3980c2149de6365e8d035a4d

commit 39e348fad976c54d3980c2149de6365e8d035a4d
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-11-18 17:59:02 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-11-18 17:59:02 +0000

    sys-fs/lvm2: fix strerror_r check for musl
    
    Closes: https://bugs.gentoo.org/869404
    Signed-off-by: Sam James <sam@gentoo.org>

 .../lvm2/files/lvm2-2.03.16-musl-strerror_r.patch  | 23 ++++++++++++++++++++++
 sys-fs/lvm2/lvm2-2.03.16-r2.ebuild                 |  1 +
 2 files changed, 24 insertions(+)