Skip to content

Commit

Permalink
Fix #12458 (checkers report: does not indicate misra checkers properl…
Browse files Browse the repository at this point in the history
…y) (#6302)
  • Loading branch information
danmar committed Apr 17, 2024
1 parent 3a212f1 commit 397464e
Show file tree
Hide file tree
Showing 6 changed files with 561 additions and 393 deletions.
8 changes: 8 additions & 0 deletions addons/cppcheckdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,14 @@ def is_suppressed(location, message, errorId):
return True
return False

def log_checker(message, addon):
if '--cli' in sys.argv:
msg = { 'addon': addon,
'severity': 'none',
'message': message,
'errorId': 'logChecker'}
sys.stdout.write(json.dumps(msg) + '\n')

def reportError(location, severity, message, addon, errorId, extra='', columnOverride=None):
if '--cli' in sys.argv:
msg = { 'file': location.file,
Expand Down
4 changes: 4 additions & 0 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -4489,6 +4489,10 @@ def executeCheck(self, rule_num, check_function, *args):
1901) # misra-c2012-19.1 : misra c++2008 2-13-3

if (not self.is_cpp) or rule_num in misra_cpp:
# log checker
errmsg = 'Misra C: %i.%i' % (rule_num // 100, rule_num % 100)
cppcheckdata.log_checker(errmsg, 'misra')

check_function(*args)

def parseDump(self, dumpfile, path_premium_addon=None):
Expand Down
4 changes: 2 additions & 2 deletions lib/checkbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ void CheckBufferOverrun::negativeIndexError(const Token* tok,

void CheckBufferOverrun::pointerArithmetic()
{
if (!mSettings->severity.isEnabled(Severity::portability))
if (!mSettings->severity.isEnabled(Severity::portability) && !mSettings->isPremiumEnabled("pointerOutOfBounds"))
return;

logChecker("CheckBufferOverrun::pointerArithmetic"); // portability
Expand Down Expand Up @@ -820,7 +820,7 @@ void CheckBufferOverrun::terminateStrncpyError(const Token *tok, const std::stri
void CheckBufferOverrun::argumentSize()
{
// Check '%type% x[10]' arguments
if (!mSettings->severity.isEnabled(Severity::warning))
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("argumentSize"))
return;

logChecker("CheckBufferOverrun::argumentSize"); // warning
Expand Down
Loading

0 comments on commit 397464e

Please sign in to comment.