tdb: finish weaning off err.h.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 26 Jun 2012 05:48:52 +0000 (15:18 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 26 Jun 2012 08:22:03 +0000 (10:22 +0200)
Commit 3c4263e7580143c69225729f5b67f09c00add2fd said it removed err.h
from tdb, unfortuntely it didn't: tap-interface.h still included it.

This finishes it properly!

Reported-by:Stefan Metzmacher <metze@samba.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User(master): Rusty Russell <rusty@rustcorp.com.au>
Autobuild-Date(master): Tue Jun 26 10:22:03 CEST 2012 on sn-devel-104

lib/tdb/test/external-agent.c
lib/tdb/test/run-corrupt.c
lib/tdb/test/run-die-during-transaction.c
lib/tdb/test/run-nested-traverse.c
lib/tdb/test/run-open-during-transaction.c
lib/tdb/test/run-traverse-in-transaction.c
lib/tdb/test/tap-interface.h

index 139de76f9ad0dc3e474a25828ef872870cd200a6..8140e70ead05b46e1e056f5268cce5813404e1ed 100644 (file)
@@ -108,12 +108,16 @@ struct agent *prepare_external_agent(void)
        int command[2], response[2];
        char name[1+PATH_MAX];
 
-       if (pipe(command) != 0 || pipe(response) != 0)
-               return NULL;
+       if (pipe(command) != 0 || pipe(response) != 0) {
+               fprintf(stderr, "pipe failed: %s\n", strerror(errno));
+               exit(1);
+       }
 
        pid = fork();
-       if (pid < 0)
-               return NULL;
+       if (pid < 0) {
+               fprintf(stderr, "fork failed: %s\n", strerror(errno));
+               exit(1);
+       }
 
        if (pid != 0) {
                struct agent *agent = malloc(sizeof(*agent));
index 584f789bf8078ae7387849aa0aa8479cd94613e3..1a3c769183243aad665e77784c1fb129d5b4ffe3 100644 (file)
@@ -41,11 +41,15 @@ static void tdb_flip_bit(struct tdb_context *tdb, unsigned int bit)
                ((unsigned char *)tdb->map_ptr)[off] ^= mask;
        else {
                unsigned char c;
-               if (pread(tdb->fd, &c, 1, off) != 1)
-                       err(1, "pread");
+               if (pread(tdb->fd, &c, 1, off) != 1) {
+                       fprintf(stderr, "pread: %s\n", strerror(errno));
+                       exit(1);
+               }
                c ^= mask;
-               if (pwrite(tdb->fd, &c, 1, off) != 1)
-                       err(1, "pwrite");
+               if (pwrite(tdb->fd, &c, 1, off) != 1) {
+                       fprintf(stderr, "pwrite: %s\n", strerror(errno));
+                       exit(1);
+               }
        }
 }
 
index 19c9dbebf93c7ef45184d6708654dc50249eb0db..6e3a70d4ae67372db850868a7df45a6042a51c15 100644 (file)
@@ -164,12 +164,18 @@ reset:
        key.dsize--;
 
        ret = external_agent_operation(agent, OPEN, TEST_DBNAME);
-       if (ret != SUCCESS)
-               errx(1, "Agent failed to open: %s", agent_return_name(ret));
+       if (ret != SUCCESS) {
+               fprintf(stderr, "Agent failed to open: %s\n",
+                       agent_return_name(ret));
+               exit(1);
+       }
 
        ret = external_agent_operation(agent, FETCH, KEY_STRING);
-       if (ret != SUCCESS)
-               errx(1, "Agent failed find key: %s", agent_return_name(ret));
+       if (ret != SUCCESS) {
+               fprintf(stderr, "Agent failed find key: %s\n",
+                       agent_return_name(ret));
+               exit(1);
+       }
 
        in_transaction = true;
        if (tdb_transaction_start(tdb) != 0)
@@ -215,8 +221,6 @@ int main(int argc, char *argv[])
        unlock_callback = maybe_die;
 
        agent = prepare_external_agent();
-       if (!agent)
-               err(1, "preparing agent");
 
        for (i = 0; i < sizeof(ops)/sizeof(ops[0]); i++) {
                diag("Testing %s after death", operation_name(ops[i]));
index 86f2913455703d5adbd7d15817247ab1aff5f22c..37d57c012581eb841aa2d6d3c336b89e363907ea 100644 (file)
@@ -62,8 +62,6 @@ int main(int argc, char *argv[])
 
        plan_tests(17);
        agent = prepare_external_agent();
-       if (!agent)
-               err(1, "preparing agent");
 
        tdb = tdb_open_ex("run-nested-traverse.tdb", 1024, TDB_CLEAR_IF_FIRST,
                          O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
index d46b216ccdc57515d89071ee39a40a47e490cf29..a825e6269d75f1f8d3dfa6c0914f4ebb7bd4fe05 100644 (file)
@@ -149,8 +149,6 @@ int main(int argc, char *argv[])
 
        plan_tests(20);
        agent = prepare_external_agent();
-       if (!agent)
-               err(1, "preparing agent");
 
        unlock_callback = after_unlock;
        for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) {
index 7813a6ce9a544f4bec960e0b112fdea109c592b6..bcdc3545cd5b27148e8d118c0d4e95977a4d3470 100644 (file)
@@ -47,8 +47,6 @@ int main(int argc, char *argv[])
 
        plan_tests(13);
        agent = prepare_external_agent();
-       if (!agent)
-               err(1, "preparing agent");
 
        tdb = tdb_open_ex("run-traverse-in-transaction.tdb",
                          1024, TDB_CLEAR_IF_FIRST, O_CREAT|O_TRUNC|O_RDWR,
index 12d5f942b7ab99e9065cbabe0c08880b3475f3df..d9ed6e84ea5e88f58cf2aa67cbc8a8158d493820 100644 (file)
@@ -22,7 +22,6 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 #include <stdio.h>
-#include <err.h>
 
 #ifndef __location__
 #define __TAP_STRING_LINE1__(s)    #s
@@ -32,9 +31,9 @@
 #endif
 
 #define plan_tests(num)
-#define ok(e, ...) ((e) ? (void)printf(".") : errx(1, __VA_ARGS__))
+#define ok(e, ...) do { if (e) { (void)printf("."); } else { fprintf(stderr, __VA_ARGS__); exit(1); } } while(0)
 #define ok1(e) ok((e), "%s:%s", __location__, #e)
 #define pass(...) printf(".")
-#define fail(...) errx(1, __VA_ARGS__)
+#define fail(...) do { fprintf(stderr, __VA_ARGS__); exit(1); } while(0)
 #define diag printf
 #define exit_status() 0