Add a new macro wrapper WITNESS_CHECK() around the witness_warn() function.
The difference between WITNESS_CHECK() and WITNESS_WARN() is that WITNESS_CHECK() should be used in the places that the return value of witness_warn() is checked, whereas WITNESS_WARN() should be used in places where the return value is ignored. Specifically, in a kernel without WITNESS enabled, WITNESS_WARN() evaluates to an empty string where as WITNESS_CHECK evaluates to 0. I also updated the one place that was checking the return value of WITNESS_WARN() to use WITNESS_CHECK.
This commit is contained in:
parent
bef4bf1adf
commit
ffaf2c55a8
@ -268,6 +268,9 @@ const char *witness_file(struct lock_object *);
|
||||
#define WITNESS_UNLOCK(lock, flags, file, line) \
|
||||
witness_unlock((lock), (flags), (file), (line))
|
||||
|
||||
#define WITNESS_CHECK(flags, lock, fmt, ...) \
|
||||
witness_warn((flags), (lock), (fmt), ## __VA_ARGS__)
|
||||
|
||||
#define WITNESS_WARN(flags, lock, fmt, ...) \
|
||||
witness_warn((flags), (lock), (fmt), ## __VA_ARGS__)
|
||||
|
||||
@ -296,6 +299,7 @@ const char *witness_file(struct lock_object *);
|
||||
#define WITNESS_UPGRADE(lock, flags, file, line)
|
||||
#define WITNESS_DOWNGRADE(lock, flags, file, line)
|
||||
#define WITNESS_UNLOCK(lock, flags, file, line)
|
||||
#define WITNESS_CHECK(flags, lock, fmt, ...) 0
|
||||
#define WITNESS_WARN(flags, lock, fmt, ...)
|
||||
#define WITNESS_SAVE_DECL(n)
|
||||
#define WITNESS_SAVE(lock, n)
|
||||
|
@ -1789,7 +1789,7 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
|
||||
("malloc(M_WAITOK) in interrupt context"));
|
||||
if (nosleepwithlocks) {
|
||||
#ifdef WITNESS
|
||||
badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
|
||||
badness = WITNESS_CHECK(WARN_GIANTOK | WARN_SLEEPOK,
|
||||
NULL,
|
||||
"malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT",
|
||||
zone->uz_name);
|
||||
|
Loading…
Reference in New Issue
Block a user