mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-11-30 07:13:42 +08:00
Always define and use ENABLE_ELFDBG
Convert the "if defined FOO" pre-processor checks for compiler ones "if (FOO == 1)". This makes things easier to reason with and ensures both code-paths are build-tested. In case, the option is disabled DCE will kick in (assuming you're not force disabling all optimisations) and remove the respective code. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/173 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This commit is contained in:
parent
8c1c901e9e
commit
eea5278df7
@ -219,6 +219,7 @@ AS_IF([test "x$enable_debug" = "xyes"], [
|
||||
], [
|
||||
AC_DEFINE(ENABLE_DEBUG, [0], [Debug messages.])
|
||||
])
|
||||
AC_DEFINE(ENABLE_ELFDBG, [0], [Debug elf parsing messages.])
|
||||
|
||||
AC_ARG_ENABLE([coverage],
|
||||
AS_HELP_STRING([--enable-coverage], [enable test coverage @<:@default=disabled@:>@]),
|
||||
|
@ -53,10 +53,14 @@ struct kmod_elf {
|
||||
} header;
|
||||
};
|
||||
|
||||
//#undef ENABLE_ELFDBG
|
||||
//#define ENABLE_ELFDBG 1
|
||||
|
||||
#if (ENABLE_LOGGING == 1) && defined(ENABLE_ELFDBG)
|
||||
#define ELFDBG(elf, ...) _elf_dbg(elf, __FILE__, __LINE__, __func__, __VA_ARGS__);
|
||||
#define ELFDBG(elf, ...) \
|
||||
do { \
|
||||
if (ENABLE_LOGGING == 1 && ENABLE_ELFDBG == 1) \
|
||||
_elf_dbg(elf, __FILE__, __LINE__, __func__, __VA_ARGS__); \
|
||||
} while (0);
|
||||
|
||||
static inline void _elf_dbg(const struct kmod_elf *elf, const char *fname, unsigned line,
|
||||
const char *func, const char *fmt, ...)
|
||||
@ -69,9 +73,6 @@ static inline void _elf_dbg(const struct kmod_elf *elf, const char *fname, unsig
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
#else
|
||||
#define ELFDBG(elf, ...)
|
||||
#endif
|
||||
|
||||
static int elf_identify(const void *memory, uint64_t size)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@ cdata.set_quoted('VERSION', meson.project_version())
|
||||
|
||||
cdata.set10('ENABLE_LOGGING', get_option('logging'))
|
||||
cdata.set10('ENABLE_DEBUG', get_option('debug-messages'))
|
||||
cdata.set10('ENABLE_ELFDBG', false)
|
||||
|
||||
pkg = import('pkgconfig')
|
||||
cc = meson.get_compiler('c')
|
||||
|
Loading…
Reference in New Issue
Block a user