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.
The KDE 'Krazy' Checker
KDE developers have a simple set of tests that are collectively known as "Krazy". These tests were originally developed to be run as part of a larger set of tests on a machine known as http://www.englishbreakfastnetwork.org, or EBN for short. You can see the results of running the various tests on EBN (at ).
You can also run the tests yourself. To do this, you need to obtain a copy of the code (from the kdesdk module, in ebn/krazy) and install them. You can then test either a single file (using the krazy application) or a whole tree, including subdirectories (using the krazyall application).
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).