@@ -152,7 +152,7 @@ int gpiod_edge_event_buffer_read_fd(int fd,
{
struct gpio_v2_line_event *curr;
struct gpiod_edge_event *event;
- unsigned int i;
+ size_t i;
ssize_t rd;
memset(buffer->event_data, 0,
@@ -102,7 +102,7 @@ GPIOD_API void gpiod_line_config_free(struct gpiod_line_config *config)
GPIOD_API void gpiod_line_config_reset(struct gpiod_line_config *config)
{
- int i;
+ size_t i;
memset(config, 0, sizeof(*config));
init_base_config(&config->defaults);
@@ -114,7 +114,7 @@ static struct override_config *
get_override_by_offset(struct gpiod_line_config *config, unsigned int offset)
{
struct override_config *override;
- unsigned int i;
+ size_t i;
for (i = 0; i < NUM_OVERRIDES_MAX; i++) {
override = &config->overrides[i];
@@ -130,7 +130,7 @@ static struct override_config *
get_free_override(struct gpiod_line_config *config, unsigned int offset)
{
struct override_config *override;
- unsigned int i;
+ size_t i;
for (i = 0; i < NUM_OVERRIDES_MAX; i++) {
override = &config->overrides[i];
@@ -675,7 +675,7 @@ gpiod_line_config_set_output_values(struct gpiod_line_config *config,
const unsigned int *offsets,
const int *values)
{
- unsigned int i;
+ size_t i;
for (i = 0; i < num_values; i++)
gpiod_line_config_set_output_value_override(config,
@@ -750,7 +750,7 @@ GPIOD_API size_t
gpiod_line_config_get_num_overrides(struct gpiod_line_config *config)
{
struct override_config *override;
- unsigned int i, j, count = 0;
+ size_t i, j, count = 0;
for (i = 0; i < NUM_OVERRIDES_MAX; i++) {
override = &config->overrides[i];
@@ -797,7 +797,7 @@ gpiod_line_config_get_overrides(struct gpiod_line_config *config,
unsigned int *offsets, int *props)
{
struct override_config *override;
- unsigned int i, j, count = 0;
+ size_t i, j, count = 0;
for (i = 0; i < NUM_OVERRIDES_MAX; i++) {
override = &config->overrides[i];
@@ -884,7 +884,7 @@ static uint64_t make_kernel_flags(const struct base_config *config)
static int find_bitmap_index(unsigned int needle, unsigned int num_lines,
const unsigned int *haystack)
{
- unsigned int i;
+ size_t i;
for (i = 0; i < num_lines; i++) {
if (needle == haystack[i])
@@ -900,7 +900,7 @@ static void set_kernel_output_values(uint64_t *mask, uint64_t *vals,
const unsigned int *offsets)
{
struct override_config *override;
- unsigned int i;
+ size_t i;
int idx;
gpiod_line_mask_zero(mask);
@@ -1033,7 +1033,7 @@ static void set_kernel_attr_mask(uint64_t *out, const uint64_t *in,
struct gpiod_line_config *config)
{
struct override_config *override;
- unsigned int i, j;
+ size_t i, j;
int off;
gpiod_line_mask_zero(out);
@@ -1080,7 +1080,7 @@ static int process_overrides(struct gpiod_line_config *config,
struct gpio_v2_line_config_attribute *attr;
uint64_t processed = 0, marked = 0, mask;
struct override_config *current, *next;
- unsigned int i, j;
+ size_t i, j;
for (i = 0; i < NUM_OVERRIDES_MAX; i++) {
current = &config->overrides[i];
@@ -1129,7 +1129,7 @@ static int process_overrides(struct gpiod_line_config *config,
static bool has_at_least_one_output_direction(struct gpiod_line_config *config)
{
struct override_config *override;
- unsigned int i;
+ size_t i;
if (config->defaults.direction == GPIOD_LINE_DIRECTION_OUTPUT)
return true;
@@ -110,7 +110,7 @@ gpiod_line_info_from_kernel(struct gpio_v2_line_info *infobuf)
{
struct gpio_v2_line_attribute *attr;
struct gpiod_line_info *info;
- unsigned int i;
+ size_t i;
info = malloc(sizeof(*info));
if (!info)
@@ -75,7 +75,7 @@ GPIOD_API int gpiod_line_request_get_value(struct gpiod_line_request *request,
static int offset_to_bit(struct gpiod_line_request *request,
unsigned int offset)
{
- unsigned int i;
+ size_t i;
for (i = 0; i < request->num_lines; i++) {
if (offset == request->offsets[i])
@@ -92,7 +92,7 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
{
struct gpio_v2_line_values buf;
uint64_t mask = 0, bits = 0;
- unsigned int i;
+ size_t i;
int bit, ret;
buf.bits = 0;
@@ -146,7 +146,7 @@ gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
{
struct gpio_v2_line_values buf;
uint64_t mask = 0, bits = 0;
- unsigned int i;
+ size_t i;
int bit;
for (i = 0; i < num_lines; i++) {
@@ -57,7 +57,7 @@ gpiod_request_config_set_offsets(struct gpiod_request_config *config,
size_t num_offsets,
const unsigned int *offsets)
{
- unsigned int i;
+ size_t i;
config->num_offsets = num_offsets > GPIO_V2_LINES_MAX ?
GPIO_V2_LINES_MAX : num_offsets;
@@ -96,7 +96,7 @@ gpiod_request_config_get_event_buffer_size(struct gpiod_request_config *config)
int gpiod_request_config_to_kernel(struct gpiod_request_config *config,
struct gpio_v2_line_request *reqbuf)
{
- unsigned int i;
+ size_t i;
if (config->num_offsets == 0) {
errno = EINVAL;
@@ -46,11 +46,11 @@ int main(int argc, char **argv)
struct gpiod_request_config *req_cfg;
struct gpiod_line_request *request;
struct gpiod_line_config *line_cfg;
- unsigned int *offsets, i;
+ unsigned int *offsets;
struct gpiod_chip *chip;
bool active_low = false;
char *device, *end;
- size_t num_lines;
+ size_t i, num_lines;
for (;;) {
optc = getopt_long(argc, argv, shortopts, longopts, &opti);
@@ -127,7 +127,7 @@ static void list_lines(struct gpiod_chip *chip)
bool flag_printed, of, active_low;
struct gpiod_line_info *info;
const char *name, *consumer;
- unsigned int i, offset;
+ size_t i, offset;
int direction;
printf("%s - %zu lines:\n",
@@ -146,7 +146,7 @@ static void list_lines(struct gpiod_chip *chip)
of = false;
printf("\tline ");
- prinfo(&of, 3, "%u", offset);
+ prinfo(&of, 3, "%zu", offset);
printf(": ");
name ? prinfo(&of, 12, "\"%s\"", name)
@@ -167,7 +167,7 @@ static const struct mode_mapping modes[] = {
static const struct mode_mapping *parse_mode(const char *mode)
{
- unsigned int i;
+ size_t i;
for (i = 0; i < ARRAY_SIZE(modes); i++)
if (strcmp(mode, modes[i].name) == 0)
@@ -195,11 +195,11 @@ int main(int argc, char **argv)
struct gpiod_line_request *request;
struct gpiod_line_config *line_cfg;
struct callback_data cbdata;
- unsigned int *offsets, i;
+ unsigned int *offsets;
struct gpiod_chip *chip;
bool active_low = false;
char *device, *end;
- size_t num_lines;
+ size_t i, num_lines;
memset(&cbdata, 0, sizeof(cbdata));
Switch loop variables to size_t for loops where the limit is a size_t to remove implicit type conversions. Signed-off-by: Kent Gibson <warthog618@gmail.com> --- lib/edge-event.c | 2 +- lib/line-config.c | 22 +++++++++++----------- lib/line-info.c | 2 +- lib/line-request.c | 6 +++--- lib/request-config.c | 4 ++-- tools/gpioget.c | 4 ++-- tools/gpioinfo.c | 4 ++-- tools/gpioset.c | 6 +++--- 8 files changed, 25 insertions(+), 25 deletions(-)