mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bhavin Sharma <bhavin.sharma@siliconsignals.io>
To: Hans Verkuil <hverkuil@xs4all.nl>,
	"mchehab@kernel.org" <mchehab@kernel.org>,
	"kieran.bingham@ideasonboard.com"
	<kieran.bingham@ideasonboard.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] media: adv7180: Fix cppcheck warnings
Date: Fri, 9 Feb 2024 09:11:22 +0000	[thread overview]
Message-ID: <MAZPR01MB6957B9B109854FED3106A3DEF24B2@MAZPR01MB6957.INDPRD01.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <ae539786-f73a-41ba-97a4-ea409fb88e2f@xs4all.nl>

Hi Hans,

> On 06/02/2024 06:05, Bhavin Sharma wrote:
>> Hi Hans,
>>
> >> Hi Bhavin,
>>
>>> On 02/01/2024 15:27, Bhavin Sharma wrote:
>>>> WARNING: Missing a blank line after declarations
>>>>
>>>> Signed-off-by: Bhavin Sharma <bhavin.sharma@siliconsignals.io>
>>>> ---
>>>>   drivers/media/i2c/adv7180.c | 27 ++++++++++++++++++---------
>>>>   1 file changed, 18 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
>>>> index 54134473186b..0023a546b3c9 100644
>>>> --- a/drivers/media/i2c/adv7180.c
>>>> +++ b/drivers/media/i2c/adv7180.c
>>>> @@ -335,8 +335,9 @@ static u32 adv7180_status_to_v4l2(u8 status1)
>>>>   static int __adv7180_status(struct adv7180_state *state, u32 *status,
>>>>                            v4l2_std_id *std)
>>>>   {
>>>> -     int status1 = adv7180_read(state, ADV7180_REG_STATUS1);
>>>> +     int status1;
>>>>
>>>> +     status1 = adv7180_read(state, ADV7180_REG_STATUS1);
>>>>        if (status1 < 0)
>>>>                return status1;
>>>>
>>>> @@ -356,7 +357,9 @@ static inline struct adv7180_state *to_state(struct v4l2_subdev *sd)
>>>>   static int adv7180_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
>>>>   {
>>>>        struct adv7180_state *state = to_state(sd);
>>>> -     int err = mutex_lock_interruptible(&state->mutex);
>>>> +     int err;
>>>> +
>>>> +     err = mutex_lock_interruptible(&state->mutex);
>>
>>> The problem here is the missing empty line, not that 'int err = <something>;' part.
>>> So just add the empty line and don't split up the variable assignment.
>>
>> Yes, the error is of missing empty line and I only resolved that particular error in the first version
>> of this patch.
>>
>> But I was recommended to keep the conditional statement close to the line it is associated with
>> and to make changes in the code wherever similar format is followed.
>
>> So I followed the advise of Kieran Bingham and made changes accordingly.
>>
>> Below is the link of the full discussion : https://lore.kernel.org/lkml/MAZPR01MB695752E4ADB0110443EA695CF2432@MAZPR01MB6957.INDPRD01.PROD.OUTLOOK.COM/T/

> Kieran said this:

>>> @@ -357,6 +357,7 @@ static int adv7180_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
>>>  {
>>>         struct adv7180_state *state = to_state(sd);
>>
>> Personally, I would keep the if (err) hugging the line it's associated
>> with.
>>
>>
>>>         int err = mutex_lock_interruptible(&state->mutex);
>>> +
>>>         if (err)
>>>                 return err;
>>>

> which I interpret as saying that he doesn't like adding the extra empty line.

>>
>>>>        if (err)
>>>>                return err;
>>>>
>>>> @@ -388,8 +391,9 @@ static int adv7180_s_routing(struct v4l2_subdev *sd, u32 input,
>>>>                             u32 output, u32 config)
>>>>   {
>>>>        struct adv7180_state *state = to_state(sd);
>>>> -     int ret = mutex_lock_interruptible(&state->mutex);
>>>> +     int ret;
>>>>
>>>> +     ret = mutex_lock_interruptible(&state->mutex);

> I don't believe he meant doing this.

> In any case, none of this is worth the effort, just leave this driver as-is.

I appreciate your comments. 
My intention is to make linux kernel source as per kernel code style. In this approach I found these warnings "missing a blank line after declarations"  and made changes accordingly. 
Also, there should be blank line after declaration of a variable, correct me here if I am wrong.
As per the suggestions of Kieran Bingham, he recommended to keep the if(err) hugging the line it's associated. So to adopt this change I made changes accordingly.

Regards,
Bhavin Sharma

  reply	other threads:[~2024-02-09  9:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02 14:27 Bhavin Sharma
2024-02-05  8:36 ` Hans Verkuil
2024-02-06  5:05   ` Bhavin Sharma
2024-02-06  7:38     ` Hans Verkuil
2024-02-09  9:11       ` Bhavin Sharma [this message]
2024-02-09 12:25         ` Kieran Bingham

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=MAZPR01MB6957B9B109854FED3106A3DEF24B2@MAZPR01MB6957.INDPRD01.PROD.OUTLOOK.COM \
    --to=bhavin.sharma@siliconsignals.io \
    --cc=hverkuil@xs4all.nl \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /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®