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 <[email protected]>
> >
> > '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 <[email protected]>
> > ---
> >
> > 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.
>
> > src/util/vircgroup.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> > index 532a7e5690..3d66d3acb2 100644
> > --- a/src/util/vircgroup.c
> > +++ b/src/util/vircgroup.c
> > @@ -517,7 +517,7 @@ int
> > virCgroupSetValueRaw(const char *path,
> > const char *value)
> > {
> > - char *tmp;
> > + const char *tmp;
> >
> > VIR_DEBUG("Set path '%s' to value '%s'", path, value);
> > if (virFileWriteStr(path, value, 0) < 0) {
>
> Reviewed-by: Ján Tomko <[email protected]>
>
> Jano
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 :|