From 980dbf59b6b864d90eee122936a4c8ec484f948d Mon Sep 17 00:00:00 2001 From: Bhavna Sharma Date: Tue, 2 Apr 2019 14:20:36 -0700 Subject: Fix to use explicit sized structures Cross processor communication needs explicit sized structures. Avoid using platform defined values like size_t which may vary from 32-bit to 64-bit. Also use explicitly defined timespec32_t structure that will only use uint32_t fields. CRs-Fixed: 2428163 Change-Id: Ida72f53ac672d9c9b86879bb9861cecefe6f8c6d --- gnss/GnssAdapter.cpp | 2 +- utils/gps_extended_c.h | 43 ++++++++++++++++++++++++------------------- utils/loc_gps.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp index 8e1bf5f..0775c2a 100644 --- a/gnss/GnssAdapter.cpp +++ b/gnss/GnssAdapter.cpp @@ -1636,7 +1636,7 @@ GnssAdapter::gnssSvTypeConfigUpdate(const GnssSvTypeConfig& config) void GnssAdapter::gnssSvTypeConfigUpdate(bool sendReset) { - LOC_LOGd("size %zu constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64 + LOC_LOGd("size %" PRIu32" constellations blacklisted 0x%" PRIx64 ", enabled 0x%" PRIx64 ", sendReset %d", mGnssSvTypeConfig.size, mGnssSvTypeConfig.blacklistedSvTypesMask, mGnssSvTypeConfig.enabledSvTypesMask, sendReset); diff --git a/utils/gps_extended_c.h b/utils/gps_extended_c.h index 9f4c13c..9c63166 100644 --- a/utils/gps_extended_c.h +++ b/utils/gps_extended_c.h @@ -35,7 +35,12 @@ #include #include #include -#include + +struct timespec32_t { + uint32_t tv_sec; /* seconds */ + uint32_t tv_nsec; /* and nanoseconds */ +}; + /** * @file @@ -132,7 +137,7 @@ typedef enum { typedef struct { /** set to sizeof(UlpLocation) */ - size_t size; + uint32_t size; LocGpsLocation gpsLocation; /* Provider indicator for HYBRID or GPS */ uint16_t position_source; @@ -142,7 +147,7 @@ typedef struct { typedef struct { /** set to sizeof(UlpNmea) */ - size_t size; + uint32_t size; char nmea_str[ULP_MAX_NMEA_STRING_SIZE]; unsigned int len; } UlpNmea; @@ -208,7 +213,7 @@ typedef struct { /** GPS extended callback structure. */ typedef struct { /** set to sizeof(LocGpsCallbacks) */ - size_t size; + uint32_t size; loc_gps_set_capabilities set_capabilities_cb; loc_gps_acquire_wakelock acquire_wakelock_cb; loc_gps_release_wakelock release_wakelock_cb; @@ -232,7 +237,7 @@ typedef struct { /** Represents the status of AGPS. */ typedef struct { /** set to sizeof(AGpsExtStatus) */ - size_t size; + uint32_t size; AGpsExtType type; LocAGpsStatusValue status; @@ -458,7 +463,7 @@ typedef enum { }LocReliability; typedef struct { - struct timespec apTimeStamp; + struct timespec32_t apTimeStamp; /*boottime received from pps-ktimer*/ float apTimeStampUncertaintyMs; /* timestamp uncertainty in milli seconds */ @@ -685,7 +690,7 @@ typedef struct { /** Represents gps location extended. */ typedef struct { /** set to sizeof(GpsLocationExtended) */ - size_t size; + uint32_t size; /** Contains GpsLocationExtendedFlags bits. */ uint64_t flags; /** Contains the Altitude wrt mean sea level */ @@ -1058,7 +1063,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; float clockDrift; /**< Receiver clock Drift \n - Units: meter per sec \n @@ -1072,7 +1077,7 @@ typedef struct typedef struct { - size_t size; + uint32_t size; uint8_t leapSec; /**< GPS time leap second delta to UTC time \n - Units: sec \n @@ -1093,7 +1098,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; uint32_t validMask; /* Validity mask as per Gnss_LocInterSystemBiasValidMaskType */ @@ -1110,7 +1115,7 @@ typedef struct typedef struct { - size_t size; + uint32_t size; uint8_t systemRtc_valid; /**< Validity indicator for System RTC */ @@ -1156,7 +1161,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; uint32_t svMs; /**< Satellite time milisecond.\n For GPS, BDS, GAL range of 0 thru (604800000-1) \n @@ -1216,7 +1221,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; Gnss_LocSvSystemEnumType gnssSystem; // 0 signal type mask indicates invalid value GnssSignalTypeMask gnssSignalTypeMask; @@ -1389,7 +1394,7 @@ typedef uint64_t GpsSvMeasHeaderFlags; typedef struct { - size_t size; + uint32_t size; // see defines in GNSS_SV_MEAS_HEADER_HAS_XXX_XXX uint64_t flags; @@ -1433,7 +1438,7 @@ typedef struct } GnssSvMeasurementHeader; typedef struct { - size_t size; + uint32_t size; bool isNhz; GnssSvMeasurementHeader svMeasSetHeader; uint32_t svMeasCount; @@ -1473,7 +1478,7 @@ typedef enum typedef struct { - size_t size; + uint32_t size; uint16_t gnssSvId; /* GPS: 1-32, GLO: 65-96, 0: Invalid, SBAS: 120-151, BDS:201-237,GAL:301 to 336 @@ -2034,7 +2039,7 @@ typedef enum { typedef struct { - size_t size; + uint32_t size; Gnss_SrnTech srnTechType; /* SRN Technology type in request */ bool srnRequest; /* scan - start(true) or stop(false) */ bool e911Mode; /* If in E911 emergency */ @@ -2054,7 +2059,7 @@ typedef enum { /* This SV Type config is injected directly to GNSS Adapter * bypassing Location API */ typedef struct { - size_t size; // set to sizeof(GnssSvTypeConfig) + uint32_t size; // set to sizeof(GnssSvTypeConfig) // Enabled Constellations GnssSvTypesMask enabledSvTypesMask; // Disabled Constellations @@ -2141,7 +2146,7 @@ enum OdcpiRequestType { ODCPI_REQUEST_TYPE_STOP }; struct OdcpiRequestInfo { - size_t size; + uint32_t size; OdcpiRequestType type; uint32_t tbfMillis; bool isEmergencyMode; diff --git a/utils/loc_gps.h b/utils/loc_gps.h index b58f20b..eae7383 100644 --- a/utils/loc_gps.h +++ b/utils/loc_gps.h @@ -548,7 +548,7 @@ typedef uint8_t LocGnssConstellationType; /** Represents a location. */ typedef struct { /** set to sizeof(LocGpsLocation) */ - size_t size; + uint32_t size; /** Contains LocGpsLocationFlags bits. */ uint16_t flags; /** The spoof mask */ -- cgit v1.2.3