Ticket 6173

Summary: many bad compares ?
Product: Slurm Reporter: David Binderman <dcb314>
Component: AccountingAssignee: Tim Wickberg <tim>
Status: OPEN --- QA Contact:
Severity: 6 - No support contract    
Priority: ---    
Version: 19.05.x   
Hardware: Linux   
OS: Linux   
Site: -Other- Alineos Sites: ---
Atos/Eviden Sites: --- Confidential Site: ---
Coreweave sites: --- Cray Sites: ---
DS9 clusters: --- HPCnow Sites: ---
HPE Sites: --- IBM Sites: ---
NOAA SIte: --- NoveTech Sites: ---
Nvidia HWinf-CS Sites: --- OCF Sites: ---
Recursion Pharma Sites: --- SFW Sites: ---
SNIC sites: --- Tzag Elita Sites: ---
Linux Distro: --- Machine Name:
CLE Version: Version Fixed:
Target Release: --- DevPrio: ---
Emory-Cloud Sites: ---

Description David Binderman 2018-12-05 09:47:39 MST
as_mysql_convert.c:1028]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.

Source code is

      if ((rc = _convert_job_table_pre(mysql_conn, cluster_name)
                     != SLURM_SUCCESS))

maybe better code

      if ((rc = _convert_job_table_pre(mysql_conn, cluster_name))
                     != SLURM_SUCCESS)

Duplicates:

[as_mysql_convert.c:1058]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
as_mysql_convert.c:1064]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
as_mysql_convert.c:1070]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
as_mysql_convert.c:1076]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
as_mysql_convert.c:1082]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
as_mysql_convert.c:1107]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
as_mysql_wckey.c:626]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses
.eio.c:269]: (style) Suspicious con
dition (assignment + comparison); Clarify expression with parentheses.
log.c:251]: (style) Suspicious con
dition (assignment + comparison); Clarify expression with parentheses.
Comment 1 Tim Wickberg 2018-12-05 10:50:12 MST
Hi David -

If you want to propose a patch to address these, I'm happy to review that as a contribution.

I haven't seen these specific warnings in the static analysis tool we're using - do you mind sharing which tool is generating those warnings?
Comment 2 David Binderman 2018-12-05 12:09:55 MST
(In reply to Tim Wickberg from comment #1)
> I haven't seen these specific warnings in the static analysis tool we're
> using - do you mind sharing which tool is generating those warnings?

cppcheck, available from sourceforge. I use it for all C/C++ development work.