bugGPSD - Bugs: bug #44602, Incorrect arguments in NITEMS...

 
 

bug #44602: Incorrect arguments in NITEMS macro calls

Submitter:  Zbigniew Chyla <zchyla_nokia>
Submitted:  Sun 22 Mar 2015 07:48:46 PM 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
   

Sun 22 Mar 2015 07:55:02 PM UTC, comment #1: 

The attached patches fix the error and prevent similar errors in the future.


commit 012a1ac7ad59b427e4c32d9ece516f35af38d75a
Author: Zbigniew Chyla <zbigniew.chyla@nokia.com>
Date:   Sun Mar 22 21:51:45 2015 +0200

    Add compile-time check for arg type to NITEMS()

    If a pointer (not array) is passed to NITEMS() macro, gcc will emit
    compilation warning.
    The actual check is based on newly added COMPILE_CHECK_IS_ARRAY macro.

    The change doesn't affect generated binary code.

 2 files changed, 22 insertions(+), 1 deletion(-)

commit 4f27e8bc6131cd27d221932524f3614e6fdc4e07
Author: Zbigniew Chyla <zbigniew.chyla@nokia.com>
Date:   Sun Mar 22 21:51:45 2015 +0200

    Fix incorrect arguments in NITEMS macro calls

 1 file changed, 2 insertions(+), 2 deletions(-)



(file #33421, file #33422)

Zbigniew Chyla <zchyla_nokia>
Sun 22 Mar 2015 07:48:46 PM UTC, original submission:  

I've found two incorrect calls of NITEMS macro - instead of using an array as the macro's argument, the code uses first element of the array.


gpsd_json.c:1480:
#define NAVAIDTYPE_DISPLAY(n) (((n) < (unsigned int)NITEMS(navaid_type_legends[0])) ? navaid_type_legends[n] : "INVALID NAVAID TYPE")



gpsd_json.c:1501:
#define SIGNAL_DISPLAY(n) (((n) < (unsigned int)NITEMS(signal_legends[0])) ? signal_legends[n] : "INVALID SIGNAL TYPE")


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-06-03 esr Open/ClosedOpen Closed
    2015-03-22 esr StatusNone Fixed
        Assigned toNone esr
    2015-03-22 zchyla_nokia Attached File- Added 0001-Add-compile-time-check-for-arg-type-to-NITEMS.patch, #33421
        Attached File- Added 0002-Fix-incorrect-arguments-in-NITEMS-macro-calls.patch, #33422

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code