Trivial fixes for Coverity warnings
cover Trivial fixes for Coverity warnings
Fix the low hanging fruit.
Stephen Hemminger (2):
ip_pipeline: fix coverity warning
ethtool: fix dead code
examples/ethtool/ethtool-app/ethapp.c | 9 +++------ examples/ip_pipeline/thread_fe.c | 5 ++--- 2 files changed, 5 insertions(+), 9 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/2 ip_pipeline: fix coverity warning
Fix problem reported by latest Coverity scan.
It won't have a direct impact on anything.
** CID 120412: Code maintainability issues (SIZEOF_MISMATCH) /examples/ip_pipeline/thread_fe.c: 338 in app_pipeline_thread_cmd_push()
*** CID 120412: Code maintainability issues (SIZEOF_MISMATCH) /examples/ip_pipeline/thread_fe.c: 338 in app_pipeline_thread_cmd_push()
332 /* Check for available slots in the application commands array */ 333 n_cmds = RTE_DIM(thread_cmds) - 1; 334 if (n_cmds > APP_MAX_CMDS - app->n_cmds) 335 return -ENOMEM; 336 337 /* Push thread commands into the application */ >>> CID 120412: Code maintainability issues (SIZEOF_MISMATCH) >>> Passing argument "&app->cmds[app->n_cmds]" of type "cmdline_parse_ctx_t *" and argument "n_cmds * 8UL /* sizeof (cmdline_parse_ctx_t *) */" to function "memcpy" is suspicious. In this case, "sizeof (cmdline_parse_ctx_t *)" is equal to "sizeof (cmdline_parse_ctx_t)", but this is not a portable assumption. 338 memcpy(&app->cmds[app->n_cmds], 339 thread_cmds, 340 n_cmds * sizeof(cmdline_parse_ctx_t *)); 341 342 for (i = 0; i < n_cmds; i++) 343 app->cmds[app->n_cmds + i]->data = app; --- examples/ip_pipeline/thread_fe.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
examples/ip_pipeline/thread_fe.c +2 -3
@@ -335,9 +335,8 @@ app_pipeline_thread_cmd_push(struct app_params *app)return -ENOMEM ;/* Push thread commands into the application */ -memcpy (&app->cmds[app->n_cmds], - thread_cmds, - n_cmds *sizeof (cmdline_parse_ctx_t *)); +memcpy (&app->cmds[app->n_cmds], thread_cmds, + n_cmds *sizeof (cmdline_parse_ctx_t));for (i =0 ; i < n_cmds; i++) app->cmds[app->n_cmds + i]->data = app;
Signature · 1 line
2.1.4
PATCH 2/2 ethtool: fix dead code
In reply to Stephen HemmingerRemove dead code, and print better return for other errors.
*** CID 120411: Control flow issues (DEADCODE) /examples/ethtool/ethtool-app/ethapp.c: 484 in pcmd_macaddr_callback()
478 mac_addr.addr_bytes[4],
479 mac_addr.addr_bytes[5]);
480 return;
481 }
482 }
483 if (stat == 0)
>>> CID 120411: Control flow issues (DEADCODE)
>>> Execution cannot reach this statement: "return;".
484 return;
485 else if (stat == -ENOTSUP)
486 printf("Port %i: Operation not supported\n", params->port);
487 else
488 printf("Port %i: Error %i\n", params->port, stat);
489 }** CID 120410: Error handling issues (CHECKED_RETURN)
--- examples/ethtool/ethtool-app/ethapp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
examples/ethtool/ethtool-app/ethapp.c +3 -6
@@ -480,12 +480,9 @@ pcmd_macaddr_callback(void *ptr_params,return ; } } -if (stat ==0 ) -return ; -else if (stat == -ENOTSUP ) -printf ("Port %i: Operation not supported\n" , params->port); -else -printf ("Port %i: Error %i\n" , params->port, stat); + +printf ("Port %i: Error %s\n" , params->port, +strerror (-stat)); } static void
Signature · 1 line
2.1.4
Re: [PATCH 2/2] ethtool: fix dead code
Beat me to it.. :)
Quoted 3 lines · Stephen Hemminger
Remove dead code, and print better return for other errors.
Signed-off-by Stephen Hemminger <[email protected]>
Re: [PATCH 2/2] ethtool: fix dead code
2015-12-08 16:58, Remy Horton:
Quoted 8 lines
Beat me to it.. :)
Quoted 3 lines · Stephen Hemminger
Remove dead code, and print better return for other errors.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Remy Horton <[email protected]>
Series applied, thanks