From ffaf45e4f33dccb0ff683b9f621077f25a784a28 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 5 Aug 2020 23:28:14 +0200 Subject: [PATCH] mountpoint-util: minor modernizations --- src/basic/mountpoint-util.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index df1f0ac34c..1e1c21f35d 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -32,6 +32,8 @@ int name_to_handle_at_loop( _cleanup_free_ struct file_handle *h = NULL; size_t n = ORIGINAL_MAX_HANDLE_SZ; + assert((flags & ~(AT_SYMLINK_FOLLOW|AT_EMPTY_PATH)) == 0); + /* We need to invoke name_to_handle_at() in a loop, given that it might return EOVERFLOW when the specified * buffer is too small. Note that in contrast to what the docs might suggest, MAX_HANDLE_SZ is only good as a * start value, it is not an upper bound on the buffer size required. @@ -86,13 +88,16 @@ int name_to_handle_at_loop( } } -static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *mnt_id) { +static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *ret_mnt_id) { char path[STRLEN("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)]; _cleanup_free_ char *fdinfo = NULL; _cleanup_close_ int subfd = -1; char *p; int r; + assert(ret_mnt_id); + assert((flags & ~(AT_SYMLINK_FOLLOW|AT_EMPTY_PATH)) == 0); + if ((flags & AT_EMPTY_PATH) && isempty(filename)) xsprintf(path, "/proc/self/fdinfo/%i", fd); else { @@ -121,7 +126,7 @@ static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *mnt_id p += strspn(p, WHITESPACE); p[strcspn(p, WHITESPACE)] = 0; - return safe_atoi(p, mnt_id); + return safe_atoi(p, ret_mnt_id); } int fd_is_mount_point(int fd, const char *filename, int flags) {