bugGPSD - Bugs: bug #43986, gpsd uses magic numbers and...

 
 

bug #43986: gpsd uses magic numbers and redundant expressions instead of sizeof operator

Submitter:  Zbigniew Chyla <zchyla_nokia>
Submitted:  Mon 12 Jan 2015 09:07:45 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  esr
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 12 Jan 2015 09:10:18 AM UTC, comment #1: 

I've split the fixes into two groups:

  • the first patch modifies source code (by using sizeof) but doesn't affect generated binary code (thus making it easy to verify),
  • the second patch does modify binary code, but contains only single change (an array in question is VLA).



(file #32807, file #32808)

Zbigniew Chyla <zchyla_nokia>
Mon 12 Jan 2015 09:07:45 AM UTC, original submission:  

I've found several places in the gpsd code where an array size is referred to by using an expression copied from the array's definition (usually a number or macro such as BUFSIZ) instead of "sizeof" operator. This is a bad practice, as it'll cause subtle errors if the array's size changes.

Zbigniew Chyla <zchyla_nokia>

 

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

Attach Files:
   
   
Comment:
   

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by esr (Updated the item)
  • -email is unavailable- added by zchyla_nokia (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.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-02-22 esr Open/ClosedOpen Closed
    2015-01-13 esr StatusNone Fixed
        Assigned toNone esr
    2015-01-12 zchyla_nokia Attached File- Added 0001-Always-use-sizeof-to-get-array-size.patch, #32807
        Attached File- Added 0002-Always-use-sizeof-to-get-array-size-part-2.patch, #32808

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code