]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/open.c
tdb2: fix internal tdb_write_convert() error handling in tdb_open()
[ccan] / ccan / tdb2 / open.c
index def816775c76efa8cd80db786084926c6e04e5d8..daa83a334c44a39db4dad37c77e0090fee858769 100644 (file)
@@ -1,3 +1,20 @@
+ /*
+   Trivial Database 2: opening and closing TDBs
+   Copyright (C) Rusty Russell 2010
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
 #include "private.h"
 #include <ccan/hash/hash.h>
 #include <assert.h>
@@ -533,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;
        }