diff mbox series

[libgpiod] core: Fix gpiod_line_bulk_reset type

Message ID 20220202123248.36955-1-joel@jms.id.au
State New
Headers show
Series [libgpiod] core: Fix gpiod_line_bulk_reset type | expand

Commit Message

Joel Stanley Feb. 2, 2022, 12:32 p.m. UTC
bulk->lines is an array of pointers, so it doesn't matter which pointer
type we specify to sizeof(). As it's a struct gpiod_line *, it would
make sense to use that.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---

Alternately, we could make this sizeof(*bulk->lines).

 lib/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bartosz Golaszewski Feb. 18, 2022, 6:35 p.m. UTC | #1
On Wed, Feb 2, 2022 at 1:33 PM Joel Stanley <joel@jms.id.au> wrote:
>
> bulk->lines is an array of pointers, so it doesn't matter which pointer
> type we specify to sizeof(). As it's a struct gpiod_line *, it would
> make sense to use that.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>
> Alternately, we could make this sizeof(*bulk->lines).
>
>  lib/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/core.c b/lib/core.c
> index 2e7ee4b5b896..6ef09baec0f5 100644
> --- a/lib/core.c
> +++ b/lib/core.c
> @@ -117,7 +117,7 @@ GPIOD_API struct gpiod_line_bulk *gpiod_line_bulk_new(unsigned int max_lines)
>  GPIOD_API void gpiod_line_bulk_reset(struct gpiod_line_bulk *bulk)
>  {
>         bulk->num_lines = 0;
> -       memset(bulk->lines, 0, bulk->max_lines * sizeof(struct line *));
> +       memset(bulk->lines, 0, bulk->max_lines * sizeof(struct gpiod_line *));
>  }
>
>  GPIOD_API void gpiod_line_bulk_free(struct gpiod_line_bulk *bulk)
> --
> 2.34.1
>

Applied, thanks!

Bart
diff mbox series

Patch

diff --git a/lib/core.c b/lib/core.c
index 2e7ee4b5b896..6ef09baec0f5 100644
--- a/lib/core.c
+++ b/lib/core.c
@@ -117,7 +117,7 @@  GPIOD_API struct gpiod_line_bulk *gpiod_line_bulk_new(unsigned int max_lines)
 GPIOD_API void gpiod_line_bulk_reset(struct gpiod_line_bulk *bulk)
 {
 	bulk->num_lines = 0;
-	memset(bulk->lines, 0, bulk->max_lines * sizeof(struct line *));
+	memset(bulk->lines, 0, bulk->max_lines * sizeof(struct gpiod_line *));
 }
 
 GPIOD_API void gpiod_line_bulk_free(struct gpiod_line_bulk *bulk)