com_init(): Return negative on errors
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 5 Apr 2015 13:40:12 +0000 (13:40 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 12 Aug 2015 21:23:48 +0000 (23:23 +0200)
afs.c

diff --git a/afs.c b/afs.c
index a5ec7b2..0c61574 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -1033,7 +1033,7 @@ out:
        exit(EXIT_FAILURE);
 }
 
-static int create_tables_callback(int fd, const struct osl_object *query)
+static int com_init_callback(int fd, const struct osl_object *query)
 {
        uint32_t table_mask = *(uint32_t *)query->data;
        int i, ret;
@@ -1054,16 +1054,18 @@ static int create_tables_callback(int fd, const struct osl_object *query)
                if (!t->create)
                        continue;
                ret = t->create(database_dir);
-               if (ret < 0)
+               if (ret < 0) {
+                       para_printf(&pb, "cannot create table %s\n", t->name);
                        goto out;
+               }
                para_printf(&pb, "successfully created %s table\n", t->name);
        }
        ret = open_afs_tables();
-out:
        if (ret < 0)
-               para_printf(&pb, "%s\n", para_strerror(-ret));
+               para_printf(&pb, "cannot open afs tables\n");
+out:
        flush_and_free_pb(&pb);
-       return 0;
+       return ret;
 }
 
 int com_init(struct command_context *cc)
@@ -1091,7 +1093,7 @@ int com_init(struct command_context *cc)
                                return -E_BAD_TABLE_NAME;
                }
        }
-       return send_callback_request(create_tables_callback, &query,
+       return send_callback_request(com_init_callback, &query,
                afs_cb_result_handler, cc);
 }