MCPcopy Create free account
hub / github.com/apache/mesos / CheckInvalidIncrement

Function CheckInvalidIncrement

support/cpplint.py:2174–2193  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

ProcessLineFunction · 0.85

Calls 2

errorFunction · 0.85
matchMethod · 0.80

Tested by

no test coverage detected