bugGNU Astronomy Utilities - Bugs: bug #48517, Redundant call to strlen

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #48517: Redundant call to strlen

Submitter:  Vladimir Markelov <vvm>
Submitted:  Fri 15 Jul 2016 02:25:58 AM UTC
   
 
Category:  Arithmetic Severity:  2 - Minor
Item Group:  Source code Status:  Fixed
Privacy:  Public Assigned to:  vvm
Open/Closed:  Closed

Wed 27 Jul 2016 12:46:31 PM UTC, comment #2: 

Thanks, the fix has been merged with master and pushed to the main repo.

Mohammad Akhlaghi <makhlaghi>
Group administrator
Wed 27 Jul 2016 04:13:25 AM UTC, comment #1: 
Vladimir Markelov <vvm>
Fri 15 Jul 2016 02:25:58 AM UTC, original submission:  

Example for add_operand function
src/arithmetic/arithmetic.c
77 if(strlen(filename) && gal_fits_name_is_fits(filename))

a. The first thing that gal_fits_name_is_fits does is getting length of filename. So extra call to strlen does nothing besides a slight performance decrease
b. Right now I see add_operand called only once and filename is macro that equals "". But if in the future add_operand gets arguments from another place, it is possible that filename is NULL and strlen crashes the application

I suggest to change the line to:
77 if(filename && gal_fits_name_is_fits(filename))

Vladimir Markelov <vvm>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by makhlaghi (Posted a comment)
  • -email is unavailable- added by vvm (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-27 makhlaghi StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2016-07-27 vvm StatusNone In Progress

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code