Reduce duplicate code in htonf.cBRL-CAD
Status: ClosedTime to complete: 48 hrs Mentors: Sean, Andrei PopescuTags: C, refactoring


BRL-CAD is more than one million lines of source code and keeping that much code clean is a never-ending task.  Keeping maintenance costs low requires consistent attention on improving code quality.  One great way to improve code quality is to reduce the amount of duplication.

This task involves creating a static inline function named convert_float(). Since you will modify an existing file, you need to write the function in C.  It should have the same functionality as the duplicated code in our htonf() and ntonf() functions. 

References:

  • http://www.greenend.org.uk/rjk/tech/inline.html - About inline functions.

Code:

  • brlcad/src/libbu/htonf.c

Contact andrei on #brlcad on irc.freenode.net if you need help on this task.


Uploaded Work
File name/URLFile sizeDate submitted
htonf.c2.3 KBDecember 03 2012 13:19 UTC
htonf.patch2.4 KBDecember 03 2012 17:20 UTC
htonf_2.patch2.4 KBDecember 03 2012 17:24 UTC
htonf_3.diff2.5 KBDecember 03 2012 22:07 UTC
htonf4.patch3.3 KBDecember 04 2012 13:18 UTC
htonf_5.patch1.7 KBDecember 05 2012 16:29 UTC
Comments
Shomiron Ghoseon December 3 2012 07:54 UTCTask Claimed

I would like to work on this task.

Daniel Rossberg on December 3 2012 08:08 UTCTask Assigned

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

Shomiron Ghoseon December 3 2012 13:24 UTCReady for review

The work on this task is ready to be reviewed.

Shomiron Ghoseon December 3 2012 13:25 UTCnot sure

I am 40% sure that is right. please check. if not i'll redo it.

Daniel Rossberg on December 3 2012 16:19 UTCSome things to improve

- provide a patch file


- see "1) Indentation whitespace" in Hacking for the right indentation


- use HIDDEN instead of inline


- you don't need to provide an extra prototype if the definition precedes the usage

Daniel Rossberg on December 3 2012 16:20 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.

Shomiron Ghoseon December 3 2012 17:24 UTCReady for review

The work on this task is ready to be reviewed.

Andrei Popescu on December 3 2012 20:25 UTCIssues

Issues have been discussed on IRC.

Andrei Popescu on December 3 2012 20:25 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.

Shomiron Ghoseon December 3 2012 22:07 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 4 2012 06:57 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.

Sean on December 4 2012 07:03 UTCnon-conformant style

Thanks for your efforts but the latest patch still has style conformancy problems.  See our HACKING file at the top-level of our source distribution for details, but basically the indentation is inconsistent in some places, wrong in others, and and you have an opening brace that is wrong.  See the footer for settings that can be automatically applied if you're using the emacs or vim editors.  Those same settings can be set up in MSVC, Eclipse, and most any other development environment so the file is automatically formatted if recognizing and fixing all of the issues manually is frustrating.


 

Shomiron Ghoseon December 4 2012 13:19 UTCNow?

Ok i used vim and to the best of my knowledge used the Hacking guide. the only thing that would be possibly non-compliant is the switch statement since it is not addressed in the hacking guide explicitly - i lined it up with the function statement as it is not specifically a function as per http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/HACKING?revision=HEAD section 3 braces.

Shomiron Ghoseon December 4 2012 13:19 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 4 2012 21:19 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.

Sean on December 4 2012 21:23 UTCstill not conformant

If you're using vim, you should be able to ":set modeline" to have it parse our footer, then you can auto-indent the entire file.  Note the body of the two functions, for example -- you do not indent the convert_float() calls and they should be.  Similarly, your latest version of convert_float() uses tabs and spaces inconsistently.  The indentations levels should be 4s spaces, 1 tab, 1 tab plus 4 spaces, 2 tabs, 2 tabs + 4 spaces, etc.


 

Sean on December 4 2012 21:24 UTCDeadline extended

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

Shomiron Ghoseon December 5 2012 16:29 UTCnow?

Used vim, when i opened it i typed :set modeline in the command area.


then i did it. Counted indents. They're via the levels you said above.


the convention of


function type


function name + declaration 


was used in the other files in libbu


 


so what about now? _

Shomiron Ghoseon December 5 2012 16:30 UTCReady for review

The work on this task is ready to be reviewed.

Melange on December 6 2012 00:46 UTCNo more Work can be submitted

Melange has detected that the deadline has passed and no more work can be submitted. The submitted work should be reviewed.

Sean on December 6 2012 06:13 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on December 6 2012 06:15 UTCthat looks better

That looks much better.  Thank you!  Hopefully the modeline feature will help you if you contribute other patches (lots of open source projects have a modeline defined).


We'll credit your name in our authorship documentation with this contribution, thanks again for working through the problems.

Shomiron Ghoseon December 6 2012 06:17 UTCResponse

THANK YOU! :) Are you on IRC?

Sean on January 14 2013 14:51 UTCthank you

As GCI comes to a close, we wanted to take the time to say THANK YOU for all your efforts.  This comment interface closes after GCI is over, so you're encouraged to join our mailing list where we'll be announcing contributions from GCI participants like yourelf over the upcoming months: 


https://lists.sourceforge.net/lists/listinfo/brlcad-news


If you've provided your full name, we'll be sure to credit you in our authorship documentation and you'll see your name in a future announcement.  If you contact us at devs@brlcad.org or via IRC, we'll even let you know when your work is integrated and follow up with updates.  You're welcome and encouraged to contact us any time, especially if you have a question about how to continue participating in Open Source after GCI is over, but even if just to keep in touch.  Note that ongoing participation in Open Source is one of the most impressive skills to have on your resumé.  Take care, be well, and thank you again!