service: get rid of service_init and service_validate_init, use static avl tree initi...
authorFelix Fietkau <nbd@openwrt.org>
Sat, 5 Mar 2016 13:08:59 +0000 (14:08 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 5 Mar 2016 13:08:59 +0000 (14:08 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
service/service.c
service/service.h
service/validate.c
state.c

index 2702dc38286fbd80852a9a21d1ab458aee01c6a9..0796adbb717f1ce0285aceb7c4ce5a3c976c5dfc 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "../rcS.h"
 
-struct avl_tree services;
+AVL_TREE(services, avl_strcmp, false, NULL);
 static struct blob_buf b;
 static struct ubus_context *ctx;
 
@@ -552,11 +552,3 @@ void ubus_init_service(struct ubus_context *_ctx)
        ctx = _ctx;
        ubus_add_object(ctx, &main_object);
 }
-
-void
-service_init(void)
-{
-       avl_init(&services, avl_strcmp, false, NULL);
-       service_validate_init();
-}
-
index 892a1473e04161a8df46f0ebd289c696eaa2b98a..c3f2964ef6dbb805a0a8528b9e7246ee94d536ae 100644 (file)
@@ -51,8 +51,6 @@ void service_validate_dump(struct blob_buf *b, struct service *s);
 void service_validate_dump_all(struct blob_buf *b, char *p, char *s);
 int service_start_early(char *name, char *cmdline);
 void service_validate_del(struct service *s);
-void service_validate_init(void);
-void service_init(void);
 void service_event(const char *type, const char *service, const char *instance);
 
 #endif
index 6a449f43bd875d3809aeab707d211cd932291d27..cf04490f98f13962d80c9decedc110acc34c48ed 100644 (file)
@@ -32,7 +32,7 @@ static const struct blobmsg_policy service_validate_attrs[__SERVICE_VAL_MAX] = {
        [SERVICE_VAL_DATA] = { "data", BLOBMSG_TYPE_TABLE },
 };
 
-static struct avl_tree validators;
+static AVL_TREE(validators, avl_strcmp, true, NULL);
 
 void
 service_validate_dump_all(struct blob_buf *b, char *p, char *s)
@@ -155,9 +155,3 @@ service_validate_add(struct service *s, struct blob_attr *msg)
                        free(vr);
        }
 }
-
-void
-service_validate_init(void)
-{
-       avl_init(&validators, avl_strcmp, true, NULL);
-}
diff --git a/state.c b/state.c
index d51970e952d5a3326020aaf5745463d1e5f3cf5b..4ad9e2d8d32156c84f8e5c47c17525bd71745948 100644 (file)
--- a/state.c
+++ b/state.c
@@ -111,7 +111,6 @@ static void state_enter(void)
                set_stdio("console");
                LOG("- ubus -\n");
                procd_connect_ubus();
-               service_init();
                service_start_early("ubus", ubus_cmd);
                break;