From fa75e9d2dea4ed97dae78836b2044160fa36a652 Mon Sep 17 00:00:00 2001 From: Nitin Kumbhar Date: Tue, 21 Jan 2020 17:00:46 +0530 Subject: [PATCH] gpu: nvgpu: add checks for sizes of data types Check sizes of the data types considered as "same types" in the CERT-C EXP37-C deviation record. JIRA NVGPU-3561 Change-Id: I99c0da1adfee6c4809aa1439e67aae57baa2642d Signed-off-by: Nitin Kumbhar Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2282951 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- .../gpu/nvgpu/include/nvgpu/static_analysis.h | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpu/nvgpu/include/nvgpu/static_analysis.h b/drivers/gpu/nvgpu/include/nvgpu/static_analysis.h index feafe0832..2e66f7c11 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/static_analysis.h +++ b/drivers/gpu/nvgpu/include/nvgpu/static_analysis.h @@ -687,6 +687,27 @@ static inline void nvgpu_safety_checks(void) (NVGPU_PRECISION(ULLONG_MAX) != 64)) { BUG(); } + +#if defined(__QNX__) + /* + * For CERT-C EXP37-C rule + * Check sizes of same types considered for EXP37-C deviation record. + * If the sizes of data types are same, a compiler results in using same + * size and same precision base data type like int, long or long long, + * etc for redefined data types. + */ + if ((sizeof(s64) != sizeof(long) || + sizeof(s64) != sizeof(int64_t) || + sizeof(u64) != sizeof(uint64_t) || + sizeof(u64) != sizeof(_Uint64t) || + sizeof(u64) != sizeof(uintptr_t) || + sizeof(u64) != sizeof(unsigned long) || + sizeof(size_t) != sizeof(u64) || + sizeof(size_t) != sizeof(unsigned long long) || + sizeof(unsigned long long) != sizeof(unsigned long))) { + BUG(); + } +#endif } /**