"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/checksizeof.h" between
cppcheck-1.86.tar.gz and cppcheck-1.87.tar.gz

About: Cppcheck is a static analysis tool for C/C++ code. It checks for memory leaks, mismatching allocation-deallocation, buffer overrun, and many more.

checksizeof.h  (cppcheck-1.86):checksizeof.h  (cppcheck-1.87)
/* /*
* Cppcheck - A tool for static C/C++ code analysis * Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2018 Cppcheck team. * Copyright (C) 2007-2019 Cppcheck team.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 51 skipping to change at line 51
/** @brief This constructor is used when registering the CheckClass */ /** @brief This constructor is used when registering the CheckClass */
CheckSizeof() : Check(myName()) { CheckSizeof() : Check(myName()) {
} }
/** @brief This constructor is used when running checks. */ /** @brief This constructor is used when running checks. */
CheckSizeof(const Tokenizer* tokenizer, const Settings* settings, ErrorLogge r* errorLogger) CheckSizeof(const Tokenizer* tokenizer, const Settings* settings, ErrorLogge r* errorLogger)
: Check(myName(), tokenizer, settings, errorLogger) { : Check(myName(), tokenizer, settings, errorLogger) {
} }
/** @brief Run checks against the normal token list */ /** @brief Run checks against the normal token list */
void runChecks(const Tokenizer* tokenizer, const Settings* settings, ErrorLo gger* errorLogger) override { void runChecks(const Tokenizer* tokenizer, const Settings* settings, ErrorLo gger* errorLogger) OVERRIDE {
CheckSizeof checkSizeof(tokenizer, settings, errorLogger); CheckSizeof checkSizeof(tokenizer, settings, errorLogger);
// Checks // Checks
checkSizeof.sizeofsizeof(); checkSizeof.sizeofsizeof();
checkSizeof.sizeofCalculation(); checkSizeof.sizeofCalculation();
checkSizeof.sizeofFunction(); checkSizeof.sizeofFunction();
checkSizeof.suspiciousSizeofCalculation(); checkSizeof.suspiciousSizeofCalculation();
checkSizeof.checkSizeofForArrayParameter(); checkSizeof.checkSizeofForArrayParameter();
checkSizeof.checkSizeofForPointerSize(); checkSizeof.checkSizeofForPointerSize();
checkSizeof.checkSizeofForNumericParameter(); checkSizeof.checkSizeofForNumericParameter();
checkSizeof.sizeofVoid(); checkSizeof.sizeofVoid();
} }
/** @brief Run checks against the simplified token list */ /** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer* /*tokenizer*/, const Settings* /*s ettings*/, ErrorLogger* /*errorLogger*/) override { void runSimplifiedChecks(const Tokenizer* /*tokenizer*/, const Settings* /*s ettings*/, ErrorLogger* /*errorLogger*/) OVERRIDE {
} }
/** @brief %Check for 'sizeof sizeof ..' */ /** @brief %Check for 'sizeof sizeof ..' */
void sizeofsizeof(); void sizeofsizeof();
/** @brief %Check for calculations inside sizeof */ /** @brief %Check for calculations inside sizeof */
void sizeofCalculation(); void sizeofCalculation();
/** @brief %Check for function call inside sizeof */ /** @brief %Check for function call inside sizeof */
void sizeofFunction(); void sizeofFunction();
skipping to change at line 108 skipping to change at line 108
void multiplySizeofError(const Token* tok); void multiplySizeofError(const Token* tok);
void divideSizeofError(const Token* tok); void divideSizeofError(const Token* tok);
void sizeofForArrayParameterError(const Token* tok); void sizeofForArrayParameterError(const Token* tok);
void sizeofForPointerError(const Token* tok, const std::string &varname); void sizeofForPointerError(const Token* tok, const std::string &varname);
void divideBySizeofError(const Token* tok, const std::string &memfunc); void divideBySizeofError(const Token* tok, const std::string &memfunc);
void sizeofForNumericParameterError(const Token* tok); void sizeofForNumericParameterError(const Token* tok);
void sizeofVoidError(const Token *tok); void sizeofVoidError(const Token *tok);
void sizeofDereferencedVoidPointerError(const Token *tok, const std::string &varname); void sizeofDereferencedVoidPointerError(const Token *tok, const std::string &varname);
void arithOperationsOnVoidPointerError(const Token* tok, const std::string & varname, const std::string &vartype); void arithOperationsOnVoidPointerError(const Token* tok, const std::string & varname, const std::string &vartype);
void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) co nst override { void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) co nst OVERRIDE {
CheckSizeof c(nullptr, settings, errorLogger); CheckSizeof c(nullptr, settings, errorLogger);
c.sizeofForArrayParameterError(nullptr); c.sizeofForArrayParameterError(nullptr);
c.sizeofForPointerError(nullptr, "varname"); c.sizeofForPointerError(nullptr, "varname");
c.divideBySizeofError(nullptr, "memset"); c.divideBySizeofError(nullptr, "memset");
c.sizeofForNumericParameterError(nullptr); c.sizeofForNumericParameterError(nullptr);
c.sizeofsizeofError(nullptr); c.sizeofsizeofError(nullptr);
c.sizeofCalculationError(nullptr, false); c.sizeofCalculationError(nullptr, false);
c.sizeofFunctionError(nullptr); c.sizeofFunctionError(nullptr);
c.multiplySizeofError(nullptr); c.multiplySizeofError(nullptr);
c.divideSizeofError(nullptr); c.divideSizeofError(nullptr);
c.sizeofVoidError(nullptr); c.sizeofVoidError(nullptr);
c.sizeofDereferencedVoidPointerError(nullptr, "varname"); c.sizeofDereferencedVoidPointerError(nullptr, "varname");
c.arithOperationsOnVoidPointerError(nullptr, "varname", "vartype"); c.arithOperationsOnVoidPointerError(nullptr, "varname", "vartype");
} }
static std::string myName() { static std::string myName() {
return "Sizeof"; return "Sizeof";
} }
std::string classInfo() const override { std::string classInfo() const OVERRIDE {
return "sizeof() usage checks\n" return "sizeof() usage checks\n"
"- sizeof for array given as function argument\n" "- sizeof for array given as function argument\n"
"- sizeof for numeric given as function argument\n" "- sizeof for numeric given as function argument\n"
"- using sizeof(pointer) instead of the size of pointed data\n" "- using sizeof(pointer) instead of the size of pointed data\n"
"- look for 'sizeof sizeof ..'\n" "- look for 'sizeof sizeof ..'\n"
"- look for calculations inside sizeof()\n" "- look for calculations inside sizeof()\n"
"- look for function calls inside sizeof()\n" "- look for function calls inside sizeof()\n"
"- look for suspicious calculations with sizeof()\n" "- look for suspicious calculations with sizeof()\n"
"- using 'sizeof(void)' which is undefined\n"; "- using 'sizeof(void)' which is undefined\n";
} }
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)