diff options
Diffstat (limited to 'include/lv2')
-rw-r--r-- | include/lv2/atom/forge.h | 15 | ||||
-rw-r--r-- | include/lv2/atom/util.h | 8 |
2 files changed, 18 insertions, 5 deletions
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 <stdint.h> #include <string.h> +// 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) + /** @} @} |