From d54bbc4cdccf0af5efe539844268483143c24ec3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 16 Dec 2024 11:32:07 +0100 Subject: [PATCH] memfd-util: trivial modernizations --- src/basic/memfd-util.c | 22 +++++++++++----------- src/basic/memfd-util.h | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/basic/memfd-util.c b/src/basic/memfd-util.c index 3bcb5c9582c..2d710267d0a 100644 --- a/src/basic/memfd-util.c +++ b/src/basic/memfd-util.c @@ -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; diff --git a/src/basic/memfd-util.h b/src/basic/memfd-util.h index 06af55c1b00..92d8b579149 100644 --- a/src/basic/memfd-util.h +++ b/src/basic/memfd-util.h @@ -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);