From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: Qianfeng Rong <rongqianfeng@vivo.com>
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
Jacopo Mondi <jacopo@jmondi.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
"open list:MT9V111 APTINA CAMERA SENSOR"
<linux-media@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/5] media: i2c: mt9v111: fix incorrect type for ret
Date: Thu, 28 Aug 2025 08:40:22 +0200 [thread overview]
Message-ID: <bceety6ir4doadxo7zeixc3vve5faewtqhofsilkcjcbppwu4p@zdis66vyayi2> (raw)
In-Reply-To: <8cf9d7a6-9950-4086-8b81-ddaa68639410@vivo.com>
Hi Qianfeng
On Thu, Aug 28, 2025 at 10:08:07AM +0800, Qianfeng Rong wrote:
>
> 在 2025/8/28 0:24, Jacopo Mondi 写道:
> > [You don't often get email from jacopo.mondi@ideasonboard.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> >
> > Hi Qianfeng
> >
> > On Wed, Aug 27, 2025 at 11:41:26PM +0800, Qianfeng Rong wrote:
> > > 在 2025/8/27 20:58, Jacopo Mondi 写道:
> > > > [You don't often get email from jacopo.mondi@ideasonboard.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> > > >
> > > > Hi Qianfeng
> > > >
> > > > On Wed, Aug 27, 2025 at 08:39:10PM +0800, Qianfeng Rong wrote:
> > > > > Change "ret" from unsigned int to int type in mt9v111_calc_frame_rate()
> > > > > to store negative error codes or zero returned by __mt9v111_hw_reset()
> > > > > and other functions.
> > > > >
> > > > > Storing the negative error codes in unsigned type, doesn't cause an issue
> > > > > at runtime but it's ugly as pants.
> > > > >
> > > > > No effect on runtime.
> > > > well, I'm not sure that's true.
> > > >
> > > > The code goes as
> > > >
> > > > ret = __mt9v111_hw_reset(mt9v111);
> > > > if (ret == -EINVAL)
> > > > ret = __mt9v111_sw_reset(mt9v111);
> > > > if (ret)
> > > > return ret;
> > > >
> > > > And if ret is unsigned the condition ret == -EINVAL will never be met.
> > > >
> > > > I guess this actually fixes a bug, doesn't it ?
> > > > You can add:
> > > >
> > > > Cc: stable@vger.kernel.org
> > > > Fixes: aab7ed1c3927 ("media: i2c: Add driver for Aptina MT9V111")
> > > > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > > >
> > > > Thanks
> > > > j
> > > I have written a test program on the arm64 platform:
> > >
> > > unsigned int ret = -ENOMEM;
> > >
> > > if (ret == -ENOMEM)
> > > pr_info("unsigned int ret(%u) == -ENOMEM\n", ret);
> > > else
> > > pr_info("unsigned int ret(%u) != -ENOMEM\n", ret);
> > >
> > > Output log is: unsigned int ret(4294967284) == -ENOMEM
> > Indeed, I was very wrong and ignoring the C integer promotion rules.
> >
> > If I read right the "6.3.1.8 Usual arithmetic conversions" section of
> > the C11 specs I found freely available online (ISO/IEC 9899:201x), in
> > particular:
> >
> > if the operand that has unsigned integer type has rank greater or
> > equal to the rank of the type of the other operand, then the operand with
> > signed integer type is converted to the type of the operand with unsigned
> > integer type.
> >
> > Indeed the above doesn't introduce any functional change (as the
> > 'rank' of an unsigned int is the same as the one of an int [1])
> >
> > I would anyway consider it at least a "logical" fix, as comparing an
> > unsigned int to a negative error code is misleading for the reader at
> > the least.
> >
> > Thanks anyway for testing.
> >
> > [1] Section "6.3.1.1"
> > The rank of any unsigned integer type shall equal the rank of the corresponding
> > signed integer type, if any.
>
>
> Thank you for letting me know about this. It's a great learning experience
> through our discussions-cheers!
>
> Do I still need to submit the v2 version with the following additions?
>
> Cc: stable@vger.kernel.org
> Fixes: aab7ed1c3927 ("media: i2c: Add driver for Aptina MT9V111")
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
I would do so anyway, yes.
For sure you can keep my tag ;)
Cheers!
>
> Best regards,
> Qianfeng
>
> >
next prev parent reply other threads:[~2025-08-28 6:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 12:39 [PATCH 0/5] media: use int type to store negative error codes Qianfeng Rong
2025-08-27 12:39 ` [PATCH 1/5] media: dvb: Use " Qianfeng Rong
2025-08-27 12:39 ` [PATCH 2/5] media: i2c: mt9v111: fix incorrect type for ret Qianfeng Rong
2025-08-27 12:58 ` Jacopo Mondi
2025-08-27 15:41 ` Qianfeng Rong
2025-08-27 16:24 ` Jacopo Mondi
2025-08-28 2:08 ` Qianfeng Rong
2025-08-28 6:40 ` Jacopo Mondi [this message]
2025-08-28 6:43 ` Sakari Ailus
2025-08-28 6:45 ` Sakari Ailus
2025-08-27 12:39 ` [PATCH 3/5] media: raspberrypi: use int type to store negative error codes Qianfeng Rong
2025-08-27 12:39 ` [PATCH 4/5] media: stm32-dcmi: " Qianfeng Rong
2025-08-27 12:39 ` [PATCH 5/5] media: redrat3: " Qianfeng Rong
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=bceety6ir4doadxo7zeixc3vve5faewtqhofsilkcjcbppwu4p@zdis66vyayi2 \
--to=jacopo.mondi@ideasonboard.com \
--cc=jacopo@jmondi.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rongqianfeng@vivo.com \
--cc=sakari.ailus@linux.intel.com \
/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
all inboxes | Powered by JetHome®