Skip to contentSkip to conversation

dcb: some misc fixes

PATCH In review Andrea Claudi 3 participants 7 messages May 1, 2021 – May 6, 2021

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

cover dcb: some misc fixes

This series fixes two issues on dcb code:
- patch 1 fixes an incorrect return value in dcb_cmd_app_show() if an incorrect argument is provided;
- patch 2 is a trivial fix for a memory leak when "dcb help" is executed.

Andrea Claudi (2):
dcb: fix return value on dcb_cmd_app_show
dcb: fix memory leak

 dcb/dcb.c     | 3 ++-
 dcb/dcb_app.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 dcb: fix return value on dcb_cmd_app_show

dcb_cmd_app_show() is supposed to return EINVAL if an incorrect argument is provided.

Fixes 8e9bed1493f5 ("dcb: Add a subtool for the DCB APP object")
---
 dcb/dcb_app.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dcb/dcb_app.c +1 -1
index c4816bc2..28f40614 100644
@@ -667,7 +667,7 @@ static int dcb_cmd_app_show(struct dcb *dcb, const char *dev, int argc, char **a
 out:
 	close_json_object();
 	dcb_app_table_fini(&tab);
-	return 0;
+	return ret;
 }
 
 static int dcb_cmd_app_flush(struct dcb *dcb, const char *dev, int argc, char **argv)
Signature · 1 line
2.30.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH iproute2 1/2] dcb: fix return value on dcb_cmd_app_show

Quoted 14 lines · Andrea Claudi

dcb_cmd_app_show() is supposed to return EINVAL if an incorrect argument is provided.

Fixes 8e9bed1493f5 ("dcb: Add a subtool for the DCB APP object")
---
 dcb/dcb_app.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dcb/dcb_app.c +0 -0
index c4816bc2..28f40614 100644

dcb/dcb_app.c static int dcb_cmd_app_show(struct dcb *dcb, const char *dev, int argc, char **a · line 673

Quoted 8 lines
dcb/dcb_app.c +1 -1
@@ -667,7 +667,7 @@ static int dcb_cmd_app_show(struct dcb *dcb, const char *dev, int argc, char **a
 out:
 	close_json_object();
 	dcb_app_table_fini(&tab);
-	return 0;
+	return ret;
 }
 
 static int dcb_cmd_app_flush(struct dcb *dcb, const char *dev, int argc, char **argv)

Nice catch. Looks good,

#3 lore raw

Re: [PATCH iproute2 1/2] dcb: fix return value on dcb_cmd_app_show

In reply to Andrea Claudi
Quoted 9 lines · Andrea Claudi

dcb_cmd_app_show() is supposed to return EINVAL if an incorrect argument is provided.

Fixes 8e9bed1493f5 ("dcb: Add a subtool for the DCB APP object")
---
 dcb/dcb_app.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

applied both

#4 lore raw

PATCH 2/2 dcb: fix memory leak

In reply to Andrea Claudi

main() dinamically allocates dcb, but when dcb_help() is called it returns without freeing it.

Fix this using a goto, as it is already done in the same function.

Fixes 67033d1c1c8a ("Add skeleton of a new tool, dcb")
---
 dcb/dcb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
dcb/dcb.c +2 -1
index 64a9ef02..696f00e4 100644
@@ -571,7 +571,8 @@ int main(int argc, char **argv)
 			break;
 		case 'h':
 			dcb_help();
-			return 0;
+			ret = EXIT_SUCCESS;
+			goto dcb_free;
 		default:
 			fprintf(stderr, "Unknown option.\n");
 			dcb_help();
Signature · 1 line
2.30.2
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH iproute2 2/2] dcb: fix memory leak

Quoted 7 lines · Andrea Claudi

main() dinamically allocates dcb, but when dcb_help() is called it returns without freeing it.

Fix this using a goto, as it is already done in the same function.

Fixes 67033d1c1c8a ("Add skeleton of a new tool, dcb")

Thanks!

#6 lore raw
In reply to Andrea Claudi
Quoted 6 lines · Andrea Claudi

This series fixes two issues on dcb code:
- patch 1 fixes an incorrect return value in dcb_cmd_app_show() if an incorrect argument is provided;
- patch 2 is a trivial fix for a memory leak when "dcb help" is executed.

Quoted 8 lines

Andrea Claudi (2):
dcb: fix return value on dcb_cmd_app_show
dcb: fix memory leak

 dcb/dcb.c     | 3 ++-
 dcb/dcb_app.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Always cc author of Fixes commit