Răsfoiți Sursa

ncd: modules: use NCDModuleInst_Backend_GetUser() to get the base object for in methods

ambrop7 14 ani în urmă
părinte
comite
81de98b4bc

+ 3 - 3
ncd/modules/blocker.c

@@ -194,7 +194,7 @@ static void updown_func_new_templ (NCDModuleInst *i, int up, int first_down)
     NCDModuleInst_Backend_Up(i);
     
     // get method object
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     if (first_down || mo->up != up) {
         // signal users
@@ -258,7 +258,7 @@ static void rdownup_func_new (NCDModuleInst *i)
     }
     
     // get blocker
-    struct instance *blk = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *blk = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // set blocker
     o->blocker = blk;
@@ -328,7 +328,7 @@ static void use_func_new (NCDModuleInst *i)
     }
     
     // set blocker
-    o->blocker = ((NCDModuleInst *)i->method_user)->inst_user;
+    o->blocker = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // add to blocker's list
     LinkedList2_Append(&o->blocker->users, &o->blocker_node);

+ 1 - 1
ncd/modules/call.c

@@ -245,7 +245,7 @@ static void func_new (NCDModuleInst *i)
                                         (NCDModuleProcess_func_getspecialobj)process_func_getspecialobj);
         
         // set callrefhere
-        o->crh = (o->i->method_user ? ((NCDModuleInst *)i->method_user)->inst_user : NULL);
+        o->crh = (o->i->method_user ? NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user) : NULL);
         
         // add to callrefhere's calls list
         if (o->crh) {

+ 1 - 1
ncd/modules/index.c

@@ -119,7 +119,7 @@ fail0:
 
 static void func_new_from_index (NCDModuleInst *i)
 {
-    struct instance *index = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *index = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // check overflow
     if (index->value == SIZE_MAX) {

+ 10 - 10
ncd/modules/list.c

@@ -285,7 +285,7 @@ static void append_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // append
     NCDValue v;
@@ -322,7 +322,7 @@ static void appendv_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // append
     NCDValue l;
@@ -365,7 +365,7 @@ static void length_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // remember length
     o->length = NCDValue_ListCount(&mo->list);
@@ -442,7 +442,7 @@ static void get_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // check index
     if (index >= NCDValue_ListCount(&mo->list)) {
@@ -507,7 +507,7 @@ static void shift_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // shift
     if (!NCDValue_ListFirst(&mo->list)) {
@@ -547,7 +547,7 @@ static void contains_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // search
     o->contains = 0;
@@ -631,7 +631,7 @@ static void find_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // search
     o->is_found = 0;
@@ -723,7 +723,7 @@ static void removeat_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // check position
     if (remove_pos >= NCDValue_ListCount(&mo->list)) {
@@ -761,7 +761,7 @@ static void remove_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // find value
     NCDValue *e = find_in_list(&mo->list, value_arg);
@@ -795,7 +795,7 @@ static void set_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // replace list
     NCDValue_Free(&mo->list);

+ 1 - 1
ncd/modules/net_iptables.c

@@ -490,7 +490,7 @@ static void unlock_func_new (NCDModuleInst *i)
     o->i = i;
     
     // get lock lock
-    struct lock_instance *lock = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct lock_instance *lock = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // make sure lock doesn't already have an unlock
     if (lock->unlock) {

+ 1 - 1
ncd/modules/net_watch_interfaces.c

@@ -445,7 +445,7 @@ static void nextevent_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // make sure we are currently reporting an event
     if (!event_template_is_enabled(&mo->templ)) {

+ 1 - 1
ncd/modules/ondemand.c

@@ -321,7 +321,7 @@ static void demand_func_new (NCDModuleInst *i)
     }
     
     // set ondemand
-    o->od = ((NCDModuleInst *)i->method_user)->inst_user;
+    o->od = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // add to ondemand's demands list
     LinkedList1_Append(&o->od->demands_list, &o->demands_list_node);

+ 2 - 2
ncd/modules/process_manager.c

@@ -489,7 +489,7 @@ static void start_func_new (NCDModuleInst *i)
     NCDModuleInst_Backend_Up(i);
     
     // get method object
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     if (mo->dying) {
         ModuleLog(i, BLOG_INFO, "manager is dying, not creating process %s", name);
@@ -538,7 +538,7 @@ static void stop_func_new (NCDModuleInst *i)
     NCDModuleInst_Backend_Up(i);
     
     // get method object
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     if (mo->dying) {
         ModuleLog(i, BLOG_INFO, "manager is dying, not stopping process %s", name);

+ 2 - 2
ncd/modules/ref.c

@@ -169,14 +169,14 @@ fail0:
 
 static void ref_func_new_from_refhere (NCDModuleInst *i)
 {
-    struct refhere_instance *rh = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct refhere_instance *rh = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     return ref_func_new_templ(i, rh);
 }
 
 static void ref_func_new_from_ref (NCDModuleInst *i)
 {
-    struct ref_instance *ref = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct ref_instance *ref = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     return ref_func_new_templ(i, ref->rh);
 }

+ 1 - 1
ncd/modules/sys_evdev.c

@@ -318,7 +318,7 @@ static void nextevent_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // make sure we are currently reporting an event
     if (!mo->processing) {

+ 1 - 1
ncd/modules/sys_request_client.c

@@ -648,7 +648,7 @@ static void request_func_new (NCDModuleInst *i)
     o->args = args_arg;
     
     // get client
-    struct instance *client = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *client = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     o->client = client;
     
     // check client state

+ 1 - 1
ncd/modules/sys_watch_directory.c

@@ -390,7 +390,7 @@ static void nextevent_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // make sure we are currently reporting an event
     if (!mo->processing) {

+ 1 - 1
ncd/modules/sys_watch_input.c

@@ -424,7 +424,7 @@ static void nextevent_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // make sure we are currently reporting an event
     if (!event_template_is_enabled(&mo->templ)) {

+ 1 - 1
ncd/modules/sys_watch_usb.c

@@ -392,7 +392,7 @@ static void nextevent_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // make sure we are currently reporting an event
     if (!event_template_is_enabled(&mo->templ)) {

+ 8 - 8
ncd/modules/value.c

@@ -1028,7 +1028,7 @@ static void func_new_get (NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1057,7 +1057,7 @@ static void func_new_try_get (NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1087,7 +1087,7 @@ static void func_new_getpath (NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1117,7 +1117,7 @@ static void func_new_insert (NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1192,7 +1192,7 @@ static void func_new_insert_undo (NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1251,7 +1251,7 @@ static void func_new_substr (NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1293,7 +1293,7 @@ static void remove_func_new (NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {
@@ -1320,7 +1320,7 @@ static void delete_func_new (NCDModuleInst *i)
         goto fail0;
     }
     
-    struct instance *mo = ((NCDModuleInst *)i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     struct value *mov = valref_val(&mo->ref);
     
     if (!mov) {

+ 1 - 1
ncd/modules/var.c

@@ -129,7 +129,7 @@ static void set_func_new (NCDModuleInst *i)
     }
     
     // get method object
-    struct instance *mo = ((NCDModuleInst * )i->method_user)->inst_user;
+    struct instance *mo = NCDModuleInst_Backend_GetUser((NCDModuleInst *)i->method_user);
     
     // copy value
     NCDValue v;