s3: Make the difference between r/o and r/w in connections_db_ctx more obvious
authorVolker Lendecke <vl@samba.org>
Thu, 25 Feb 2010 15:31:12 +0000 (16:31 +0100)
committerVolker Lendecke <vl@samba.org>
Mon, 1 Mar 2010 13:04:45 +0000 (14:04 +0100)
source3/lib/conn_tdb.c

index 90e455a73e13f11816f449c12debdbb975d0d106..e95ada4c6acafb7cfc70450cf1d2c7bf9cd2ec75 100644 (file)
 static struct db_context *connections_db_ctx(bool rw)
 {
        static struct db_context *db_ctx;
+       int open_flags;
 
        if (db_ctx != NULL) {
                return db_ctx;
        }
 
-       if (rw) {
-               db_ctx = db_open(NULL, lock_path("connections.tdb"), 0,
-                                TDB_CLEAR_IF_FIRST|TDB_DEFAULT, 
-                                O_RDWR | O_CREAT, 0644);
-       }
-       else {
-               db_ctx = db_open(NULL, lock_path("connections.tdb"), 0,
-                                TDB_CLEAR_IF_FIRST|TDB_DEFAULT, O_RDONLY, 0);
-       }
+       open_flags = rw ? (O_RDWR|O_CREAT) : O_RDONLY;
 
+       db_ctx = db_open(NULL, lock_path("connections.tdb"), 0,
+                        TDB_CLEAR_IF_FIRST|TDB_DEFAULT, open_flags, 0644);
        return db_ctx;
 }