BRL-CAD's sources are compiled with a number of build flags including numerous warning flags. By default, we treat all warnings as errors and we turn on nearly every warning that the compiler is capable of producing and then we fix them. When you do this systematically and consistently, it can greatly improve code quality. Help us improve BRL-CAD's code quality even more. We already compile with the following gcc/clang warning flags:
-pedantic -Wall -Wextra -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long -Wno-variadic-macros -Werror
This task involves enabling any new warning flag that is not already explicitly enabled or enabled by default, and then fixing the warnings that result.
Post a patch for review that enables the new flag, fixes at least one warning, and post a full build log (with "make -k" so we can get an estimate of how many issues need to be fixed).
You can enable the build flag by adding a CHECK_C_FLAG(your_flag_here) line in:
- misc/CMake/BRLCAD_CompilerFlags.cmake
Add your line after the "Wall" checks (search for Wall) similar to the numerous other flags being tested. Don't worry about setting it as a C++/CXX flag unless you're feeling adventurous. See the GCC or Clang manual page for a list of warning flags that can be enabled but some unconfirmed possibilities include:
- Wcast-qual
- Wredundant-decls
- Wunreachable-code
- Wmissing-declarations
- Wmissing-prototypes
- Wstrict-prototypes
- Wdocumentation (for Doxygen comments)
- Wfour-char-constants
- Wtraditional
- Wbad-function-cast
- Wc++-compat
- ... many many others ... really, see the GCC manpage and try enabling one
How to approach this task? Add your flag, make sure the build halts because something was detected, then run "make -k" to see just how many were detected. Then try to fix just one of them. If you are successful fixing one of them, submit your make -k log and a patch that fixes one and turns on the flag and get started on fixing the rest.
You'll be expected to fix some portion of the warnings reported, but this will be determined on a case-by-case basis depending on how complicated the warnings are and how many there are.
File name/URL | File size | Date submitted | |
---|---|---|---|
http://sourceforge.net/p/brlcad/patches/251/ | n/a | January 02 2014 07:12 UTC |
I would like to work on this task.
This task has been assigned to Shardul Chiplunkar. You have 144 hours to complete this task, good luck!
The work on this task is ready to be reviewed.
One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.
Shardul, this is looking like a good patch, but the build log you submitted is incomplete. If you would, re-submit the log here or regenerate the log. Note that you'll need to redirect stderr to get the warning messages that ensue:
make -k VERBOSE=1 build.log 21
Also, if unreachable code did not detect anything, do not enable it. It very well could already be enabled by default; you'd need to verify with certainty that it wasn't enabled prior. Still better to just focus on one flag.
The work on this task is ready to be reviewed.
Made the changes, and posted the [quite large] full build log. Is it OK?
Further confirmation, Wunreachable-code no longer does anything: http://gcc.gnu.org/ml/gcc-help/2011-05/msg00360.html
One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.
Patch applied cleanly, but the very first warning/error I encounter after compiling is a declaration mismatch (bu.h and rbinternals.h). That is, you fixed some issues and introduced others with your edits.
This needs to be a patch that can be applied to our sources and still compile cleanly, otherwise, we've made no progress. I realize this may be a fair bit of work for some warning flags, but just keep track of your time and let us know how long the task takes you.
The work on this task is ready to be reviewed.
It's almost all done except for some complicated pointers in src/libbu/rb_create.c which I can't understand. If you could help me with those, I could fix the warnings generated there.
? I haven't tested it. BTW, this are pointers to functions with return type int and no parameters.
One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.
How many errors (warnings) do I have to fix for this task to get accepted? Is it fine if there are warnings about strict-prototypes, but not about anything else; that is, if I don't exactly break anything?
The work on this task is ready to be reviewed.
The resulting build log consists of lots of Wstrict-prototype warnings. Should I fix more of them, or is the patch fine?
This looks like a sufficient quantity of fixes, but the build fails if your new flag is turned off. This means that you have mistakes or something is incomplete. Disable the flag you added in the cmake file and redo your build to see the errors.
Also, make sure you repost a build log with the flag turned ON with "make -k" ... don't forget the -k ;)
One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.
The work on this task is ready to be reviewed.
One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.
Shardul,
I've just spent several hours (yes, hours) reviewing and fixing your patch and there are simply too many issues to accept the patch without you fixing them. I'm working on applying a modified version of the patch, so you can review my upcoming commits to know what changes need to be made, but I encourage you to attempt the fixes yourself.
Here's a summary of some of the issues I've had to fix:
The work on this task is ready to be reviewed.
Saw the errors that occured last time with my patch, and also saw the patches that fixed them -- my earlier patch was quite a mess!
The patch submitted this time is straightforward and should not have any errors. The part I am not sure about is the warnings from the external libs (src/other), and the call to db_tree_funcleaf in db_match.c. Thanks!
Congratulations, this task has been completed successfully.
The updated patch looks much better. Nice work.
Your patch was applied in r59278. Your contributor status was graduated from special thanks (for your earlier documentation work) to code contributor status. Thank you for your efforts!