Prechádzať zdrojové kódy

mainconfig: check error return codes from logsys_format_set

and avoid yet another gcc warning

Reviewed-by: Steven Dake <sdake@redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Fabio M. Di Nitto 14 rokov pred
rodič
commit
55d97fd8cb
1 zmenil súbory, kde vykonal 16 pridanie a 1 odobranie
  1. 16 1
      exec/mainconfig.c

+ 16 - 1
exec/mainconfig.c

@@ -138,7 +138,7 @@ static int corosync_main_config_format_set (
 	const char *error_reason;
 	char new_format_buffer[PATH_MAX];
 	char *value = NULL;
-	cs_error_t err;
+	int err = 0;
 
 	if (icmap_get_string("logging.fileline", &value) == CS_OK) {
 		if (strcmp (value, "on") == 0) {
@@ -163,6 +163,11 @@ static int corosync_main_config_format_set (
 		free(value);
 	}
 
+	if (err) {
+		error_reason = "not enough memory to set logging format buffer";
+		goto parse_error;
+	}
+
 	if (icmap_get_string("logging.function_name", &value) == CS_OK) {
 		if (strcmp (value, "on") == 0) {
 			if (!insert_into_buffer(new_format_buffer,
@@ -186,6 +191,11 @@ static int corosync_main_config_format_set (
 		free(value);
 	}
 
+	if (err) {
+		error_reason = "not enough memory to set logging format buffer";
+		goto parse_error;
+	}
+
 	if (icmap_get_string("logging.timestamp", &value) == CS_OK) {
 		if (strcmp (value, "on") == 0) {
 			if(!insert_into_buffer(new_format_buffer,
@@ -204,6 +214,11 @@ static int corosync_main_config_format_set (
 		free(value);
 	}
 
+	if (err) {
+		error_reason = "not enough memory to set logging format buffer";
+		goto parse_error;
+	}
+
 	return (0);
 
 parse_error: