linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Dishank Jogi <jogidishank503@gmail.com>
Cc: linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org,
	 darshanrathod475@gmail.com
Subject: Re: [PATCH] zorro: fix checkpatch error by avoiding assignment in if-statement.
Date: Tue, 29 Jul 2025 09:08:32 +0200	[thread overview]
Message-ID: <CAMuHMdUkJrsug-hKkM_f+0xxrPHBQfw_3WB2FhMM=yAYzRn1Eg@mail.gmail.com> (raw)
In-Reply-To: <20250728093412.48065-1-jogidishank503@gmail.com>

Hi Dishank,

On Mon, 28 Jul 2025 at 11:34, Dishank Jogi <jogidishank503@gmail.com> wrote:
> These changes improve code readability and bring the file
> in line with the Linux kernel coding style.
>
> No functional changes.
>
> Signed-off-by: Dishank Jogi <jogidishank503@gmail.com>

Thanks for your patch!

> --- a/drivers/zorro/gen-devlist.c
> +++ b/drivers/zorro/gen-devlist.c
> @@ -44,7 +44,8 @@ main(void)
>
>         while (fgets(line, sizeof(line)-1, stdin)) {
>                 lino++;
> -               if ((c = strchr(line, '\n')))
> +               c = strchr(line, '\n')

As Christophe pointed out, this line lacks a semicolon.
Please do not submit untested patches.

> +               if (c)
>                         *c = 0;
>                 if (!line[0] || line[0] == '#')
>                         continue;
> @@ -68,7 +69,8 @@ main(void)
>                                         fprintf(devf, "\tPRODUCT(%s,%s,\"", manuf, line+1);
>                                         pq(devf, c);
>                                         fputs("\")\n", devf);
> -                               } else goto err;
> +                               } else
> +                                       goto err;

This does not comply with Linux kernel coding style: please use braces
in both branches.

However, in this case I'd rather invert the logic, remove the braces,
and reduce indentation for the big block:

    if (strlen(line) <= 5 || line[5] != ' ')
            goto err;

    [...]

>                                 break;
>                         default:
>                                 goto err;

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  parent reply	other threads:[~2025-07-29  7:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-28  9:34 [PATCH] zorro: fix checkpatch error by avoiding assignment in if-statement Dishank Jogi
2025-07-28 20:42 ` Christophe JAILLET
2025-07-29  7:08 ` Geert Uytterhoeven [this message]
2025-07-29 12:10   ` Jogi Dishank
2025-07-29 15:49     ` Geert Uytterhoeven
2025-07-29 15:31 ` kernel test robot

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='CAMuHMdUkJrsug-hKkM_f+0xxrPHBQfw_3WB2FhMM=yAYzRn1Eg@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=darshanrathod475@gmail.com \
    --cc=jogidishank503@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.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;
as well as URLs for NNTP newsgroup(s).