On Tue, Nov 25, 2025 at 04:05:06PM +0100, Ján Tomko wrote:
On a Tuesday in 2025, Michal Prívozník wrote:
On 11/25/25 15:10, Daniel P. Berrangé via Devel wrote:
On Tue, Nov 25, 2025 at 02:54:20PM +0100, Ján Tomko via Devel wrote:
On a Tuesday in 2025, Peter Krempa via Devel wrote:
From: Peter Krempa <pkrempa@redhat.com>
'char *tmp' is assigned from calling 'strrchr' on a 'const char *'. New clang in fedora doesn't like it. Make 'tmp' const.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> ---
https://gitlab.com/MichalPrivoznik/libvirt/-/jobs/12208300313
I was hoping the link would show a fixed pipeline :)
I'm rather curious how clang decides to trigger that warning given the libc header file declares the return value non-const
extern char *strchr (const char *__s, int __c) __THROW __attribute_pure__ __nonnull ((1));
It seems like clang has special-cased strchr/strrchr to enforce the const return for const input.
Well, it also triggers in places like:
../src/rpc/virnetsshsession.c:223:18: error: assigning to 'char *' from 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] 223 | if ((tmp = strrchr(askcred[i].prompt, ':'))) | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And just to give you context around the line:
if ((tmp = strrchr(askcred[i].prompt, ':'))) *tmp = '\0';
Well, the prompt is defined as const char*:
We just created askcred[i].prompt from g_strdup a line earlier so it is safe. None the less this is bad practice - we should use an intermediate variable to strip the ':', and only assign to the struct once done.
struct _virConnectCredential { int type; /* One of virConnectCredentialType constants */ const char *prompt; /* Prompt to show to user */ const char *challenge; /* Additional challenge to show */ const char *defresult; /* Optional default result */ char *result; /* Result to be filled with user response (or defresult) */ unsigned int resultlen; /* Length of the result */ };
Jano
So I'd rather this patch is NOT merged and CLang is fixed instead.
Michal
With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|