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 <nkumbhar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2282951
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Nitin Kumbhar
2020-01-21 17:00:46 +05:30
committed by Alex Waterman
parent 73df40d9d4
commit fa75e9d2de

View File

@@ -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
}
/**