tdb: Make tdb_new_database() follow a more conventional style
authorVolker Lendecke <vl@samba.org>
Fri, 14 Dec 2012 14:53:08 +0000 (15:53 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2012 10:57:01 +0000 (11:57 +0100)
We usually "goto fail" on every error and then in normal flow set the
return variable to success. This patch removes a comment which from my
point of view is now obsolete. It violates the {} rule from README.Coding
here in favor of the style used in this function.

Reviewed-by: Rusty Russell <rusty@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/tdb/common/open.c

index 694701f69dcdb5b9bdd99847d72bfe7f360c2cd6..b10f5ebe974d0c4cf078285672f407e42f106b0c 100644 (file)
@@ -94,10 +94,11 @@ static int tdb_new_database(struct tdb_context *tdb, int hash_size)
        memcpy(&tdb->header, newdb, sizeof(tdb->header));
        /* Don't endian-convert the magic food! */
        memcpy(newdb->magic_food, TDB_MAGIC_FOOD, strlen(TDB_MAGIC_FOOD)+1);
-       /* we still have "ret == -1" here */
-       if (tdb_write_all(tdb->fd, newdb, size))
-               ret = 0;
 
+       if (!tdb_write_all(tdb->fd, newdb, size))
+               goto fail;
+
+       ret = 0;
   fail:
        SAFE_FREE(newdb);
        return ret;