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

Submitted by:  Vladimir Markelov <vvm>
Submitted on:  Fri 15 Jul 2016 02:25:58 AM UTC  
 
Category: ArithmeticSeverity: 2 - Minor
Item Group: Source codeStatus: Fixed
Privacy: PublicAssigned to: Vladimir Markelov <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>
Project Administrator
Wed 27 Jul 2016 04:13:25 AM UTC, comment #1:

I've replaced strlen with checking against NULL. Please see branch:
https://github.com/VladimirMarkelov/gnuastro-vvm/tree/redundant-strlen
Commit:
https://github.com/VladimirMarkelov/gnuastro-vvm/commit/98a2ce4b9e8de9856f2814db92007faeaf0c90c5

Vladimir Markelov <vvm>
Project MemberIn charge of this item.
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>
Project MemberIn charge of this item.

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 27 Jul 2016 12:46:31 PM UTCmakhlaghiStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Wed 27 Jul 2016 04:13:25 AM UTCvvmStatusNone=>In Progress

    Back to the top


    Powered by Savane 3.1-cleanup1