GeneralPurpose-StringPointerEquality¶
Use strcmp() or similar functions when comparing strings, do not compare using ==
Required inputs: IR
== or != to compare strings.
Example
char* s;
if ("Hello" != s) {} // bad
if (!strcmp(s, "Hello")) {} // good
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
string_equality_comparison |
String comparison with ==; did you mean to compare the address, or was a comparison with strcmp() intended? |
None |
False |
string_literal_equality_comparison |
String comparison with ==; did you mean to compare the address, or was a comparison with strcmp() intended? |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
report_all_char_pointer¶
report_all_char_pointer : bool = False
== on arbitrary (const)char*
expressions should be reported.