public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Ricardo Ribalda <ribalda@chromium.org>,
	linux-media@vger.kernel.org,
	Ricardo Ribalda <ricardo@ribalda.com>,
	hverkuil@xs4all.nl
Subject: Re: [PATCH] yavta: Format type errors for non x86 arches
Date: Wed, 20 Sep 2023 00:03:06 +0300	[thread overview]
Message-ID: <20230919210306.GD24325@pendragon.ideasonboard.com> (raw)
In-Reply-To: <ZQoDIbeg00j3STdW@valkosipuli.retiisi.eu>

On Tue, Sep 19, 2023 at 08:22:57PM +0000, Sakari Ailus wrote:
> Hi Ricardo,
> 
> On Tue, Sep 19, 2023 at 10:10:41PM +0200, Ricardo Ribalda wrote:
> > Hi Sakari
> > 
> > On Tue, 19 Sept 2023 at 22:07, Sakari Ailus <sakari.ailus@iki.fi> wrote:
> > >
> > > Hi Ricardo,
> > >
> > > Thanks for the patch.
> > >
> > > On Tue, Sep 19, 2023 at 04:01:23PM +0200, Ricardo Ribalda wrote:
> > > > mipsel64el, ppc64el, ia64, ppc64, sparc64 and x32 have different lenghts
> > > > for long long ints, which result in some compilation errors.
> > > >
> > > > Lets add some castings to help the compiler deal with this.
> > > >
> > > > We cannot use the Format macro constants ffrom inttypes because they
> > > > seem to not be compatible with kernel (__u64 et al) types.
> > > >
> > > > Signed-off-by: Ricardo Ribalda <ricardo@ribalda.com>
> > > > ---
> > > >  yavta.c | 35 +++++++++++++++++++++--------------
> > > >  1 file changed, 21 insertions(+), 14 deletions(-)
> > > >
> > > > diff --git a/yavta.c b/yavta.c
> > > > index d562863..bf54e4f 100644
> > > > --- a/yavta.c
> > > > +++ b/yavta.c
> > > > @@ -1313,7 +1313,8 @@ static void video_query_menu(struct device *dev,
> > > >                       printf("  %u: %.32s%s\n", menu.index, menu.name,
> > > >                              menu.index == value ? " (*)" : "");
> > > >               else
> > > > -                     printf("  %u: %lld%s\n", menu.index, menu.value,
> > > > +                     printf("  %u: %lld%s\n", menu.index,
> > >
> > > Could you instead use PRId64 for this? You can avoid casting to another
> > > type this way. Same for the other cases.
> > 
> > Already tried this:
> > 
> > @@ -1313,7 +1313,7 @@ static void video_query_menu(struct device *dev,
> >                         printf("  %u: %.32s%s\n", menu.index, menu.name,
> >                                menu.index == value ? " (*)" : "");
> >                 else
> > -                       printf("  %u: %lld%s\n", menu.index, menu.value,
> > +                       printf("  %u: %" PRId64 "%s\n", menu.index, menu.value,
> >                                menu.index == value ? " (*)" : "");
> >         };
> >  }
> > 
> > but gcc was not happy:
> > 
> > yavta.c: In function ‘video_query_menu’:
> > yavta.c:1316:11: warning: format ‘%ld’ expects argument of type ‘long
> > int’, but argument 3 has type ‘__s64’ {aka ‘long long int’}
> > [-Wformat=]
> >  1316 |    printf("  %u: %" PRId64 "%s\n", menu.index, menu.value,
> >       |           ^~~~~~~~~                            ~~~~~~~~~~
> >       |                                                    |
> >       |                                                    __s64 {aka
> > long long int}
> > In file included from yavta.c:26:
> > /usr/include/inttypes.h:57:34: note: format string is defined here
> >    57 | # define PRId64  __PRI64_PREFIX "d"
> 
> I guess I should have expected this...
> 
> I'm not sure if it'd be prettier but another option is to use the PRI*
> macros and explicitly cast to a standard type.
> 
> Using the standard types in the V4L2 header would have avoided this issue.
> I wonder if there's anything to be gained by using the kernel types.

The kernel has defined __s64 as signed int int for a long time now, on
all architectures, at least since

commit 0c79a8e29b5fcbcbfd611daf9d500cfad8370fcf
Author: Geert Uytterhoeven <geert@linux-m68k.org>
Date:   Thu Jan 23 15:53:43 2014 -0800

    asm/types.h: Remove include/asm-generic/int-l64.h

which was merged in v3.14.

According to https://buildd.debian.org/status/package.php?p=yavta,
however, __s64 seems to be defined as long int on some platforms.

/me is puzzled

> Cc Hans, too.
> 
> > So I took the shotgun and fixed it with castings :)
> 
> :-)

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2023-09-19 21:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19 14:01 [PATCH] yavta: Format type errors for non x86 arches Ricardo Ribalda
2023-09-19 20:07 ` Sakari Ailus
2023-09-19 20:10   ` Ricardo Ribalda
2023-09-19 20:22     ` Sakari Ailus
2023-09-19 21:03       ` Laurent Pinchart [this message]
2023-09-20 12:19         ` Ricardo Ribalda
2023-09-20 12:39           ` Sakari Ailus
2023-09-20 12:58             ` Ricardo Ribalda
  -- strict thread matches above, loose matches on Subject: below --
2023-09-20 12:59 Ricardo Ribalda
2023-09-20 13:06 ` Sakari Ailus
2023-10-20  7:07   ` Ricardo Ribalda Delgado
2024-04-02 13:59     ` Ricardo Ribalda
2024-09-14  0:27       ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230919210306.GD24325@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=ribalda@chromium.org \
    --cc=ricardo@ribalda.com \
    --cc=sakari.ailus@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox