Checks for invalid increment *count++. For example following function: void increment_counter(int* count) { *count++; } is invalid, because it effectively does count++, moving pointer, and should be replaced with ++*count, (*count)++ or *count += 1. Args: filename: The name of
(filename, clean_lines, linenum, error)
| 2167 | |
| 2168 | |
| 2169 | def CheckInvalidIncrement(filename, clean_lines, linenum, error): |
| 2170 | """Checks for invalid increment *count++. |
| 2171 | |
| 2172 | For example following function: |
| 2173 | void increment_counter(int* count) { |
| 2174 | *count++; |
| 2175 | } |
| 2176 | is invalid, because it effectively does count++, moving pointer, and should |
| 2177 | be replaced with ++*count, (*count)++ or *count += 1. |
| 2178 | |
| 2179 | Args: |
| 2180 | filename: The name of the current file. |
| 2181 | clean_lines: A CleansedLines instance containing the file. |
| 2182 | linenum: The number of the line to check. |
| 2183 | error: The function to call with any errors found. |
| 2184 | """ |
| 2185 | line = clean_lines.elided[linenum] |
| 2186 | if _RE_PATTERN_INVALID_INCREMENT.match(line): |
| 2187 | error(filename, linenum, 'runtime/invalid_increment', 5, |
| 2188 | 'Changing pointer instead of value (or unused value of operator*).') |
| 2189 | |
| 2190 | |
| 2191 | def IsMacroDefinition(clean_lines, linenum): |
no outgoing calls
no test coverage detected
searching dependent graphs…