From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Kent Gibson <warthog618@gmail.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
akpm@linux-foundation.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH v3 1/2] gpio: sim: fix an invalid __free() usage
Date: Sun, 17 Sep 2023 20:59:01 +0200 [thread overview]
Message-ID: <CAMRc=MdMBo0R2XDMYDU+gySyb_eQnvdE64QxE4JSGRDqH7Xcmw@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=wjr5N-2ZKgn_gPaMapprn1vbBxzsdp4fJY+2iC=1H2T5g@mail.gmail.com>
On Sun, Sep 17, 2023 at 6:46 PM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Sun, 17 Sept 2023 at 02:12, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > + has_line_names = true;
> > + max_offset = max(line->offset, max_offset);
>
> I really don't understand why you kept this old broken logic.
>
> I sent a much better version of this function that didn't need that
> pointless has_line_names thing or the 'max()' thing, by just making
> the code a lot simpler.
>
Right, it does what it's supposed to after all but IMO it's less
clear, I had to take a second look now to get it. I was wondering if
I'm simply too sleep deprived but no - it's because in your version
the max_offset variable actually holds the value of (max_offset + 1)
which makes the name untrue.
I don't want to bikeshed about it, let me know if my version is
GoodEnough(R) or do you prefer another respin.
Bart
> Whatever.
>
> > + line_names_size = gpio_sim_get_line_names_size(bank);
> > + if (line_names_size) {
> > + line_names = kcalloc(line_names_size, sizeof(*line_names),
> > + GFP_KERNEL);
> > + if (!line_names)
> > + return ERR_PTR(-ENOMEM);
> > +
> > + gpio_sim_set_line_names(bank, line_names);
> >
> > - if (line_names)
> > properties[prop_idx++] = PROPERTY_ENTRY_STRING_ARRAY_LEN(
> > "gpio-line-names",
> > line_names, line_names_size);
> > + }
>
> But I do like this reorganization.
>
> Linus
next prev parent reply other threads:[~2023-09-17 19:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-17 9:12 [PATCH v3 0/2] gpio: sim: improve the usage of __free() Bartosz Golaszewski
2023-09-17 9:12 ` [PATCH v3 1/2] gpio: sim: fix an invalid __free() usage Bartosz Golaszewski
2023-09-17 16:46 ` Linus Torvalds
2023-09-17 18:59 ` Bartosz Golaszewski [this message]
2023-09-17 9:12 ` [PATCH v3 2/2] gpio: sim: initialize a managed pointer when declaring it Bartosz Golaszewski
2023-09-18 7:06 ` Andy Shevchenko
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='CAMRc=MdMBo0R2XDMYDU+gySyb_eQnvdE64QxE4JSGRDqH7Xcmw@mail.gmail.com' \
--to=brgl@bgdev.pl \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=warthog618@gmail.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;
as well as URLs for NNTP newsgroup(s).