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:
John Baldwin 2006-01-27 22:20:15 +00:00
parent bef4bf1adf
commit ffaf2c55a8
2 changed files with 5 additions and 1 deletions

View File

@ -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)

View File

@ -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);