diff mbox series

[ibsim,19/23] sim_cmd.c: Delete unused value

Message ID 20190102131318.5765-19-honli@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series [ibsim,01/23] move sim_cmd_file into ibsim/sim_cmd.c | expand

Commit Message

Honggang LI Jan. 2, 2019, 1:13 p.m. UTC
Issue was detected by Coverity.

Error: CLANG_WARNING: [#def3]
ibsim-0.7/ibsim/sim_cmd.c:540:3: warning: Value stored to 'n' is never read
//                n += sprintf(comment+n, "\t# err_attr %d", port->errattr);
//                ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ibsim-0.7/ibsim/sim_cmd.c:540:3: note: Value stored to 'n' is never read
//                n += sprintf(comment+n, "\t# err_attr %d", port->errattr);
//                ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  538|   		n += sprintf(comment, "\t# err_rate %d", port->errrate);
//  539|   	if (port->errattr)
//  540|-> 		n += sprintf(comment+n, "\t# err_attr %d", port->errattr);
//  541|   }
//  542|

Signed-off-by: Honggang Li <honli@redhat.com>
---
 ibsim/sim_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hal Rosenstock Jan. 4, 2019, 12:25 p.m. UTC | #1
On 1/2/2019 8:13 AM, Honggang Li wrote:
> Issue was detected by Coverity.
> 
> Error: CLANG_WARNING: [#def3]
> ibsim-0.7/ibsim/sim_cmd.c:540:3: warning: Value stored to 'n' is never read
> //                n += sprintf(comment+n, "\t# err_attr %d", port->errattr);
> //                ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ibsim-0.7/ibsim/sim_cmd.c:540:3: note: Value stored to 'n' is never read
> //                n += sprintf(comment+n, "\t# err_attr %d", port->errattr);
> //                ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> //  538|   		n += sprintf(comment, "\t# err_rate %d", port->errrate);
> //  539|   	if (port->errattr)
> //  540|-> 		n += sprintf(comment+n, "\t# err_attr %d", port->errattr);
> //  541|   }
> //  542|
> 
> Signed-off-by: Honggang Li <honli@redhat.com>

Thanks. Applied.

-- Hal
diff mbox series

Patch

diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index 0a94c68bdf21..325292103caa 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -537,7 +537,7 @@  static void dump_comment(Port * port, char *comment)
 	if (port->errrate)
 		n += sprintf(comment, "\t# err_rate %d", port->errrate);
 	if (port->errattr)
-		n += sprintf(comment+n, "\t# err_attr %d", port->errattr);
+		sprintf(comment+n, "\t# err_attr %d", port->errattr);
 }
 
 static void dump_port(FILE * f, Port * port, int type)