(svn r2818) Don't tell the world about a local variable which is only used once
authortron
Sat, 06 Aug 2005 16:55:05 +0000
changeset 2294 4b7408a29936
parent 2293 b48192aec903
child 2295 95e8858e9938
(svn r2818) Don't tell the world about a local variable which is only used once
dedicated.c
variables.h
--- a/dedicated.c	Sat Aug 06 16:07:22 2005 +0000
+++ b/dedicated.c	Sat Aug 06 16:55:05 2005 +0000
@@ -20,25 +20,28 @@
 		case -1:
 			perror("Unable to fork");
 			exit(1);
-		case 0:
-			// We're the child
+
+		case 0: { // We're the child
+			FILE* f;
 
 			/* Open the log-file to log all stuff too */
-			_log_file_fd = fopen(_log_file, "a");
-			if (!_log_file_fd) {
+			f = fopen(_log_file, "a");
+			if (f == NULL) {
 				perror("Unable to open logfile");
 				exit(1);
 			}
 			/* Redirect stdout and stderr to log-file */
-			if (dup2(fileno(_log_file_fd), fileno(stdout)) == -1) {
+			if (dup2(fileno(f), fileno(stdout)) == -1) {
 				perror("Rerouting stdout");
 				exit(1);
 			}
-			if (dup2(fileno(_log_file_fd), fileno(stderr)) == -1) {
+			if (dup2(fileno(f), fileno(stderr)) == -1) {
 				perror("Rerouting stderr");
 				exit(1);
 			}
 			break;
+		}
+
 		default:
 			// We're the parent
 			printf("Loading dedicated server...\n");
--- a/variables.h	Sat Aug 06 16:07:22 2005 +0000
+++ b/variables.h	Sat Aug 06 16:55:05 2005 +0000
@@ -346,7 +346,6 @@
 VARDEF char *_config_file;
 VARDEF char *_highscore_file;
 VARDEF char *_log_file;
-VARDEF FILE *_log_file_fd;
 
 // NOSAVE: These can be recalculated from InitializeLandscapeVariables
 typedef struct {