From 048f9b415670d1630c5cb25ffc4385c6a11fdc6b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 30 Apr 2023 18:52:24 -0400 Subject: Avoid or suppress clang-tidy warnings in utility headers --- include/lv2/atom/forge.h | 15 +++++++++++---- include/lv2/atom/util.h | 8 +++++++- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'include/lv2/atom') diff --git a/include/lv2/atom/forge.h b/include/lv2/atom/forge.h index 5110b99..5656079 100644 --- a/include/lv2/atom/forge.h +++ b/include/lv2/atom/forge.h @@ -316,11 +316,18 @@ lv2_atom_forge_write(LV2_Atom_Forge* forge, const void* data, uint32_t size) static inline LV2_Atom_Forge_Ref lv2_atom_forge_string_body(LV2_Atom_Forge* forge, const char* str, uint32_t len) { - LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, str, len); - if (out && (out = lv2_atom_forge_raw(forge, "", 1))) { - lv2_atom_forge_pad(forge, len + 1); + const LV2_Atom_Forge_Ref s = lv2_atom_forge_raw(forge, str, len); + if (!s) { + return s; } - return out; + + const LV2_Atom_Forge_Ref t = lv2_atom_forge_raw(forge, "", 1); + if (!t) { + return t; + } + + lv2_atom_forge_pad(forge, len + 1U); + return t; } /** diff --git a/include/lv2/atom/util.h b/include/lv2/atom/util.h index f641619..556fb58 100644 --- a/include/lv2/atom/util.h +++ b/include/lv2/atom/util.h @@ -28,6 +28,8 @@ #include #include +// NOLINTBEGIN(bugprone-macro-parentheses) + #ifdef __cplusplus extern "C" { #endif @@ -36,7 +38,9 @@ extern "C" { static inline uint32_t lv2_atom_pad_size(uint32_t size) { - return (size + 7U) & (~7U); + static const uint32_t mask = 7U; + + return (size + mask) & ~mask; } /** Return the total size of `atom`, including the header. */ @@ -501,6 +505,8 @@ lv2_atom_object_get_typed(const LV2_Atom_Object* object, ...) } /* extern "C" */ #endif +// NOLINTEND(bugprone-macro-parentheses) + /** @} @} -- cgit v1.2.1