diff options
| author | Peter Jones <pjones@redhat.com> | 2021-01-29 15:27:26 -0500 |
|---|---|---|
| committer | Peter Jones <pmjones@gmail.com> | 2021-01-29 18:24:57 -0500 |
| commit | 0172d43507f0d0af4b8940131770196b5a186aba (patch) | |
| tree | 445227d00ffcd656545dfa2a925d058dde6a83ea | |
| parent | 0789f48d70b7593808f18dc4f1dbce2ca67df0f4 (diff) | |
| download | efi-boot-shim-0172d43507f0d0af4b8940131770196b5a186aba.tar.gz efi-boot-shim-0172d43507f0d0af4b8940131770196b5a186aba.zip | |
Work around some clang-format oddnesses
In the version of clang-format I've got locally[0],
WhitespaceSensitiveMacros seems to only work sometimes. That means that
if we ever run it on some particular things, it could seriously mess up
a bunch of our debugging output. That's not great.
In this patch, I've gone ahead and run clang-format on all the macros
that use __LINE__, which are the obvious places this is dangerous, and
then audited the result and fixed anything that's broken (including a
couple of places where it was already broken.)
[0] random:~/devel/github.com/shim/clang-format$ clang-format --version
clang-format version 11.0.0 (Fedora 11.0.0-2.fc33)
Signed-off-by: Peter Jones <pjones@redhat.com>
| -rw-r--r-- | fallback.c | 17 | ||||
| -rw-r--r-- | include/compiler.h | 2 | ||||
| -rw-r--r-- | include/console.h | 7 | ||||
| -rw-r--r-- | include/hexdump.h | 8 | ||||
| -rw-r--r-- | mok.c | 17 | ||||
| -rw-r--r-- | shim.c | 6 | ||||
| -rw-r--r-- | shim.h | 6 |
7 files changed, 36 insertions, 27 deletions
@@ -54,14 +54,15 @@ get_fallback_verbose(void) ret_; \ }) -#define VerbosePrint(fmt, ...) \ - ({ UINTN line_ = __LINE__; \ - UINTN ret_ = 0; \ - if (get_fallback_verbose()) { \ - console_print(L"%a:%d: ", __func__, line_); \ - ret_ = console_print((fmt), ##__VA_ARGS__); \ - } \ - ret_; \ +#define VerbosePrint(fmt, ...) \ + ({ \ + UINTN line_ = __LINE__ - 2; \ + UINTN ret_ = 0; \ + if (get_fallback_verbose()) { \ + console_print(L"%a:%d: ", __func__, line_); \ + ret_ = console_print((fmt), ##__VA_ARGS__); \ + } \ + ret_; \ }) static EFI_STATUS diff --git a/include/compiler.h b/include/compiler.h index a2a08593..163b3df2 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -129,7 +129,7 @@ */ #ifndef compiletime_assert #define compiletime_assert(condition, msg) \ - _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) + _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__ - 1) #endif /** diff --git a/include/console.h b/include/console.h index ac6fdf61..b99004c6 100644 --- a/include/console.h +++ b/include/console.h @@ -84,10 +84,13 @@ extern UINT32 verbose; __dprint_ret = console_print((fmt), ##__VA_ARGS__); \ __dprint_ret; \ }) -#define dprint(fmt, ...) dprint_(L"%a:%d:%a() " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__) +#define dprint(fmt, ...) \ + dprint_(L"%a:%d:%a() " fmt, __FILE__, __LINE__ - 1, __func__, \ + ##__VA_ARGS__) extern EFI_STATUS vdprint_(const CHAR16 *fmt, const char *file, int line, const char *func, va_list args); -#define vdprint(fmt, ...) vdprint_(fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__) +#define vdprint(fmt, ...) \ + vdprint_(fmt, __FILE__, __LINE__ - 1, __func__, ##__VA_ARGS__) extern EFI_STATUS print_crypto_errors(EFI_STATUS rc, char *file, const char *func, int line); #define crypterr(rc) print_crypto_errors((rc), __FILE__, __func__, __LINE__) diff --git a/include/hexdump.h b/include/hexdump.h index b2968cd4..de209ec5 100644 --- a/include/hexdump.h +++ b/include/hexdump.h @@ -135,9 +135,11 @@ hexdumpat(const char *file, int line, const char *func, const void *data, unsign } #define LogHexdump(data, sz) LogHexdump_(__FILE__, __LINE__, __func__, data, sz) -#define dhexdump(data, sz) hexdump(__FILE__, __LINE__, __func__, data, sz) -#define dhexdumpat(data, sz, at) hexdumpat(__FILE__, __LINE__, __func__, data, sz, at) -#define dhexdumpf(fmt, data, sz, at, ...) hexdumpf(__FILE__, __LINE__, __func__, fmt, data, sz, at, ##__VA_ARGS__) +#define dhexdump(data, sz) hexdump(__FILE__, __LINE__, __func__, data, sz) +#define dhexdumpat(data, sz, at) \ + hexdumpat(__FILE__, __LINE__ - 1, __func__, data, sz, at) +#define dhexdumpf(fmt, data, sz, at, ...) \ + hexdumpf(__FILE__, __LINE__ - 1, __func__, fmt, data, sz, at, ##__VA_ARGS__) #endif /* STATIC_HEXDUMP_H */ // vim:fenc=utf-8:tw=75:noet @@ -27,14 +27,15 @@ static BOOLEAN check_var(CHAR16 *varname) return FALSE; } -#define SetVariable(name, guid, attrs, varsz, var) ({ \ - EFI_STATUS efi_status_; \ - efi_status_ = gRT->SetVariable(name, guid, attrs, varsz, var); \ - dprint_(L"%a:%d:%a() SetVariable(\"%s\", ... varsz=0x%llx) = %r\n",\ - __FILE__, __LINE__, __func__, \ - name, varsz, efi_status_); \ - efi_status_; \ -}) +#define SetVariable(name, guid, attrs, varsz, var) \ + ({ \ + EFI_STATUS efi_status_; \ + efi_status_ = gRT->SetVariable(name, guid, attrs, varsz, var); \ + dprint_(L"%a:%d:%a() SetVariable(\"%s\", ... varsz=0x%llx) = %r\n", \ + __FILE__, __LINE__ - 5, __func__, name, varsz, \ + efi_status_); \ + efi_status_; \ + }) /* * If the OS has set any of these variables we need to drop into MOK and @@ -756,7 +756,7 @@ static BOOLEAN secure_mode (void) goto done; \ } \ }) -#define check_size(d,ds,h,hs) check_size_line(d,ds,h,hs,__LINE__) +#define check_size(d, ds, h, hs) check_size_line(d, ds, h, hs, __LINE__) /* * Calculate the SHA1 and SHA256 hashes of a binary @@ -2802,9 +2802,9 @@ efi_main (EFI_HANDLE passed_image_handle, EFI_SYSTEM_TABLE *passed_systab) setup_verbosity(); dprint(L"vendor_authorized:0x%08lx vendor_authorized_size:%lu\n", - __FILE__, __LINE__, __func__, vendor_authorized, vendor_authorized_size); + vendor_authorized, vendor_authorized_size); dprint(L"vendor_deauthorized:0x%08lx vendor_deauthorized_size:%lu\n", - __FILE__, __LINE__, __func__, vendor_deauthorized, vendor_deauthorized_size); + vendor_deauthorized, vendor_deauthorized_size); init_openssl(); /* @@ -212,7 +212,9 @@ extern UINT8 in_protocol; LogError_(file, line, func, fmt, ##__VA_ARGS__); \ __perror_ret; \ }) -#define perror(fmt, ...) perror_(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) -#define LogError(fmt, ...) LogError_(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) +#define perror(fmt, ...) \ + perror_(__FILE__, __LINE__ - 1, __func__, fmt, ##__VA_ARGS__) +#define LogError(fmt, ...) \ + LogError_(__FILE__, __LINE__ - 1, __func__, fmt, ##__VA_ARGS__) #endif /* SHIM_H_ */ |
