Browse Source

ctl: refactored error handling and removed unnecessary code

(cherry picked from commit edbb5b11e9453be3519e6e9a945937307c95709e)
(cherry picked from commit 691eb2600c1fcf24d0d1f9b2648e7257499537a8)
(cherry picked from commit 83a4165fc62710027ddf006058c66f082d01b51f)
Daniel-Constantin Mierla 7 months ago
parent
commit
efec4195cb
1 changed files with 5 additions and 6 deletions
  1. 5 6
      src/modules/ctl/fifo_server.c

+ 5 - 6
src/modules/ctl/fifo_server.c

@@ -1288,7 +1288,7 @@ static int rpc_struct_printf(struct text_chunk *c, char *name, char *fmt, ...)
 					&nm, 1); /* Escape all characters, including : and , */
 			if(!m) {
 				rpc_fault(ctx, 500, "Internal Server Error");
-				goto err;
+				goto error;
 			}
 
 			s.s = buf;
@@ -1298,7 +1298,7 @@ static int rpc_struct_printf(struct text_chunk *c, char *name, char *fmt, ...)
 				rpc_fault(ctx, 500, "Internal Server Error");
 				free_chunk(m);
 				ERR("Error while creating text_chunk structure");
-				goto err;
+				goto error;
 			}
 
 			l->flags |= CHUNK_MEMBER_VALUE;
@@ -1324,13 +1324,12 @@ static int rpc_struct_printf(struct text_chunk *c, char *name, char *fmt, ...)
 		if((buf0 = ctl_realloc(buf, buf_size)) == 0) {
 			rpc_fault(ctx, 500, "Internal Server Error (No memory left)");
 			ERR("No memory left\n");
-			goto err;
+			goto error;
 		}
 		buf = buf0;
 	}
-	ctl_free(buf);
-	return 0;
-err:
+
+error:
 	if(buf)
 		ctl_free(buf);
 	return -1;