Browse Source

ncd: cosmetic changes

ambrop7 13 năm trước cách đây
mục cha
commit
8f4ede1dbb

+ 1 - 4
ncd/modules/blocker.c

@@ -110,10 +110,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // check arguments
     if (!NCDVal_ListRead(o->i->args, 0)) {
@@ -135,7 +133,6 @@ static void func_new (NCDModuleInst *i)
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
-    
     return;
     
 fail1:

+ 1 - 3
ncd/modules/call.c

@@ -201,10 +201,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // check arguments
     NCDValRef template_name_arg;

+ 1 - 3
ncd/modules/choose.c

@@ -62,10 +62,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef arg_choices;

+ 1 - 4
ncd/modules/concat.c

@@ -58,10 +58,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // init string
     ExpString s;
@@ -92,7 +90,6 @@ static void func_new (NCDModuleInst *i)
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
-    
     return;
     
 fail2:

+ 1 - 4
ncd/modules/concatv.c

@@ -58,10 +58,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef strings_arg;
@@ -103,7 +101,6 @@ static void func_new (NCDModuleInst *i)
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
-    
     return;
     
 fail2:

+ 2 - 6
ncd/modules/depend.c

@@ -173,10 +173,8 @@ static void provide_func_new_templ (NCDModuleInst *i, int event)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef name_arg;
@@ -306,10 +304,8 @@ static void depend_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef name_arg;

+ 1 - 3
ncd/modules/dynamic_depend.c

@@ -391,10 +391,8 @@ static void depend_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef name_arg;

+ 1 - 3
ncd/modules/imperative.c

@@ -232,10 +232,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // check arguments
     NCDValRef init_template_arg;

+ 2 - 2
ncd/modules/index.c

@@ -68,10 +68,10 @@ static void func_new_templ (NCDModuleInst *i, size_t value)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
+    o->i = i;
     NCDModuleInst_Backend_SetUser(i, o);
     
-    // init arguments
-    o->i = i;
+    // set value
     o->value = value;
     
     // signal up

+ 1 - 4
ncd/modules/ip_in_network.c

@@ -59,10 +59,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef arg_addr1;
@@ -99,7 +97,6 @@ static void func_new (NCDModuleInst *i)
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
-    
     return;
     
 fail1:

+ 1 - 4
ncd/modules/logical.c

@@ -65,10 +65,8 @@ static void func_new (NCDModuleInst *i, int is_not, int is_or)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // compute value from arguments
     if (is_not) {
@@ -107,7 +105,6 @@ static void func_new (NCDModuleInst *i, int is_not, int is_or)
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
-    
     return;
     
 fail1:

+ 2 - 6
ncd/modules/multidepend.c

@@ -163,10 +163,8 @@ static void provide_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef name_arg;
@@ -267,10 +265,8 @@ static void depend_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef names_arg;

+ 1 - 4
ncd/modules/net_dns.c

@@ -211,10 +211,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // init servers list
     LinkedList2_Init(&o->ipv4_dns_servers);
@@ -266,7 +264,6 @@ static void func_new (NCDModuleInst *i)
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
-    
     return;
     
 fail2:

+ 1 - 3
ncd/modules/net_iptables.c

@@ -387,10 +387,8 @@ static void func_new (NCDModuleInst *i, command_template_build_cmdline build_cmd
         BLog(BLOG_ERROR, "malloc failed");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     command_template_new(&o->cti, i, build_cmdline, template_free_func, o, BLOG_CURRENT_CHANNEL, &iptables_lock);
     return;

+ 1 - 4
ncd/modules/net_ipv4_addr.c

@@ -57,10 +57,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef ifname_arg;
@@ -92,7 +90,6 @@ static void func_new (NCDModuleInst *i)
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
-    
     return;
     
 fail1:

+ 1 - 3
ncd/modules/net_ipv4_arp_probe.c

@@ -126,10 +126,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef arg_ifname;

+ 1 - 4
ncd/modules/net_ipv4_dhcp.c

@@ -103,10 +103,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // check arguments
     NCDValRef ifname_arg;
@@ -173,7 +171,6 @@ static void func_new (NCDModuleInst *i)
     
     // set not up
     o->up = 0;
-    
     return;
     
 fail1:

+ 1 - 4
ncd/modules/net_ipv4_route.c

@@ -70,10 +70,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read arguments
     NCDValRef dest_arg;
@@ -143,7 +141,6 @@ static void func_new (NCDModuleInst *i)
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
-    
     return;
     
 fail1:

+ 1 - 4
ncd/modules/sleep.c

@@ -76,10 +76,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // check arguments
     NCDValRef ms_start_arg;
@@ -109,7 +107,6 @@ static void func_new (NCDModuleInst *i)
     
     // set timer
     BReactor_SetTimerAfter(o->i->iparams->reactor, &o->timer, o->ms_start);
-    
     return;
     
 fail1:

+ 2 - 2
ncd/modules/sys_request_client.c

@@ -546,7 +546,7 @@ static void func_new (NCDModuleInst *i)
     // allocate structure
     struct instance *o = malloc(sizeof(*o));
     if (!o) {
-        ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
+        ModuleLog(i, BLOG_ERROR, "malloc failed");
         goto fail0;
     }
     o->i = i;
@@ -622,7 +622,7 @@ static void request_func_new (NCDModuleInst *i)
     // allocate structure
     struct request_instance *o = malloc(sizeof(*o));
     if (!o) {
-        ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
+        ModuleLog(i, BLOG_ERROR, "malloc failed");
         goto fail0;
     }
     o->i = i;

+ 2 - 2
ncd/modules/sys_request_server.c

@@ -579,7 +579,7 @@ static struct reply * reply_init (struct connection *c, uint32_t request_id, NCD
     }
     
     if (!ExpString_AppendZeros(&str, sizeof(struct reply_header))) {
-        ModuleLog(o->i, BLOG_ERROR, "ExpString_AppendBinary failed");
+        ModuleLog(o->i, BLOG_ERROR, "ExpString_AppendZeros failed");
         goto fail2;
     }
     
@@ -733,7 +733,7 @@ static void func_new (NCDModuleInst *i)
     // allocate structure
     struct instance *o = malloc(sizeof(*o));
     if (!o) {
-        ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
+        ModuleLog(i, BLOG_ERROR, "malloc failed");
         goto fail0;
     }
     o->i = i;

+ 2 - 4
ncd/modules/var.c

@@ -60,10 +60,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "failed to allocate instance");
         goto fail0;
     }
-    NCDModuleInst_Backend_SetUser(i, o);
-    
-    // init arguments
     o->i = i;
+    NCDModuleInst_Backend_SetUser(i, o);
     
     // read argument
     NCDValRef value_arg;
@@ -116,7 +114,7 @@ static int func_getvar (void *vo, const char *name, NCDValMem *mem, NCDValRef *o
     if (!strcmp(name, "")) {
         *out = NCDVal_NewCopy(mem, o->value);
         if (NCDVal_IsInvalid(*out)) {
-            ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitCopy failed");
+            ModuleLog(o->i, BLOG_ERROR, "NCDVal_NewCopy failed");
         }
         return 1;
     }