Explorar o código

dispatcher: declare vars at beginning of the block in rpc command

Daniel-Constantin Mierla %!s(int64=7) %!d(string=hai) anos
pai
achega
c73a22abb1
Modificáronse 1 ficheiros con 9 adicións e 9 borrados
  1. 9 9
      src/modules/dispatcher/dispatcher.c

+ 9 - 9
src/modules/dispatcher/dispatcher.c

@@ -1275,16 +1275,7 @@ static const char *dispatcher_rpc_list_doc[2] = {
  */
 int ds_rpc_print_set(ds_set_t *node, rpc_t *rpc, void *ctx, void *rpc_handle)
 {
-	if(!node)
-		return 0;
-
 	int i = 0, rc = 0;
-	for(; i < 2; ++i) {
-		rc = ds_rpc_print_set(node->next[i], rpc, ctx, rpc_handle);
-		if(rc != 0)
-			return rc;
-	}
-
 	void *rh;
 	void *sh;
 	void *vh;
@@ -1294,6 +1285,15 @@ int ds_rpc_print_set(ds_set_t *node, rpc_t *rpc, void *ctx, void *rpc_handle)
 	char c[3];
 	str data = STR_NULL;
 
+	if(!node)
+		return 0;
+
+	for(; i < 2; ++i) {
+		rc = ds_rpc_print_set(node->next[i], rpc, ctx, rpc_handle);
+		if(rc != 0)
+			return rc;
+	}
+
 	if(rpc->struct_add(rpc_handle, "{", "SET", &sh) < 0) {
 		rpc->fault(ctx, 500, "Internal error set structure");
 		return -1;