There are a lot of ways to find bugs in KDE code. Increasingly, KDE developers have started to use automated tools. You can use some of those tools to improve your own code.
KDE developers have a simple set of tests that are collectively known as "Krazy".
The Krazy tests are designed to minimise false positives (that is, alerts that do not represent real problems). However because most of the tests are conducted on a single line, there are some tests that might produce such a false positive. For example, code that does something like:
mystring += "/";
will be flagged by the doublequote_chars checker, because it is more efficient to add a single char, as shown below:
// note that we are using single quotes - this is a char, not a char array
mystring += '/';
That same checker will produce a false positive for code that looks like:
mystring += "/";
You can suppress these false positives using a special comment format. To exclude a particular plugin from being run on a line of code, simply add a C++ comment containing the string "krazy:exclude=<plugin_name>".
Specifically, for this plugin use "krazy:exclude=doublequote_chars".
lenstr = "0" + lenstr;
lenstr = "0" + lenstr; // krazy:exclude=doublequote_chars
In addition to the various Krazy tools, you can also get valuable assistance from the warnings that the compiler emits, especially if you enable additional warnings (per the documentation for your compiler), and also if you test with more than one compiler (e.g. if you can test on Linux with both GCC and the Intel compiler; or on Linux with GCC and also on Windows with the Microsoft compiler).