[libcamera-devel] [PATCH] utils: ipu3: Include libgen.h for basename()

Jacopo Mondi jacopo at jmondi.org
Fri Dec 2 14:48:27 CET 2022


Not really...

I get with clang

../utils/ipu3/ipu3-unpack.c:21:63: error: passing argument 1 of ‘__xpg_basename’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   21 |         printf("Usage: %s input-file output-file\n", basename(argv0));

Sorry, I should have tested before, but it seemed trivial.

I now wonder what 'basename' we were calling, or better, to which
function prototype we were referring to, which didn't trigger such
error...

On Fri, Dec 02, 2022 at 03:33:56PM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Fri, Dec 02, 2022 at 02:27:06PM +0100, Jacopo Mondi via libcamera-devel wrote:
> > The "basename" function from the standard C library is defined in the
> > libgen.h header.
> >
> > Include it to avoid errors triggered by -Wimplicit-function-declaration
> >
> > ../utils/ipu3/ipu3-pack.c:21:47: error: implicit declaration of function
> > 'basename' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> >
> > Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
>
> > ---
> >  utils/ipu3/ipu3-pack.c   | 1 +
> >  utils/ipu3/ipu3-unpack.c | 1 +
> >  2 files changed, 2 insertions(+)
> >
> > diff --git a/utils/ipu3/ipu3-pack.c b/utils/ipu3/ipu3-pack.c
> > index decbfc6c397a..27af44068956 100644
> > --- a/utils/ipu3/ipu3-pack.c
> > +++ b/utils/ipu3/ipu3-pack.c
> > @@ -8,6 +8,7 @@
> >
> >  #include <errno.h>
> >  #include <fcntl.h>
> > +#include <libgen.h>
> >  #include <stdint.h>
> >  #include <stdio.h>
> >  #include <string.h>
> > diff --git a/utils/ipu3/ipu3-unpack.c b/utils/ipu3/ipu3-unpack.c
> > index 9d2c1200d932..aa67e0b0ecf5 100644
> > --- a/utils/ipu3/ipu3-unpack.c
> > +++ b/utils/ipu3/ipu3-unpack.c
> > @@ -8,6 +8,7 @@
> >
> >  #include <errno.h>
> >  #include <fcntl.h>
> > +#include <libgen.h>
> >  #include <stdint.h>
> >  #include <stdio.h>
> >  #include <string.h>
>
> --
> Regards,
>
> Laurent Pinchart


More information about the libcamera-devel mailing list