]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
memfd-util: trivial modernizations
authorLennart Poettering <lennart@poettering.net>
Mon, 16 Dec 2024 10:32:07 +0000 (11:32 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 17 Dec 2024 17:26:15 +0000 (18:26 +0100)
src/basic/memfd-util.c
src/basic/memfd-util.h

index 3bcb5c9582c7ef92507c0baaa26a8f6c9c0a4ec1..2d710267d0ac620536412605a9e40c67fd319abf 100644 (file)
@@ -75,13 +75,13 @@ int memfd_new_full(const char *name, unsigned extra_flags) {
                         MFD_CLOEXEC | MFD_NOEXEC_SEAL | extra_flags);
 }
 
-int memfd_add_seals(int fd, unsigned int seals) {
+int memfd_add_seals(int fd, unsigned seals) {
         assert(fd >= 0);
 
         return RET_NERRNO(fcntl(fd, F_ADD_SEALS, seals));
 }
 
-int memfd_get_seals(int fd, unsigned int *ret_seals) {
+int memfd_get_seals(int fd, unsigned *ret_seals) {
         int r;
 
         assert(fd >= 0);
@@ -95,14 +95,14 @@ int memfd_get_seals(int fd, unsigned int *ret_seals) {
         return 0;
 }
 
-int memfd_map(int fd, uint64_t offset, size_t size, void **p) {
+int memfd_map(int fd, uint64_t offset, size_t size, void **ret) {
         unsigned int seals;
         void *q;
         int r;
 
         assert(fd >= 0);
         assert(size > 0);
-        assert(p);
+        assert(ret);
 
         r = memfd_get_seals(fd, &seals);
         if (r < 0)
@@ -115,7 +115,7 @@ int memfd_map(int fd, uint64_t offset, size_t size, void **p) {
         if (q == MAP_FAILED)
                 return -errno;
 
-        *p = q;
+        *ret = q;
         return 0;
 }
 
@@ -135,16 +135,16 @@ int memfd_get_sealed(int fd) {
         return FLAGS_SET(seals, F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE);
 }
 
-int memfd_get_size(int fd, uint64_t *sz) {
+int memfd_get_size(int fd, uint64_t *ret) {
         struct stat stat;
 
         assert(fd >= 0);
-        assert(sz);
+        assert(ret);
 
         if (fstat(fd, &stat) < 0)
                 return -errno;
 
-        *sz = stat.st_size;
+        *ret = stat.st_size;
         return 0;
 }
 
@@ -154,12 +154,12 @@ int memfd_set_size(int fd, uint64_t sz) {
         return RET_NERRNO(ftruncate(fd, sz));
 }
 
-int memfd_new_and_map(const char *name, size_t sz, void **p) {
+int memfd_new_and_map(const char *name, size_t sz, void **ret) {
         _cleanup_close_ int fd = -EBADF;
         int r;
 
         assert(sz > 0);
-        assert(p);
+        assert(ret);
 
         fd = memfd_new(name);
         if (fd < 0)
@@ -169,7 +169,7 @@ int memfd_new_and_map(const char *name, size_t sz, void **p) {
         if (r < 0)
                 return r;
 
-        r = memfd_map(fd, 0, sz, p);
+        r = memfd_map(fd, 0, sz, ret);
         if (r < 0)
                 return r;
 
index 06af55c1b00ffe207ab2d96fd14bc0c2dc349cf4..92d8b579149ac08466108bba03c2ba99abdf250e 100644 (file)
@@ -13,19 +13,19 @@ static inline int memfd_new(const char *name) {
         return memfd_new_full(name, 0);
 }
 
-int memfd_new_and_map(const char *name, size_t sz, void **p);
+int memfd_new_and_map(const char *name, size_t sz, void **ret);
 
 int memfd_new_and_seal(const char *name, const void *data, size_t sz);
 static inline int memfd_new_and_seal_string(const char *name, const char *s) {
         return memfd_new_and_seal(name, s, SIZE_MAX);
 }
 
-int memfd_add_seals(int fd, unsigned int seals);
-int memfd_get_seals(int fd, unsigned int *ret_seals);
-int memfd_map(int fd, uint64_t offset, size_t size, void **p);
+int memfd_add_seals(int fd, unsigned seals);
+int memfd_get_seals(int fd, unsigned *ret_seals);
+int memfd_map(int fd, uint64_t offset, size_t size, void **ret);
 
 int memfd_set_sealed(int fd);
 int memfd_get_sealed(int fd);
 
-int memfd_get_size(int fd, uint64_t *sz);
+int memfd_get_size(int fd, uint64_t *ret);
 int memfd_set_size(int fd, uint64_t sz);