dcb: some misc fixes
Subsystems (2)
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
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.
--- dcb/dcb_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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)
Signature · 1 line
2.30.2
PATCH 2/2 dcb: fix memory leak
In reply to Andrea Claudimain() 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.
--- dcb/dcb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
dcb/dcb.c +2 -1
@@ -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
Quoted 6 lines · Andrea Claudi
This series fixes two issues on dcb code:
- patch 1 fixes an incorrect return value indcb_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 ondcb_cmd_app_show
dcb: fix memory leakdcb/dcb.c | 3 ++- dcb/dcb_app.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
Always cc author of Fixes commit
Re: [PATCH iproute2 2/2] dcb: fix memory leak
In reply to Andrea ClaudiQuoted 7 lines · Andrea Claudi
main()dinamically allocates dcb, but whendcb_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")Signed-off-by Andrea Claudi <[email protected]>
Thanks!
Re: [PATCH iproute2 1/2] dcb: fix return value on dcb_cmd_app_show
In reply to Andrea ClaudiQuoted 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")Signed-off-by Andrea Claudi <[email protected]>--- dcb/dcb_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)dcb/dcb_app.c +0
-0
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,
Re: [PATCH iproute2 1/2] dcb: fix return value on dcb_cmd_app_show
In reply to Andrea ClaudiQuoted 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")Signed-off-by Andrea Claudi <[email protected]>--- dcb/dcb_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
applied both