Compile with -Wold-style-definition, fix warnings that ensueBRL-CAD
Status: ClosedTime to complete: 48 hrs Mentors: SeanTags: compile, warnings, C, C++, code quality

We hold BRL-CAD to a rather high standard of code quality.  We compile with nearly every useful warning that GCC is capable of producing and consider all warnings as errors that stop compilation.  This is done because many/most warnings are "code smells" that are eventually usually costly to ignore over time.

This task involves adding the -Wold-style-definition warning to our compilation and fixing the issues that result.  You can add the flag by editing misc/CMake/BRLCAD_CompilerFlags.cmake

Make sure you compile cleanly before beginning.  Make sure you're using a fresh SVN checkout.  See http://brlcad.org/wiki/Compiling for help.

Protip: run this to save all errors to a file so you can work on them in bulk: make -k 21 | tee build.log

Submit you work as a single patch file, see http://brlcad.org/wiki/Patches

 

Uploaded Work
File name/URLFile sizeDate submitted
Wold-style-definition.patch54.6 KBDecember 27 2012 04:13 UTC
Comments
javamonnon December 25 2012 04:31 UTCTask Claimed

I would like to work on this task.

Sean on December 25 2012 06:20 UTCTask Assigned

This task has been assigned to javamonn. You have 48 hours to complete this task, good luck!

javamonnon December 27 2012 04:13 UTCReady for review

The work on this task is ready to be reviewed.

javamonnon December 27 2012 04:15 UTCA couple notes:

I was able to fix all warnings except for one function in termio.c. I couldn't figure out what type to set the parameters and still retain the portability, since C doesn't allow for overloading. I left it how it was. Let me know if I need to make any other changes.


Thanks,


Daniel

Sean on December 27 2012 05:08 UTCWhat issue?

What issue in termio?  Can you also provide the compilation log?  Thanks!

Sean on December 27 2012 05:12 UTCTask Closed

Congratulations, this task has been completed successfully.

javamonnon December 28 2012 05:10 UTCWhere do I submit?

Where can I submit the build log, and also a revised patch? I made a couple tweaks to the patch, it wouldn't compile before apparently. As far as termio, it has two functions in which the parameter types are system dependent. In the old c fasion, it was defined:


static void


copy_Tio(to, from)


#ifdef BSD


    struct sgttyb *to, *from;


#endif


#ifdef SYSV


    struct termio *to, *from;


#endif


#ifdef HAVE_TERMIOS_H


    struct termios *to, *from;


#endif


{


//function body


}


Now, im unsure as to how to convert this into a single method signature so it doesn't throw a warning? I mean you could use a void pointer and just cast it, but it still throws a warning. Could a union possibly be used for this?


 

Sean on December 28 2012 08:38 UTCsourceforge

You can submit your updated files to our Sourceforget patches tracker and just leave a comment here with the URL.  You can attach files to the tracker item you create.


As for the crazy ifdef logic, just create three copies of the copy_Tio() declaration line protected by the same/similar three ifdefs.