[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <411e9db5-5339-4527-bb3d-473b339a6572@vivo.com>
Date: Wed, 27 Aug 2025 23:41:26 +0800
From: Qianfeng Rong <rongqianfeng@...o.com>
To: Jacopo Mondi <jacopo.mondi@...asonboard.com>
Cc: Jacopo Mondi <jacopo@...ndi.org>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
"open list:MT9V111 APTINA CAMERA SENSOR" <linux-media@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/5] media: i2c: mt9v111: fix incorrect type for ret
在 2025/8/27 20:58, Jacopo Mondi 写道:
> [You don't often get email from jacopo.mondi@...asonboard.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@...r.kernel.org
> Fixes: aab7ed1c3927 ("media: i2c: Add driver for Aptina MT9V111")
> Reviewed-by: Jacopo Mondi <jacopo.mondi@...asonboard.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
I suspect that -ENOMEM is forcibly converted to an unsigned type during the
comparison, but I am not sure if this behavior is consistent across all
platforms and compilers. Therefore, I agree that your suggestion and will
submit the v2 version.
Best regards,
Qianfeng
Powered by blists - more mailing lists