openvpnctrl: Fix some compiler warnings.

(Hopefully) no functional changes.
This commit is contained in:
Michael Tremer
2011-06-29 19:58:01 +02:00
parent 858d8d9092
commit 80ca8bd0f5

View File

@@ -122,6 +122,20 @@ connection *getConnections() {
return conn_first; return conn_first;
} }
int readPidFile(const char *pidfile) {
FILE *fp = fopen(pidfile, "r");
if (fp == NULL) {
fprintf(stderr, "PID file not found: '%s'\n", pidfile);
exit(1);
}
int pid = 0;
fscanf(fp, "%d", &pid);
fclose(fp);
return pid;
}
void ovpnInit(void) { void ovpnInit(void) {
// Read OpenVPN configuration // Read OpenVPN configuration
@@ -358,7 +372,7 @@ void stopDaemon(void) {
char command[STRING_SIZE]; char command[STRING_SIZE];
int pid = readPidFile("/var/run/openvpn.pid"); int pid = readPidFile("/var/run/openvpn.pid");
if (pid == NULL) { if (!pid > 0) {
exit(1); exit(1);
} }
@@ -422,20 +436,6 @@ void startNet2Net(char *name) {
executeCommand(command); executeCommand(command);
} }
int readPidFile(const char *pidfile) {
FILE *fp = fopen(pidfile, "r");
if (fp == NULL) {
fprintf(stderr, "PID file not found: '%s'\n", pidfile);
exit(1);
}
int pid = NULL;
fscanf(fp, "%d", &pid);
fclose(fp);
return pid;
}
void killNet2Net(char *name) { void killNet2Net(char *name) {
connection *conn = NULL; connection *conn = NULL;
connection *conn_iter; connection *conn_iter;
@@ -456,10 +456,10 @@ void killNet2Net(char *name) {
} }
char pidfile[STRING_SIZE]; char pidfile[STRING_SIZE];
snprintf(&pidfile, STRING_SIZE - 1, "/var/run/%sn2n.pid", conn->name); snprintf(pidfile, STRING_SIZE - 1, "/var/run/%sn2n.pid", conn->name);
int pid = readPidFile(pidfile); int pid = readPidFile(pidfile);
if (pid == NULL) { if (!pid > 0) {
exit(1); exit(1);
} }