Questions tagged [cppcheck]

Cppcheck is an open source tool for static C/C++ code analysis that tries to detect bugs that a C/C++ compiler doesn't see.

Cppcheck - A tool for static C/C++ code analysis

Cppcheck is an analysis tool for C/C++ code. Unlike C/C++ compilers and many other analysis tools, we don't detect syntax errors. Cppcheck only detects the types of bugs that the compilers normally fail to detect. The goal is no false positives.

331 questions
0
votes
0 answers

how git get the cppcheck report

Firstly, Cppcheck checks code will come out a result which stored in a file. In Git, the file is in everyone's local computer because Git is a distributed system, Now we want to collect the files and analyze the files. But we don't know how to…
0
votes
1 answer

Can we add/remove coding standards to CppCheck?

Can we add some of the coding standards which is not defined in Cppheck, or can we remove some of the coding standards defined in Cpppcheck which i does not want to check.
Dinesh Kumar
  • 131
  • 10
-1
votes
1 answer

CPP Guessing Game not working, its stops after i enter the name

I'm trying to make this kina guess game on C++, I'm a beginner and still learning. What I'm trying to achieve is a guessing game of two const names, is very simple without errors but it's not working after I enter something. it should report until I…
-1
votes
1 answer

My global function cannot access the private data member, even after using friend function

Cannot access the private member 'b'. This was a test problem and I can only edit a limited number of lines. This was a simple addition program, with the 3 lines highlighted by '//' left empty, this was my solution to the problem. But I am facing…
-1
votes
2 answers

cppcheck format string on member functions of C++

aa.h #ifndef __US_LOG_FILEA_H_ #define __US_LOG_FILEA_H_ namespace AA{ class A{ public: A(); ~A(); static A& Ins(){ static A obj; return obj; } void do_p(const char *cat, int level, const char *Format ...); //…
Leo
  • 21
  • 2
-1
votes
1 answer

Static Code Analysis tool (like CppCheck) versus Setting compiler warnings to a stricter level

[This is a more general question and banks upon the experience with both setting the compiler options and usage of static code analysis tools.] Currently, I use the -Werror to flag all warning as errors during compilation. I am planning on using the…
-1
votes
1 answer

cppcheck detects a resource leak - a false negative?

cppcheck detects a resorce leak in the code below. I think it is a fals negative. If not, can you explaint to me why it is a resource leak? bool fileExists(const char* filename) { FILE* fp = fopen(filename, "r"); bool result = (fp != NULL); …
jkabutz
  • 15
  • 5
-1
votes
1 answer

Memcpy and const correctness

When using cppcheck on my code it indicated a function could be made const. Cppcheck seems to be correct but I found the memcpy in the code strange. Excerpt from the code: if ( (offset + size) <= _bufferSize ) { char* _destPtr…
refro
  • 209
  • 1
  • 7
-1
votes
2 answers

CppCheck does not detect memory leak

Have following code, but CppCheck(1.68) detects only "style" error. AbstractTelegram *TelegramFactory::CreateGetWigWagParameterTelegram(BYTE Address_i, BYTE SubAddress_i, BYTE Tag_i) { SignDataWigWag *pWigWag = new SignDataWigWag(); …
blackhearted
  • 27
  • 1
  • 5
-2
votes
3 answers

composition of classes in c++

This is an example of the composition of classes. But my code doesn't show a correct answer. This program must calculate the length of the line segment in the coordinates of the two ends of the line segment! I don't know what to do in the main…
-2
votes
1 answer

scanf() without field width limits can crash with huge input data

So basically i want to input data in this way for example " string:%d:%d:%d ", if i use " %s:%d:%d:%d " it cant stop scanning the string until it finds a white space, but if i use this " %[^:]:%d:%d:%d " its works but i get an error using cppcheck…
Martim Correia
  • 385
  • 1
  • 6
-2
votes
1 answer

Why the string is not getting updated and doesn't print anything in the end

CODE: #include using namespace std; int main() { string message, rMessage; getline(cin,message); for(int i=0;i='a' && message[i]<='z') || (message[i]>='A' && message[i]<='Z') || …
-2
votes
2 answers

cppcheck null pointer dereference, but it can actually become null

I have a function that can return a pointer to a structure or NULL (Example to explain return possibilities of get_my_struct_from_[X] functions): struct my_struct *my_function(my_struct i) { if (i.value < 5) return i; else return NULL; } In…
Czoka
  • 118
  • 3
  • 12
-4
votes
1 answer

Segment Fault 11

I'm getting an error for Segment fault 11. It will run through the printall()command but seems to fail at the printInvalidEmail command. I can also input the other classes I have created. I have about 6 different classes and header files for the…
kayla
  • 1
-4
votes
1 answer

How to make cppcheck stop on error

I use cppcheck to look for errors. now I'm looking for a way the stop the cppcheck run after he found the first error. Thanks for your help.
jonyR
  • 7
  • 1
1 2 3
22
23