[PATCH] log: Allow LOG_DEBUG to always enable log output

Heinrich Schuchardt xypron.glpk at gmx.de
Wed Aug 5 14:54:05 CEST 2020

On 05.08.20 14:18, Tom Rini wrote:
> On Sun, Jul 26, 2020 at 08:27:35PM -0600, Simon Glass wrote:
>> At present if CONFIG_LOG enabled, putting LOG_DEBUG at the top of a file
>> (before log.h inclusion) causes _log() to be executed for every log()
>> call, regardless of the build- or run-time logging level.
>> However there is no guarantee that the log record will actually be
>> displayed. If the current log level is lower than LOGL_DEBUG then it will
>> not be.
>> Add a way to signal that the log record should always be displayed and
>> update log_passes_filters() to handle this.
>> Signed-off-by: Simon Glass <sjg at chromium.org>
> This exposes an underlying problem with LOG and clang I believe:
> https://gitlab.denx.de/u-boot/u-boot/-/jobs/135789

include/log.h:147:44: note: expanded from macro 'log'
        if (CONFIG_IS_ENABLED(LOG) && (_LOG_DEBUG || _l <=
drivers/misc/p2sb_emul.c:197:10: error: converting the enum constant to
a boolean [-Werror,-Wint-in-bool-context]

This seems to be a Clang bug. _LOG_DEBUG is not an enum:

#ifdef LOG_DEBUG
#define _LOG_DEBUG      1
#define _LOG_DEBUG      0

So there seems to be a bug in the Clang you used.

Compiling with clang on Debian Bullseye does not show the problem:

make HOSTCC=clang sandbox_defconfig
make HOSTCC=clang CC=clang -j8

clang version 9.0.1-13
LLVM version 9.0.1

Which Clang version did you use?

This is the change that added the test:

-Wint-in-bool-context seems to be new in Clang 10.

All over the U-Boot code we assume that a non-zero integer is true. Do
we really want to enable -Wint-in-bool-context?

Best regards


More information about the U-Boot mailing list