mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
The BUG_ON() macro adds a little bit of complexity over BUG(), and in some cases this ends up confusing the compiler's control flow analysis in a way that results in a warning. This one now shows up with clang-21: arch/arm64/kvm/vgic/vgic-mmio.c:1094:3: error: variable 'len' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] 1094 | BUG_ON(1); Change both instances of BUG_ON(1) to a plain BUG() in the arm64 kvm code, to avoid the false-positive warning. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20250807072132.4170088-1-arnd@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2022 - Google LLC
|
|
* Author: Keir Fraser <keirf@google.com>
|
|
*/
|
|
|
|
#include <linux/list.h>
|
|
#include <linux/bug.h>
|
|
|
|
static inline __must_check bool nvhe_check_data_corruption(bool v)
|
|
{
|
|
return v;
|
|
}
|
|
|
|
#define NVHE_CHECK_DATA_CORRUPTION(condition) \
|
|
nvhe_check_data_corruption(({ \
|
|
bool corruption = unlikely(condition); \
|
|
if (corruption) { \
|
|
if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
|
|
BUG(); \
|
|
} else \
|
|
WARN_ON(1); \
|
|
} \
|
|
corruption; \
|
|
}))
|
|
|
|
/* The predicates checked here are taken from lib/list_debug.c. */
|
|
|
|
__list_valid_slowpath
|
|
bool __list_add_valid_or_report(struct list_head *new, struct list_head *prev,
|
|
struct list_head *next)
|
|
{
|
|
if (NVHE_CHECK_DATA_CORRUPTION(next->prev != prev) ||
|
|
NVHE_CHECK_DATA_CORRUPTION(prev->next != next) ||
|
|
NVHE_CHECK_DATA_CORRUPTION(new == prev || new == next))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
__list_valid_slowpath
|
|
bool __list_del_entry_valid_or_report(struct list_head *entry)
|
|
{
|
|
struct list_head *prev, *next;
|
|
|
|
prev = entry->prev;
|
|
next = entry->next;
|
|
|
|
if (NVHE_CHECK_DATA_CORRUPTION(next == LIST_POISON1) ||
|
|
NVHE_CHECK_DATA_CORRUPTION(prev == LIST_POISON2) ||
|
|
NVHE_CHECK_DATA_CORRUPTION(prev->next != entry) ||
|
|
NVHE_CHECK_DATA_CORRUPTION(next->prev != entry))
|
|
return false;
|
|
|
|
return true;
|
|
}
|