lib: Simplify two if-expressions
authorVolker Lendecke <vl@samba.org>
Tue, 23 May 2023 08:44:40 +0000 (10:44 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 16 Jun 2023 16:14:30 +0000 (16:14 +0000)
This version looks easier to read to me.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/util.c

index 9fd913ba72908c94d72fe84ad4922713dffd09c1..922b7ad83d93e2d6eb6df0bb073be41023b38af1 100644 (file)
@@ -119,11 +119,8 @@ uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf)
 bool check_same_dev_ino(const SMB_STRUCT_STAT *sbuf1,
                         const SMB_STRUCT_STAT *sbuf2)
 {
-       if (sbuf1->st_ex_dev != sbuf2->st_ex_dev ||
-                       sbuf1->st_ex_ino != sbuf2->st_ex_ino) {
-               return false;
-       }
-       return true;
+       return ((sbuf1->st_ex_dev == sbuf2->st_ex_dev) &&
+               (sbuf1->st_ex_ino == sbuf2->st_ex_ino));
 }
 
 /****************************************************************************
@@ -131,14 +128,11 @@ bool check_same_dev_ino(const SMB_STRUCT_STAT *sbuf1,
 ****************************************************************************/
 
 bool check_same_stat(const SMB_STRUCT_STAT *sbuf1,
-                       const SMB_STRUCT_STAT *sbuf2)
+                    const SMB_STRUCT_STAT *sbuf2)
 {
-       if (sbuf1->st_ex_uid != sbuf2->st_ex_uid ||
-                       sbuf1->st_ex_gid != sbuf2->st_ex_gid ||
-                       !check_same_dev_ino(sbuf1, sbuf2)) {
-               return false;
-       }
-       return true;
+       return ((sbuf1->st_ex_uid == sbuf2->st_ex_uid) &&
+               (sbuf1->st_ex_gid == sbuf2->st_ex_gid) &&
+               check_same_dev_ino(sbuf1, sbuf2));
 }
 
 /*******************************************************************