From 227da7359cb2568c17bf8096538900b60d88127d Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 8 Sep 2016 14:49:13 -0700 Subject: [PATCH] dbus-proxy: alignment bit-twiddling to remove multiple and divide Common bit-twiddling to remove the multiply and divide for realignment. --- dbus-proxy/flatpak-proxy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dbus-proxy/flatpak-proxy.c b/dbus-proxy/flatpak-proxy.c index 6a71a078e..72897e678 100644 --- a/dbus-proxy/flatpak-proxy.c +++ b/dbus-proxy/flatpak-proxy.c @@ -848,16 +848,16 @@ write_uint32 (Header *header, guint8 *ptr, guint32 val) *(guint32 *) ptr = GUINT32_TO_LE (val); } -static guint32 +static inline guint32 align_by_8 (guint32 offset) { - return 8 * ((offset + 7) / 8); + return (offset + 8 - 1) & ~(8 - 1); } -static guint32 +static inline guint32 align_by_4 (guint32 offset) { - return 4 * ((offset + 3) / 4); + return (offset + 4 - 1) & ~(4 - 1); } static const char *