]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
core: fix compiler warning due to difference in order of struct memebers 40872/head
authorWillem Jan Withagen <wjw@digiware.nl>
Thu, 15 Apr 2021 11:01:21 +0000 (13:01 +0200)
committerWillem Jan Withagen <wjw@digiware.nl>
Thu, 15 Apr 2021 22:00:34 +0000 (00:00 +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`

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
src/global/pidfile.cc

index 6a6b939f1138083dbabcf22bc2635d321dd4e499..c46ad2b303636b92417d8a630fe95ba54c4eb67f 100644 (file)
@@ -164,12 +164,12 @@ int pidfh::open(std::string_view pid_file)
   // Default Windows file share flags prevent other processes from writing
   // to this file.
   #ifndef _WIN32
-  struct flock l = {
-    .l_type = F_WRLCK,
-    .l_whence = SEEK_SET,
-    .l_start = 0,
-    .l_len = 0
-  };
+  struct flock l;
+  l.l_type = F_WRLCK;
+  l.l_whence = SEEK_SET;
+  l.l_start = 0;
+  l.l_len = 0;
+  
   int r = ::fcntl(pf_fd, F_SETLK, &l);
   if (r < 0) {
     if (errno == EAGAIN || errno == EACCES) {