From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH] treewide: use size_t where applicable
Date: Wed, 9 Mar 2022 09:25:25 +0800 [thread overview]
Message-ID: <20220309012525.GA28192@sol> (raw)
In-Reply-To: <CAMRc=Mdck1HUZwVOad+FJ-Dc7t8jA0J7qpFwpWSN4x9_vB+7rQ@mail.gmail.com>
On Tue, Mar 08, 2022 at 09:26:56PM +0100, Bartosz Golaszewski wrote:
> On Tue, Mar 8, 2022 at 4:55 PM Kent Gibson <warthog618@gmail.com> wrote:
> >
> > On Tue, Mar 08, 2022 at 04:22:33PM +0100, Bartosz Golaszewski wrote:
> > > size_t is the unsigned integer type generally used whenever variables
> > > define sizes, ranges and numbers of elements. Use it throughout the
> > > C library wherever it makes sense.
> > >
> > > Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
> > > ---
> > > include/gpiod.h | 30 +++++++++++++++---------------
> > > lib/chip.c | 4 ++--
> > > lib/edge-event.c | 12 ++++++------
> > > lib/internal.h | 2 +-
> > > lib/line-config.c | 4 ++--
> > > lib/line-request.c | 10 +++++-----
> > > lib/request-config.c | 12 ++++++------
> > > tools/gpiodetect.c | 2 +-
> > > tools/gpioget.c | 3 ++-
> > > tools/gpioinfo.c | 2 +-
> > > tools/gpiomon.c | 4 ++--
> > > tools/gpioset.c | 3 ++-
> > > 12 files changed, 45 insertions(+), 43 deletions(-)
> > >
> > > diff --git a/include/gpiod.h b/include/gpiod.h
> > > index 0512a8f..e6a4645 100644
> >
> > [snip]
> >
> > > diff --git a/tools/gpioget.c b/tools/gpioget.c
> > > index 112257c..28030fa 100644
> > > --- a/tools/gpioget.c
> > > +++ b/tools/gpioget.c
> > > @@ -44,12 +44,13 @@ int main(int argc, char **argv)
> > > int direction = GPIOD_LINE_DIRECTION_INPUT;
> > > int optc, opti, bias = 0, ret, *values;
> > > struct gpiod_request_config *req_cfg;
> > > - unsigned int *offsets, i, num_lines;
> > > struct gpiod_line_request *request;
> > > struct gpiod_line_config *line_cfg;
> > > + unsigned int *offsets, i;
> > > struct gpiod_chip *chip;
> > > bool active_low = false;
> > > char *device, *end;
> > > + size_t num_lines;
> > >
> >
> > Also makes sense for indicies into arrays, such as the i here and
> > elsewhere?
> > I'm guessing there is a lot of elsewhere.
> >
>
> I'd leave it for now. In most cases there's no chance of exceeding the
> max value of unsigned int (size_t is unsigned long) and it's also an
> implementation detail that can be changed later. This patch mostly
> addresses the library interface.
>
The checkin comment says "throughout the C library wherever it makes sense",
so reword that to limit the scope to the API, and we can pickup the rest
later.
And this is for the v2 branch, right?
Cheers,
Kent.
next prev parent reply other threads:[~2022-03-09 1:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 15:22 [PATCH] treewide: use size_t where applicable Bartosz Golaszewski
2022-03-08 15:54 ` Kent Gibson
2022-03-08 20:26 ` Bartosz Golaszewski
2022-03-09 1:25 ` Kent Gibson [this message]
2022-03-09 8:32 ` 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=20220309012525.GA28192@sol \
--to=warthog618@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@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;
as well as URLs for NNTP newsgroup(s).