]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
memory-util: make memcpy_safe() return pointer to destination
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 May 2021 12:20:49 +0000 (21:20 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 May 2021 12:20:49 +0000 (21:20 +0900)
src/basic/memory-util.h

index 179edd247bf63bbd0f5046e1227b918fec00b70c..4ca3060c0cc8168bc55db7c14fc5fd0174705e1e 100644 (file)
@@ -16,11 +16,11 @@ size_t page_size(void) _pure_;
 #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) {
+static inline void *memcpy_safe(void *dst, const void *src, size_t n) {
         if (n == 0)
-                return;
+                return dst;
         assert(src);
-        memcpy(dst, src, n);
+        return memcpy(dst, src, n);
 }
 
 /* Normal memcmp requires s1 and s2 to be nonnull. We do nothing if n is 0. */