Re: [PATCHv2] fix GCC enum warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 20, 2020 at 5:26 AM Hans Verkuil <hverkuil@xxxxxxxxx> wrote:
>
> On 03/08/2020 23:39, Rosen Penev wrote:
> > Found with -Wenum-compare
> >
> > ../utils/common/v4l-helpers.h:880:36: warning: enumerated and
> > non-enumerated type in conditional expression [-Wextra]
> >   880 |  return hsv_enc < V4L2_HSV_ENC_180 ? V4L2_HSV_ENC_180 : hsv_enc;
> >
> > Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> > ---
> >  v2: Added warning message.
> >  utils/common/v4l-helpers.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/utils/common/v4l-helpers.h b/utils/common/v4l-helpers.h
> > index e093e717..edd21c16 100644
> > --- a/utils/common/v4l-helpers.h
> > +++ b/utils/common/v4l-helpers.h
> > @@ -877,7 +877,7 @@ v4l_format_g_hsv_enc(const struct v4l2_format *fmt)
> >  {
> >       unsigned hsv_enc = v4l_format_g_ycbcr_enc(fmt);
>
> Does the warning go away if you replace 'unsigned' with enum v4l2_hsv_encoding?
../utils/common/v4l-helpers.h:878:25: error: cannot initialize a
variable of type 'enum v4l2_hsv_encoding' with an rvalue of type
'unsigned int'
        enum v4l2_hsv_encoding hsv_enc = v4l_format_g_ycbcr_enc(fmt);

>
> I would like that a lot better than casting V4L2_HSV_ENC_180.
>
> Regards,
>
>         Hans
>
> >
> > -     return hsv_enc < V4L2_HSV_ENC_180 ? V4L2_HSV_ENC_180 : hsv_enc;
> > +     return hsv_enc < V4L2_HSV_ENC_180 ? unsigned(V4L2_HSV_ENC_180) : hsv_enc;
> >  }
> >
> >  static inline void v4l_format_s_quantization(struct v4l2_format *fmt,
> >
>



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux