mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-25 02:52:51 +03:00
gpu: nvgpu: posix: make BITS_TO_LONGS CERT-C friendly
Fix CERT-C INT30 violations caused by BIT_TO_LONGS() macro in bitops.h. JIRA NVGPU-3587 Change-Id: Idadd0c719160fe4bc54c80c0e26890d3f1256c94 Signed-off-by: Philip Elcan <pelcan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2132540 GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
d388e45d98
commit
ca96903881
@@ -31,7 +31,7 @@
|
||||
#define BITS_PER_BYTE 8UL
|
||||
#define BITS_PER_LONG ((unsigned long)__SIZEOF_LONG__ * BITS_PER_BYTE)
|
||||
#define BITS_TO_LONGS(bits) \
|
||||
(((bits) + BITS_PER_LONG - 1UL) / BITS_PER_LONG)
|
||||
(nvgpu_safe_add_u64(bits, BITS_PER_LONG - 1UL) / BITS_PER_LONG)
|
||||
|
||||
/*
|
||||
* Deprecated; use the explicit BITxx() macros instead.
|
||||
@@ -42,8 +42,15 @@
|
||||
(((~0UL) - (1UL << (lo)) + 1UL) & \
|
||||
(~0UL >> (BITS_PER_LONG - 1UL - (unsigned long)(hi))))
|
||||
|
||||
#define DECLARE_BITMAP(bmap, bits) \
|
||||
unsigned long bmap[BITS_TO_LONGS(bits)]
|
||||
/*
|
||||
* Can't use BITS_TO_LONGS to declare arrays where we can't use BUG(), so if the
|
||||
* range is invalid, use -1 for the size which will generate a compiler error.
|
||||
*/
|
||||
#define DECLARE_BITMAP(bmap, bits) \
|
||||
unsigned long bmap[(((LONG_MAX - (bits)) < (BITS_PER_LONG - 1UL)) ? \
|
||||
-1 : \
|
||||
(long int)(((bits) + BITS_PER_LONG - 1UL) / \
|
||||
BITS_PER_LONG))]
|
||||
|
||||
#define for_each_set_bit(bit, addr, size) \
|
||||
for ((bit) = find_first_bit((addr), (size)); \
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define NVGPU_UTILS_H
|
||||
|
||||
#include <nvgpu/types.h>
|
||||
#include <nvgpu/safe_ops.h>
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/kernel.h>
|
||||
|
||||
Reference in New Issue
Block a user