Skip to contentSkip to conversation

treewide: use size_t where applicable

PATCH In review Bartosz Golaszewski 2 participants 5 messages Mar 8, 2022 – Mar 9, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 treewide: use size_t where applicable

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.

---
 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(-)
include/gpiod.h +15 -15
index 0512a8f..e6a4645 100644
@@ -9,6 +9,7 @@
 #define __LIBGPIOD_GPIOD_H__
 
 #include <stdbool.h>
+#include <stddef.h>
 #include <stdint.h>
 
 #ifdef __cplusplus
@@ -99,7 +100,7 @@ const char *gpiod_chip_get_path(struct gpiod_chip *chip);
  * @param chip GPIO chip object.
  * @return Number of GPIO lines.
  */
-unsigned int gpiod_chip_get_num_lines(struct gpiod_chip *chip);
+size_t gpiod_chip_get_num_lines(struct gpiod_chip *chip);
 
 /**
  * @brief Get the current snapshot of information about the line at given
@@ -940,7 +941,7 @@ gpiod_line_config_set_output_value_override(struct gpiod_line_config *config,
  *               the previous argument.
  */
 void gpiod_line_config_set_output_values(struct gpiod_line_config *config,
-					 unsigned int num_values,
+					 size_t num_values,
 					 const unsigned int *offsets,
 					 const int *values);
 
@@ -1016,8 +1017,7 @@ enum {
  * @param config Line config object.
  * @return Number of individual overridden settings.
  */
-unsigned int
-gpiod_line_config_get_num_overrides(struct gpiod_line_config *config);
+size_t gpiod_line_config_get_num_overrides(struct gpiod_line_config *config);
 
 /**
  * @brief Get the list of overridden offsets and the corresponding types of
@@ -1090,7 +1090,7 @@ gpiod_request_config_get_consumer(struct gpiod_request_config *config);
  *       accepted by the kernel (64 lines) are silently dropped.
  */
 void gpiod_request_config_set_offsets(struct gpiod_request_config *config,
-				      unsigned int num_offsets,
+				      size_t num_offsets,
 				      const unsigned int *offsets);
 
 /**
@@ -1098,7 +1098,7 @@ void gpiod_request_config_set_offsets(struct gpiod_request_config *config,
  * @param config Request config object.
  * @return Number of line offsets in this request config.
  */
-unsigned int
+size_t
 gpiod_request_config_get_num_offsets(struct gpiod_request_config *config);
 
 /**
@@ -1119,14 +1119,14 @@ void gpiod_request_config_get_offsets(struct gpiod_request_config *config,
  */
 void
 gpiod_request_config_set_event_buffer_size(struct gpiod_request_config *config,
-					   unsigned int event_buffer_size);
+					   size_t event_buffer_size);
 
 /**
  * @brief Get the edge event buffer size from this request config.
  * @param config Request config object.
  * @return Current edge event buffer size setting.
  */
-unsigned int
+size_t
 gpiod_request_config_get_event_buffer_size(struct gpiod_request_config *config);
 
 /**
@@ -1149,7 +1149,7 @@ void gpiod_line_request_release(struct gpiod_line_request *request);
  * @param request Line request object.
  * @return Number of requested lines.
  */
-unsigned int gpiod_line_request_get_num_lines(struct gpiod_line_request *request);
+size_t gpiod_line_request_get_num_lines(struct gpiod_line_request *request);
 
 /**
  * @brief Get the hardware offsets of lines in this request.
@@ -1179,7 +1179,7 @@ int gpiod_line_request_get_value(struct gpiod_line_request *request,
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
-					 unsigned num_lines,
+					 size_t num_lines,
 					 const unsigned int *offsets,
 					 int *values);
 
@@ -1216,7 +1216,7 @@ int gpiod_line_request_set_value(struct gpiod_line_request *request,
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
-					 unsigned int num_lines,
+					 size_t num_lines,
 					 const unsigned int *offsets,
 					 const int *values);
 
@@ -1272,7 +1272,7 @@ int gpiod_line_request_edge_event_wait(struct gpiod_line_request *request,
  */
 int gpiod_line_request_edge_event_read(struct gpiod_line_request *request,
 				       struct gpiod_edge_event_buffer *buffer,
-				       unsigned int max_events);
+				       size_t max_events);
 
 /**
  * @}
@@ -1361,7 +1361,7 @@ unsigned long gpiod_edge_event_get_line_seqno(struct gpiod_edge_event *event);
  *       capacity is larger than 1024, it will be limited to 1024.
  */
 struct gpiod_edge_event_buffer *
-gpiod_edge_event_buffer_new(unsigned int capacity);
+gpiod_edge_event_buffer_new(size_t capacity);
 
 /**
  * @brief Get the capacity (the max number of events that can be stored) of
@@ -1369,7 +1369,7 @@ gpiod_edge_event_buffer_new(unsigned int capacity);
  * @param buffer Edge event buffer.
  * @return The capacity of the buffer.
  */
-unsigned int
+size_t
 gpiod_edge_event_buffer_get_capacity(struct gpiod_edge_event_buffer *buffer);
 
 /**
@@ -1395,7 +1395,7 @@ gpiod_edge_event_buffer_get_event(struct gpiod_edge_event_buffer *buffer,
  * @param buffer Edge event buffer.
  * @return Number of events stored in this buffer.
  */
-unsigned int
+size_t
 gpiod_edge_event_buffer_get_num_events(struct gpiod_edge_event_buffer *buffer);
 
 /**
lib/chip.c +2 -2
index 74544f5..b881be1 100644
@@ -15,7 +15,7 @@
 
 struct gpiod_chip {
 	int fd;
-	unsigned int num_lines;
+	size_t num_lines;
 	char name[32];
 	char label[32];
 	char *path;
@@ -105,7 +105,7 @@ GPIOD_API const char *gpiod_chip_get_path(struct gpiod_chip *chip)
 	return chip->path;
 }
 
-GPIOD_API unsigned int gpiod_chip_get_num_lines(struct gpiod_chip *chip)
+GPIOD_API size_t gpiod_chip_get_num_lines(struct gpiod_chip *chip)
 {
 	return chip->num_lines;
 }
lib/edge-event.c +6 -6
index 69c0d96..8f993e8 100644
@@ -21,8 +21,8 @@ struct gpiod_edge_event {
 };
 
 struct gpiod_edge_event_buffer {
-	unsigned int capacity;
-	unsigned int num_events;
+	size_t capacity;
+	size_t num_events;
 	struct gpiod_edge_event *events;
 	struct gpio_v2_line_event *event_data;
 };
@@ -79,7 +79,7 @@ gpiod_edge_event_get_line_seqno(struct gpiod_edge_event *event)
 }
 
 GPIOD_API struct gpiod_edge_event_buffer *
-gpiod_edge_event_buffer_new(unsigned int capacity)
+gpiod_edge_event_buffer_new(size_t capacity)
 {
 	struct gpiod_edge_event_buffer *buf;
 
@@ -111,7 +111,7 @@ gpiod_edge_event_buffer_new(unsigned int capacity)
 	return buf;
 }
 
-GPIOD_API unsigned int
+GPIOD_API size_t
 gpiod_edge_event_buffer_get_capacity(struct gpiod_edge_event_buffer *buffer)
 {
 	return buffer->capacity;
@@ -140,7 +140,7 @@ gpiod_edge_event_buffer_get_event(struct gpiod_edge_event_buffer *buffer,
 	return &buffer->events[index];
 }
 
-GPIOD_API unsigned int
+GPIOD_API size_t
 gpiod_edge_event_buffer_get_num_events(struct gpiod_edge_event_buffer *buffer)
 {
 	return buffer->num_events;
@@ -148,7 +148,7 @@ gpiod_edge_event_buffer_get_num_events(struct gpiod_edge_event_buffer *buffer)
 
 int gpiod_edge_event_buffer_read_fd(int fd,
 				    struct gpiod_edge_event_buffer *buffer,
-				    unsigned int max_events)
+				    size_t max_events)
 {
 	struct gpio_v2_line_event *curr;
 	struct gpiod_edge_event *event;
lib/internal.h +1 -1
index 32f36b5..9af2cda 100644
@@ -29,7 +29,7 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config,
 struct gpiod_line_request *
 gpiod_line_request_from_kernel(struct gpio_v2_line_request *reqbuf);
 int gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer,
-				    unsigned int max_events);
+				    size_t max_events);
 struct gpiod_info_event *
 gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf);
 struct gpiod_info_event *gpiod_info_event_read_fd(int fd);
lib/line-config.c +2 -2
index b58603f..a4b4d7b 100644
@@ -671,7 +671,7 @@ gpiod_line_config_set_output_value_override(struct gpiod_line_config *config,
 
 GPIOD_API void
 gpiod_line_config_set_output_values(struct gpiod_line_config *config,
-				    unsigned int num_values,
+				    size_t num_values,
 				    const unsigned int *offsets,
 				    const int *values)
 {
@@ -746,7 +746,7 @@ static bool base_debounce_period_is_equal(struct base_config *base,
 	return true;
 }
 
-GPIOD_API unsigned int
+GPIOD_API size_t
 gpiod_line_config_get_num_overrides(struct gpiod_line_config *config)
 {
 	struct override_config *override;
lib/line-request.c +5 -5
index 45e11e3..69e4e11 100644
@@ -14,7 +14,7 @@
 
 struct gpiod_line_request {
 	unsigned int offsets[GPIO_V2_LINES_MAX];
-	unsigned int num_lines;
+	size_t num_lines;
 	int fd;
 };
 
@@ -45,7 +45,7 @@ GPIOD_API void gpiod_line_request_release(struct gpiod_line_request *request)
 	free(request);
 }
 
-GPIOD_API unsigned int
+GPIOD_API size_t
 gpiod_line_request_get_num_lines(struct gpiod_line_request *request)
 {
 	return request->num_lines;
@@ -87,7 +87,7 @@ static int offset_to_bit(struct gpiod_line_request *request,
 
 GPIOD_API int
 gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
-				     unsigned num_lines,
+				     size_t num_lines,
 				     const unsigned int *offsets, int *values)
 {
 	struct gpio_v2_line_values buf;
@@ -140,7 +140,7 @@ GPIOD_API int gpiod_line_request_set_value(struct gpiod_line_request *request,
 
 GPIOD_API int
 gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
-				     unsigned int num_lines,
+				     size_t num_lines,
 				     const unsigned int *offsets,
 				     const int *values)
 {
@@ -210,7 +210,7 @@ gpiod_line_request_edge_event_wait(struct gpiod_line_request *request,
 GPIOD_API int
 gpiod_line_request_edge_event_read(struct gpiod_line_request *request,
 				   struct gpiod_edge_event_buffer *buffer,
-				   unsigned int max_events)
+				   size_t max_events)
 {
 	return gpiod_edge_event_buffer_read_fd(request->fd, buffer, max_events);
 }
lib/request-config.c +6 -6
index 3de1820..dd92062 100644
@@ -13,8 +13,8 @@
 struct gpiod_request_config {
 	char consumer[GPIO_MAX_NAME_SIZE];
 	unsigned int offsets[GPIO_V2_LINES_MAX];
-	unsigned int num_offsets;
-	unsigned int event_buffer_size;
+	size_t num_offsets;
+	size_t event_buffer_size;
 };
 
 GPIOD_API struct gpiod_request_config *gpiod_request_config_new(void)
@@ -54,7 +54,7 @@ gpiod_request_config_get_consumer(struct gpiod_request_config *config)
 
 GPIOD_API void
 gpiod_request_config_set_offsets(struct gpiod_request_config *config,
-				 unsigned int num_offsets,
+				 size_t num_offsets,
 				 const unsigned int *offsets)
 {
 	unsigned int i;
@@ -66,7 +66,7 @@ gpiod_request_config_set_offsets(struct gpiod_request_config *config,
 		config->offsets[i] = offsets[i];
 }
 
-GPIOD_API unsigned int
+GPIOD_API size_t
 gpiod_request_config_get_num_offsets(struct gpiod_request_config *config)
 {
 	return config->num_offsets;
@@ -82,12 +82,12 @@ gpiod_request_config_get_offsets(struct gpiod_request_config *config,
 
 GPIOD_API void
 gpiod_request_config_set_event_buffer_size(struct gpiod_request_config *config,
-					   unsigned int event_buffer_size)
+					   size_t event_buffer_size)
 {
 	config->event_buffer_size = event_buffer_size;
 }
 
-GPIOD_API unsigned int
+GPIOD_API size_t
 gpiod_request_config_get_event_buffer_size(struct gpiod_request_config *config)
 {
 	return config->event_buffer_size;
tools/gpiodetect.c +1 -1
index 9047091..6ce3cb8 100644
@@ -70,7 +70,7 @@ int main(int argc, char **argv)
 		if (!chip)
 			die_perror("unable to open %s", entries[i]->d_name);
 
-		printf("%s [%s] (%u lines)\n",
+		printf("%s [%s] (%zu lines)\n",
 		       gpiod_chip_get_name(chip),
 		       gpiod_chip_get_label(chip),
 		       gpiod_chip_get_num_lines(chip));
tools/gpioget.c +2 -1
index 112257c..28030fa 100644
@@ -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;
 
 	for (;;) {
 		optc = getopt_long(argc, argv, shortopts, longopts, &opti);
tools/gpioinfo.c +1 -1
index 2c21474..7788468 100644
@@ -130,7 +130,7 @@ static void list_lines(struct gpiod_chip *chip)
 	unsigned int i, offset;
 	int direction;
 
-	printf("%s - %u lines:\n",
+	printf("%s - %zu lines:\n",
 	       gpiod_chip_get_name(chip), gpiod_chip_get_num_lines(chip));
 
 	for (offset = 0; offset < gpiod_chip_get_num_lines(chip); offset++) {
tools/gpiomon.c +2 -2
index 31ea294..2ead5c6 100644
@@ -154,15 +154,15 @@ static void handle_signal(int signum UNUSED)
 
 int main(int argc, char **argv)
 {
-	unsigned int offsets[64], num_lines = 0, offset, events_wanted = 0,
-		     events_done = 0;
 	bool watch_rising = false, watch_falling = false, active_low = false;
+	size_t num_lines = 0, events_wanted = 0, events_done = 0;
 	struct gpiod_edge_event_buffer *event_buffer;
 	int optc, opti, ret, i, edge, bias = 0;
 	uint64_t timeout = 10 * 1000000000LLU;
 	struct gpiod_request_config *req_cfg;
 	struct gpiod_line_request *request;
 	struct gpiod_line_config *line_cfg;
+	unsigned int offsets[64], offset;
 	struct gpiod_edge_event *event;
 	struct gpiod_chip *chip;
 	struct mon_ctx ctx;
tools/gpioset.c +2 -1
index c27525a..3b8e34b 100644
@@ -192,13 +192,14 @@ int main(int argc, char **argv)
 	const struct mode_mapping *mode = &modes[MODE_EXIT];
 	int ret, optc, opti, bias = 0, drive = 0, *values;
 	struct gpiod_request_config *req_cfg;
-	unsigned int *offsets, num_lines, i;
 	struct gpiod_line_request *request;
 	struct gpiod_line_config *line_cfg;
 	struct callback_data cbdata;
+	unsigned int *offsets, i;
 	struct gpiod_chip *chip;
 	bool active_low = false;
 	char *device, *end;
+	size_t num_lines;
 
 	memset(&cbdata, 0, sizeof(cbdata));
 
Signature · 1 line
2.30.1
#1 lore raw
Quoted 22 lines · Bartosz Golaszewski

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.

---
 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(-)
include/gpiod.h +0 -0
index 0512a8f..e6a4645 100644

[snip]

Quoted 7 lines
tools/gpioget.c +0 -0
index 112257c..28030fa 100644
@@ -44,12 +44,13 @@ int main(int argc, char **argv)
 	int direction = GPIOD_LINE_DIRECTION_INPUT;
 	int optc, opti, bias = 0, ret, *values;

tools/gpioget.c int main(int argc, char **argv) · line 54

Quoted 10 lines
tools/gpioget.c +2 -1
 	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.

Cheers,
Kent.

#2 lore raw
Quoted 40 lines · Kent Gibson
Quoted 22 lines · Bartosz Golaszewski

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.

---
 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(-)
include/gpiod.h +0 -0
index 0512a8f..e6a4645 100644

[snip]

Quoted 13 lines
tools/gpioget.c +1 -1
index 112257c..28030fa 100644
@@ -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;
Quoted 9 lines

tools/gpioget.c int main(int argc, char **argv) · line 54

Quoted 4 lines
tools/gpioget.c +1 -0
      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.

Bart

#3 lore raw
Quoted 51 lines · Bartosz Golaszewski
Quoted 40 lines · Kent Gibson
Quoted 22 lines · Bartosz Golaszewski

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.

---
 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(-)
include/gpiod.h +0 -0
index 0512a8f..e6a4645 100644

[snip]

Quoted 13 lines
tools/gpioget.c +1 -1
index 112257c..28030fa 100644
@@ -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;
Quoted 9 lines

tools/gpioget.c int main(int argc, char **argv) · line 54

Quoted 4 lines
tools/gpioget.c +1 -0
      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.

Quoted 5 lines

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.

#4 lore raw
Quoted 59 lines · Kent Gibson
Quoted 51 lines · Bartosz Golaszewski
Quoted 40 lines · Kent Gibson
Quoted 22 lines · Bartosz Golaszewski

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.

---
 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(-)
include/gpiod.h +0 -0
index 0512a8f..e6a4645 100644

[snip]

Quoted 13 lines
tools/gpioget.c +1 -1
index 112257c..28030fa 100644
@@ -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;
Quoted 9 lines

tools/gpioget.c int main(int argc, char **argv) · line 54

Quoted 4 lines
tools/gpioget.c +1 -0
      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.

Quoted 5 lines

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.

Quoted 4 lines

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.

Quoted 2 lines

And this is for the v2 branch, right?

Yes, of course.

Thanks,
Bart

Quoted 2 lines

Cheers,
Kent.