From d7d0aae7b9498e4bed566d863dda27eac90610c1 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Wed, 9 Mar 2022 10:08:03 +0100 Subject: [PATCH] gpiosim: use size_t in the public interface where applicable Use the standard integer type for representing sizes in the API of libgpiod wherever it makes sense. Signed-off-by: Bartosz Golaszewski --- tests/gpiosim/gpiosim.c | 9 ++++----- tests/gpiosim/gpiosim.h | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/gpiosim/gpiosim.c b/tests/gpiosim/gpiosim.c index 338fbc1..ea5357a 100644 --- a/tests/gpiosim/gpiosim.c +++ b/tests/gpiosim/gpiosim.c @@ -319,7 +319,7 @@ struct gpiosim_bank { char *dev_path; int cfs_dir_fd; int sysfs_dir_fd; - unsigned int num_lines; + size_t num_lines; }; static int ctx_open_configfs_dir(struct gpiosim_ctx *ctx, const char *cfs_path) @@ -830,7 +830,7 @@ GPIOSIM_API int gpiosim_bank_set_label(struct gpiosim_bank *bank, } GPIOSIM_API int gpiosim_bank_set_num_lines(struct gpiosim_bank *bank, - unsigned int num_lines) + size_t num_lines) { char buf[32]; int ret; @@ -838,7 +838,7 @@ GPIOSIM_API int gpiosim_bank_set_num_lines(struct gpiosim_bank *bank, if (!dev_check_pending(bank->dev)) return -1; - snprintf(buf, sizeof(buf), "%u", num_lines); + snprintf(buf, sizeof(buf), "%zu", num_lines); ret = open_write_close(bank->cfs_dir_fd, "num_lines", buf); if (ret) @@ -958,8 +958,7 @@ GPIOSIM_API int gpiosim_bank_clear_hog(struct gpiosim_bank *bank, } static int sysfs_read_bank_attr(struct gpiosim_bank *bank, unsigned int offset, - const char *attr, char *buf, - unsigned int bufsize) + const char *attr, char *buf, size_t bufsize) { struct gpiosim_dev *dev = bank->dev; char where[32]; diff --git a/tests/gpiosim/gpiosim.h b/tests/gpiosim/gpiosim.h index de38f3f..25b245a 100644 --- a/tests/gpiosim/gpiosim.h +++ b/tests/gpiosim/gpiosim.h @@ -5,6 +5,7 @@ #define __GPIOD_GPIOSIM_H__ #include +#include #ifdef __cplusplus extern "C" { @@ -49,8 +50,7 @@ const char *gpiosim_bank_get_chip_name(struct gpiosim_bank *bank); const char *gpiosim_bank_get_dev_path(struct gpiosim_bank *bank); int gpiosim_bank_set_label(struct gpiosim_bank *bank, const char *label); -int gpiosim_bank_set_num_lines(struct gpiosim_bank *bank, - unsigned int num_lines); +int gpiosim_bank_set_num_lines(struct gpiosim_bank *bank, size_t num_lines); int gpiosim_bank_set_line_name(struct gpiosim_bank *bank, unsigned int offset, const char *name); int gpiosim_bank_hog_line(struct gpiosim_bank *bank, unsigned int offset, -- 2.30.2