On Wed, Mar 9, 2022 at 2:25 AM Kent Gibson <warthog618@xxxxxxxxx> wrote: > > 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@xxxxxxxxx> 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@xxxxxxxx> > > > > --- > > > > 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. > Will do when applying. > And this is for the v2 branch, right? > Yes, of course. Thanks, Bart > Cheers, > Kent.