mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@kernel.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/1] gpiolib: shared: Don't define variable in the middle of the code
Date: Tue, 13 Oct 2026 16:31:40 +0300	[thread overview]
Message-ID: <as4yvFgW9R5HPHX4@ashevche-desk.local> (raw)
In-Reply-To: <CAMRc=McSCMS0PB69k0tnKMvBRkB1t-4HOhsvGr82yse4FuNtCw@mail.gmail.com>

On Tue, Oct 13, 2026 at 02:42:59PM +0300, Bartosz Golaszewski wrote:
> On Tue, 13 Oct 2026 12:04:41 +0200, Jiri Slaby <jirislaby@kernel.org> said:
> > On 13. 10. 26, 11:44, Andy Shevchenko wrote:
> >> While the C11 allows us to define variables in the code, we do not
> >> do this style (see more at [1]). Move the declaration to the top of
> >> the function.
> >>
> >> Link: https://lore.kernel.org/lkml/58fd478f408a34b578ee8d949c5c4b4da4d4f41d.camel@HansenPartnership.com/ [1]
> >
> >  From the link, I have just learnt two things:
> > 1) I am not alone preferring declarations in the middle of blocks (it
> > has more pros than cons IMO). But again, I spend a lot of time in the
> > c++ universe.

True, but there is also old style and it's kept like this.

> I actually do prefer declaring variables at the top of the function. This is
> a leftover from when this variable was managed with __free().
> 
> > 2) the kernel defines "auto" even for < c23. Therefore:

True, but using auto in the code will make it really hard to follow. I find it
nice in the macros, though.

> Excuse me, what?! :O
> 
> That's the first time I'm learning that we can use C++-like auto in the kernel
> C code. Thanks for bringing this to my attention!

Yeah, with some version we eventually get it standardized.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-10-13 13:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  9:44 Andy Shevchenko
2026-10-13 10:04 ` Jiri Slaby
2026-10-13 11:42   ` Bartosz Golaszewski
2026-10-13 13:31     ` Andy Shevchenko [this message]
2026-10-14  8:25 ` Bartosz Golaszewski

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=as4yvFgW9R5HPHX4@ashevche-desk.local \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=jirislaby@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.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®