summaryrefslogtreecommitdiff
path: root/aehd_types.h
diff options
context:
space:
mode:
authorHaitao Shan <hshan@google.com>2023-08-25 16:19:13 -0700
committerHaitao Shan <hshan@google.com>2024-04-01 18:44:56 -0700
commit7e41dff254b45667a9b993a5727d3a8071856999 (patch)
tree2aaa6e2a608bdc7ce90d19df29b86285feb7505e /aehd_types.h
parentb23907397a84493ee2f4d8ba0af1bd4c80d79cf4 (diff)
downloadaehd-7e41dff254b45667a9b993a5727d3a8071856999.tar.gz
Fix warning messages from CodeQL scan for WHCP.
See: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/static-tools-and-codeql Change-Id: I441cf30f02381e90aefbba03cb0d837ef422e238
Diffstat (limited to 'aehd_types.h')
-rw-r--r--aehd_types.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/aehd_types.h b/aehd_types.h
index 05a28b2..9e8084c 100644
--- a/aehd_types.h
+++ b/aehd_types.h
@@ -1124,14 +1124,22 @@ static __forceinline unsigned char test_bit(size_t nr, volatile size_t *addr)
#ifdef _WIN64
static __forceinline size_t __ffs(size_t mask)
{
- unsigned long pos;
+ unsigned long pos = ULONG_MAX;
+ /*
+ * When mask is 0, __ffs return value is undefined. The caller is
+ * expected to explicitly check against 0 first.
+ */
_BitScanForward64(&pos, mask);
return pos;
}
static __forceinline size_t __fls(size_t mask)
{
- unsigned long pos;
+ unsigned long pos = ULONG_MAX;
+ /*
+ * When mask is 0, __fls return value is undefined. The caller is
+ * expected to explicitly check against 0 first.
+ */
_BitScanReverse64(&pos, mask);
return pos;
}