Compile with -Wstrict-prototypes, fix warnings that ensueBRL-CAD
Status: ClosedTime to complete: 72 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 -Wstrict-prototypes 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

Note that the majority of errors will be functions that take no arguments that weren't declared/defined as (void).  Be careful to not add a 'void' where it's actually an old kr empty argument declaration, though.  Submit you work as a single patch file, see http://brlcad.org/wiki/Patches

There are about 99 unique places in the code that need fixing.

Uploaded Work
File name/URLFile sizeDate submitted
prototypes.patch71.2 KBJanuary 14 2013 03:33 UTC
prototypes2.patch71.2 KBJanuary 15 2013 01:08 UTC
Comments
SB9595on December 20 2012 13:50 UTCTask Claimed

I would like to work on this task.

Sean on December 20 2012 13:53 UTCTask Assigned

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

SB9595on December 20 2012 13:58 UTCClaim Removed

The claim on this task has been removed, someone else can claim it now.

Sean on December 20 2012 14:01 UTCWhy?

Why would you do that?

javamonnon January 11 2013 00:06 UTCTask Claimed

I would like to work on this task.

Sean on January 11 2013 05:17 UTCTask Assigned

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

javamonnon January 14 2013 00:55 UTCWell...

Well, this task has taken me far longer than I had originally anticipated. I started with compiling with the -Wstrict-prototypes flag, and saved the warnings to a log. I then used a script to go through the log and change all the places where a warning was thrown and added in a void into the prototype, since I figured these were the vast majority of cases and that I could go back and do the final edits by hand.


For some reason, the vast majority of the cases are not that the prototypes lack a void in the definition, It seems like whoever coded some of these header files just got lazy. I'm having to go through and grep each function to find the original signature so I can correctly write the prototype. Note that this is certainly not hard work, just extremely tedious and time consuming. 


I've spent well over 10 hours on this so far, and I've worked my way up to ~70% compile. I don't think I'll be able to finish it in time with gci ending tommorow, but I'd be happy to submit what I have now as a proof of concept or whatever, and then submit the whole patch to the tracker later in the week. Let me know what you want me to do. 


Thanks,


Daniel

Melange on January 14 2013 05:17 UTCInitial Deadline passed

Melange has detected that the initial deadline has passed and it has set the task status to ActionNeeded. The student has 24 hours to submit the work before the task is reopened and sent back to the pool for other students to claim.

Daniel Rossberg on January 14 2013 09:05 UTCSet the task to needs review

if you think you did enough for a GCi task.

javamonnon January 14 2013 12:37 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on January 14 2013 13:13 UTCI'm getting the following compilation errors

with standard CMake generated make files (no -Wstrict-prototypes):


/home/rossberg/Devel/brlcad/src/libdm/tcl.c: In function ‘dm_validXType_tcl’:


/home/rossberg/Devel/brlcad/src/libdm/tcl.c:65:5: error: passing argument 1 of ‘dm_validXType’ discards ‘const’ qualifier from pointer target type [-Werror]


/home/rossberg/Devel/brlcad/src/libdm/tcl.c:41:12: note: expected ‘char *’ but argument is of type ‘const char *’


/home/rossberg/Devel/brlcad/src/libdm/tcl.c:65:5: error: passing argument 2 of ‘dm_validXType’ discards ‘const’ qualifier from pointer target type [-Werror]


/home/rossberg/Devel/brlcad/src/libdm/tcl.c:41:12: note: expected ‘char *’ but argument is of type ‘const char *’


 

Daniel Rossberg on January 14 2013 13:13 UTCTask Needs More Work

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.

Daniel Rossberg on January 14 2013 13:14 UTCDeadline extended

The deadline of the task has been extended with 1 days and 0 hours.

Sean on January 14 2013 14:17 UTCtwo hours remaining

Javamonn, Since there's only two hours remaining, go ahead and mark the task as needing review (again) so we can mark it complete.  We'll need to fix the const errors but I think you probably invested more than a couple hours on this task already.. :)


 

javamonnon January 15 2013 01:07 UTCReady for review

The work on this task is ready to be reviewed.

javamonnon January 15 2013 01:13 UTCRemoved that line

I removed the line from the patch that was causing the problem. It's still an old style prototype but at least it will compile now. I wasn't getting that error on my end, oddly enough.


Thanks for all the help though, with everything. The mentors for this project have been extremely helpful. GCI has been alot of fun. Whats the best way to stay involved, going forward? Is there somewhere where bugs or other requests for code changes and fixes are posted? I enjoy having something to do, and its a great exercise as far as getting better with C. 

Sean on January 15 2013 03:07 UTCTask Closed

Congratulations, this task has been completed successfully.