This checker is validating suspicious usage of string compare functions.
Example:
if (strcmp(...)) // Implicitly compare to zero if (!strcmp(...)) // Won't warn if (strcmp(...) != 0) // Won't warn
This patch was checked over large amount of code.
There is three checks:
- Implicit comparator to zero (coding-style, many warnings found),
- Suspicious implicit cast to non-integral (bugs!?, almost none found),
- Comparison to suspicious constant (bugs!?, found two cases),
else if(strcmp(id, "select") == 0) { array->array[i].key1 = 25; } else if(strcmp(id, "sk") == 28) // BUG!? { array->array[i].key1 = 20; }
The variable is not const right now. I recently started preferring the constexpr char X[] = ... way of defining string constants.