* Remove useless code in example [libgpiod]
@ 2025-03-25 3:23 Rostyslav Lobov
2025-03-26 4:17 ` Kent Gibson
0 siblings, 1 reply; 4+ messages in thread
From: Rostyslav Lobov @ 2025-03-25 3:23 UTC (permalink / raw)
To: linux-gpio
[-- Attachment #1: Type: text/plain, Size: 292 bytes --]
Hello, I noticed that `libgpiod/examples/reconfigure_input_to_output.c`
has some useless declaration `struct gpiod_request_config *req_cfg =
NULL;` and later free `gpiod_request_config_free(req_cfg);` of the
variable which is never used...
So I'm attaching a fix patch.
Rostyslav Lobov
[-- Attachment #2: remove_useless.patch --]
[-- Type: text/x-patch, Size: 779 bytes --]
diff --git a/examples/reconfigure_input_to_output.c b/examples/reconfigure_input_to_output.c
index 451bb0e..734a99c 100644
--- a/examples/reconfigure_input_to_output.c
+++ b/examples/reconfigure_input_to_output.c
@@ -71,7 +71,6 @@ static int reconfigure_as_output_line(struct gpiod_line_request *request,
unsigned int offset,
enum gpiod_line_value value)
{
- struct gpiod_request_config *req_cfg = NULL;
struct gpiod_line_settings *settings;
struct gpiod_line_config *line_cfg;
int ret = -1;
@@ -95,8 +94,6 @@ static int reconfigure_as_output_line(struct gpiod_line_request *request,
ret = gpiod_line_request_reconfigure_lines(request, line_cfg);
- gpiod_request_config_free(req_cfg);
-
free_line_config:
gpiod_line_config_free(line_cfg);
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: Remove useless code in example [libgpiod]
2025-03-25 3:23 Remove useless code in example [libgpiod] Rostyslav Lobov
@ 2025-03-26 4:17 ` Kent Gibson
2025-03-29 3:18 ` [PATCH] examples: reconfigure_input_to_output: Remove useless variable Rostyslav Lobov
0 siblings, 1 reply; 4+ messages in thread
From: Kent Gibson @ 2025-03-26 4:17 UTC (permalink / raw)
To: Rostyslav Lobov; +Cc: linux-gpio, Bartosz Golaszewski
On Mon, Mar 24, 2025 at 11:23:17PM -0400, Rostyslav Lobov wrote:
> Hello, I noticed that `libgpiod/examples/reconfigure_input_to_output.c`
> has some useless declaration `struct gpiod_request_config *req_cfg =
> NULL;` and later free `gpiod_request_config_free(req_cfg);` of the
> variable which is never used...
> So I'm attaching a fix patch.
> Rostyslav Lobov
> diff --git a/examples/reconfigure_input_to_output.c b/examples/reconfigure_input_to_output.c
> index 451bb0e..734a99c 100644
> --- a/examples/reconfigure_input_to_output.c
> +++ b/examples/reconfigure_input_to_output.c
> @@ -71,7 +71,6 @@ static int reconfigure_as_output_line(struct gpiod_line_request *request,
> unsigned int offset,
> enum gpiod_line_value value)
> {
> - struct gpiod_request_config *req_cfg = NULL;
> struct gpiod_line_settings *settings;
> struct gpiod_line_config *line_cfg;
> int ret = -1;
> @@ -95,8 +94,6 @@ static int reconfigure_as_output_line(struct gpiod_line_request *request,
>
> ret = gpiod_line_request_reconfigure_lines(request, line_cfg);
>
> - gpiod_request_config_free(req_cfg);
> -
> free_line_config:
> gpiod_line_config_free(line_cfg);
>
The patch makes sense, that code looks like a leftover from a cut-and-paste,
but please re-submit as per the CONTRIBUTING section of the README.
Cheers,
Kent.
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH] examples: reconfigure_input_to_output: Remove useless variable
2025-03-26 4:17 ` Kent Gibson
@ 2025-03-29 3:18 ` Rostyslav Lobov
2025-03-31 7:31 ` Bartosz Golaszewski
0 siblings, 1 reply; 4+ messages in thread
From: Rostyslav Lobov @ 2025-03-29 3:18 UTC (permalink / raw)
To: linux-gpio; +Cc: Rostyslav Lobov
The `req_cfg` is declared to NULL, never used and then freed.
Signed-off-by: Rostyslav Lobov <rostyslav@exmakhina.com>
---
examples/reconfigure_input_to_output.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/examples/reconfigure_input_to_output.c b/examples/reconfigure_input_to_output.c
index 451bb0e..734a99c 100644
--- a/examples/reconfigure_input_to_output.c
+++ b/examples/reconfigure_input_to_output.c
@@ -71,7 +71,6 @@ static int reconfigure_as_output_line(struct gpiod_line_request *request,
unsigned int offset,
enum gpiod_line_value value)
{
- struct gpiod_request_config *req_cfg = NULL;
struct gpiod_line_settings *settings;
struct gpiod_line_config *line_cfg;
int ret = -1;
@@ -95,8 +94,6 @@ static int reconfigure_as_output_line(struct gpiod_line_request *request,
ret = gpiod_line_request_reconfigure_lines(request, line_cfg);
- gpiod_request_config_free(req_cfg);
-
free_line_config:
gpiod_line_config_free(line_cfg);
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] examples: reconfigure_input_to_output: Remove useless variable
2025-03-29 3:18 ` [PATCH] examples: reconfigure_input_to_output: Remove useless variable Rostyslav Lobov
@ 2025-03-31 7:31 ` Bartosz Golaszewski
0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2025-03-31 7:31 UTC (permalink / raw)
To: linux-gpio, Rostyslav Lobov; +Cc: Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Fri, 28 Mar 2025 23:18:07 -0400, Rostyslav Lobov wrote:
> The `req_cfg` is declared to NULL, never used and then freed.
>
>
Applied, thanks! Please use the [libgpiod] tag in the email title, I almost
missed this because it doesn't contain any libgpiod keywords.
[1/1] examples: reconfigure_input_to_output: Remove useless variable
commit: 9f0eca2d7260de1ae22fed3795280bdb14b62e57
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-31 7:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 3:23 Remove useless code in example [libgpiod] Rostyslav Lobov
2025-03-26 4:17 ` Kent Gibson
2025-03-29 3:18 ` [PATCH] examples: reconfigure_input_to_output: Remove useless variable Rostyslav Lobov
2025-03-31 7:31 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).