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

 
 

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

Submitted by:  Zbigniew Chyla <zchyla_nokia>
Submitted on:  Mon 12 Jan 2015 09:07:45 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: Eric S. Raymond <esr>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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 File(s):
   
   
Comment:
   

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 22 Feb 2015 05:03:18 PM UTCesrOpen/ClosedOpen=>Closed
    Tue 13 Jan 2015 12:25:57 PM UTCesrStatusNone=>Fixed
      Assigned toNone=>esr
    Mon 12 Jan 2015 09:10:18 AM UTCzchyla_nokiaAttached 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.1-cleanup1