gnuastro-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-devel] [bug #48517] Redundant call to strlen


From: Vladimir Markelov
Subject: [gnuastro-devel] [bug #48517] Redundant call to strlen
Date: Fri, 15 Jul 2016 02:26:01 +0000 (UTC)
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0

URL:
  <http://savannah.gnu.org/bugs/?48517>

                 Summary: Redundant call to strlen
                 Project: GNU Astronomy Utilities
            Submitted by: vvm
            Submitted on: Thu 14 Jul 2016 07:25:58 PM PDT
                Category: Arithmetic
                Severity: 2 - Minor
              Item Group: Source code
                  Status: None
                 Privacy: Public
             Assigned to: vvm
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

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))




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48517>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]