]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bus-message: add macro for calculation of offset from the page 16237/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 22 Jun 2020 15:18:35 +0000 (17:18 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 22 Jun 2020 15:18:35 +0000 (17:18 +0200)
src/basic/memory-util.h
src/libsystemd/sd-bus/bus-message.c

index a6a2ccdbc299bf932c9fd3ec5bf64a491a37d6e2..4f596cffb75bc2d9fd28c94df8b5d9020bcbddd3 100644 (file)
@@ -13,6 +13,7 @@
 size_t page_size(void) _pure_;
 #define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
 #define PAGE_ALIGN_DOWN(l) ((l) & ~(page_size() - 1))
+#define PAGE_OFFSET(l) ((l) & (page_size() - 1))
 
 /* Normal memcpy requires src to be nonnull. We do nothing if n is 0. */
 static inline void memcpy_safe(void *dst, const void *src, size_t n) {
index 8a8fbde781094791d5c0633f751c0b0dbbabfb3e..55e35cd902ee960e20bb13271aa69ce0e0df89c5 100644 (file)
@@ -3022,7 +3022,7 @@ int bus_body_part_map(struct bus_body_part *part) {
                 return 0;
         }
 
-        shift = part->memfd_offset - ((part->memfd_offset / page_size()) * page_size());
+        shift = PAGE_OFFSET(part->memfd_offset);
         psz = PAGE_ALIGN(part->size + shift);
 
         if (part->memfd >= 0)