From e9ecc9081afd910a31f1dc58d1f2ba86afebc9fa Mon Sep 17 00:00:00 2001 From: Willem Jan Withagen Date: Thu, 15 Apr 2021 12:53:50 +0200 Subject: [PATCH] blk/kernel: explicit assign to fields in struct Clang on FreeBSD reports: ``` Building CXX object src/global/CMakeFiles/libglobal_objs.dir/pidfile.cc.o ../src/global/pidfile.cc:170:5: warning: ISO C++ requires field designators to be specified in declaration order; field 'l_whence' will be initialized after field 'l_start' [-Wreorder-init-list] .l_start = 0, ^~~~~~~~~~~~ ../src/global/pidfile.cc:169:17: note: previous initialization for field 'l_whence' is here .l_whence = SEEK_SET, ^~~~~~~~ ``` And Linux and BSD have different orders in their `struct flock`. It also prevents the wrong initialisation on FreeBSD Signed-off-by: Willem Jan Withagen --- src/blk/kernel/KernelDevice.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index 09a4b687ef0..0cf38dfa241 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -94,8 +94,8 @@ int KernelDevice::_lock() int fd = fd_directs[WRITE_LIFE_NOT_SET]; uint64_t nr_tries = 0; for (;;) { - struct flock fl = { F_WRLCK, - SEEK_SET }; + struct flock fl = { .l_type = F_WRLCK, + .l_whence = SEEK_SET }; int r = ::fcntl(fd, F_OFD_SETLK, &fl); if (r < 0) { if (errno == EINVAL) { -- 2.39.5