tdb2: fix internal tdb_write_convert() error handling in tdb_open()
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 31 Aug 2011 01:11:12 +0000 (10:41 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 31 Aug 2011 01:11:12 +0000 (10:41 +0930)
As noted, failtest was taking a long time, because a failure injected here
was not detected.

ccan/tdb2/open.c

index e88c9e694c531b67bf4a6ff33d113a3b4078ad59..daa83a334c44a39db4dad37c77e0090fee858769 100644 (file)
@@ -550,10 +550,11 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags,
        /* Clear any features we don't understand. */
        if ((open_flags & O_ACCMODE) != O_RDONLY) {
                hdr.features_used &= TDB_FEATURE_MASK;
-               if (tdb_write_convert(tdb, offsetof(struct tdb_header,
-                                                   features_used),
-                                     &hdr.features_used,
-                                     sizeof(hdr.features_used)) == -1)
+               ecode = tdb_write_convert(tdb, offsetof(struct tdb_header,
+                                                       features_used),
+                                         &hdr.features_used,
+                                         sizeof(hdr.features_used));
+               if (ecode != TDB_SUCCESS)
                        goto fail;
        }