]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
blk/kernel: explicit assign to fields in struct
authorWillem Jan Withagen <wjw@digiware.nl>
Thu, 15 Apr 2021 10:53:50 +0000 (12:53 +0200)
committerWillem Jan Withagen <wjw@digiware.nl>
Sun, 9 May 2021 10:36:53 +0000 (12:36 +0200)
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 <wjw@digiware.nl>
src/blk/kernel/KernelDevice.cc

index 09a4b687ef062b11d12347e865f17f7f88b23cd2..0cf38dfa241071cea8c36d40b80f0b28b9d34340 100644 (file)
@@ -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) {