commit 5f212c885e2b5371b93f200a39697aba2e5aad43
parent e4f4612ef85c7099e0ef944d48a2916574bc9d51
Author: leitner <leitner>
Date: Tue, 13 May 2003 20:14:27 +0000
remove compiler warnings
Diffstat:
9 files changed, 29 insertions(+), 65 deletions(-)
diff --git a/CHANGES b/CHANGES
@@ -3,6 +3,7 @@
control/ctrlaltdel-run (Florian Westphal)
add killall5, needs /proc on Linux though (Florian Westphal)
add shutdown
+ add -Wall and -W and kill resulting compiler warnings
0.9.1:
fix embarassing typo in msvc (Gelu G. Lupas)
diff --git a/Makefile b/Makefile
@@ -1,9 +1,9 @@
all: minit msvc pidfilehack hard-reboot write_proc killall5 shutdown
#CFLAGS=-pipe -march=i386 -fomit-frame-pointer -Os -I../dietlibc/include
-DIET=diet
+DIET=/opt/diet/bin/diet
CC=gcc
-CFLAGS=-pipe -fomit-frame-pointer -Os
+CFLAGS=-Wall -W -pipe -fomit-frame-pointer -Os
CROSS=
#CROSS=arm-linux-
LDFLAGS=-s
diff --git a/hard-reboot.c b/hard-reboot.c
@@ -1,5 +1,6 @@
#include <unistd.h>
#include <sys/reboot.h>
+#include <stdlib.h>
#define ABORTMSG "hard-reboot: Aborted.\n"
#define USAGE "Say \"hard-reboot (RESTART|HALT|POWER_OFF)\" if you really mean it.\n"
diff --git a/minit.c b/minit.c
@@ -13,6 +13,9 @@
#include <stdio.h>
#include <linux/kd.h>
#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <alloca.h>
+#include <sys/reboot.h>
#include "fmt.h"
#include "str.h"
@@ -115,7 +118,7 @@ int loadservice(char *service) {
tmp.__stdout=pipefd[1];
}
}
- addprocess(&tmp);
+ return addprocess(&tmp);
}
/* usage: isup(findservice("sshd")).
@@ -125,6 +128,8 @@ int isup(int service) {
return (root[service].pid!=0);
}
+int startservice(int service,int pause);
+
#undef debug
void handlekilled(pid_t killed) {
int i;
@@ -189,7 +194,6 @@ again:
/* child */
if (i_am_init) {
- int fd;
ioctl(0, TIOCNOTTY, 0);
setsid();
opendevconsole();
@@ -252,12 +256,8 @@ again:
/* start a service, return nonzero on error */
int startnodep(int service,int pause) {
- pid_t p;
/* step 1: see if the process is already up */
if (isup(service)) return 0;
-#if 0
- printf("launching %s\n",root[service].name);
-#endif
/* step 2: fork and exec service, put PID in data structure */
if (chdir(MINITROOT) || chdir(root[service].name)) return -1;
root[service].startedat=time(0);
@@ -266,16 +266,11 @@ int startnodep(int service,int pause) {
}
int startservice(int service,int pause) {
- int dir=-1,fd;
+ int dir=-1;
unsigned long len;
char *s=0;
pid_t pid;
if (service<0) return 0;
-#if 0
- write(1,"startservice ",13);
- write(1,root[service].name,str_len(root[service].name));
- write(1,"\n",1);
-#endif
if (root[service].circular)
return 0;
root[service].circular=1;
@@ -350,11 +345,11 @@ void childhandler() {
static volatile int dowinch=0;
static volatile int doint=0;
-void sigchild(int whatever) { }
-void sigwinch(int sig) { dowinch=1; }
-void sigint(int sig) { doint=1; }
+void sigchild(int sig) { (void)sig; }
+void sigwinch(int sig) { (void)sig; dowinch=1; }
+void sigint(int sig) { (void)sig; doint=1; }
-main(int argc, char *argv[]) {
+int main(int argc, char *argv[]) {
/* Schritt 1: argv[1] als Service nehmen und starten */
int count=0;
int i;
@@ -366,7 +361,6 @@ main(int argc, char *argv[]) {
outfd=open("/etc/minit/out",O_RDWR|O_NONBLOCK);
if (getpid()==1) {
int fd;
- pid_t p;
i_am_init=1;
reboot(0);
if ((fd=open("/dev/console",O_RDWR|O_NOCTTY))) {
@@ -401,7 +395,6 @@ main(int argc, char *argv[]) {
circsweep();
if (!count) startservice(loadservice("default"),0);
for (;;) {
- int status;
int i;
char buf[1501];
time_t now;
@@ -420,40 +413,8 @@ main(int argc, char *argv[]) {
long diff=last-now;
int j;
-#if 0
- strcpy(buf,"minit: compensating for clock drift: ");
- i=str_len(buf);
- if (diff<0) { diff=-diff; buf[i]='-'; ++i; }
- buf[i+fmt_ulong(buf+i,diff)]=0;
- strcat(buf," sec.\r\n");
- _puts(buf);
- buf[fmt_ulong(buf,maxprocess)]=0;
- strcat(buf," processes.\r\n");
- _puts(buf);
-#endif
-
- for (j=0; j<=maxprocess; ++j) {
-#if 0
- strcpy(buf,"minit: setting ");
- strcat(buf,root[j].name);
- strcat(buf," from ");
- i=str_len(buf);
- buf[i+fmt_ulong(buf+i,root[j].startedat)]=0;
- strcat(buf," to ");
-#endif
-
+ for (j=0; j<=maxprocess; ++j)
root[j].startedat-=diff;
-
-#if 0
- i=str_len(buf);
- buf[i+fmt_ulong(buf+i,root[j].startedat)]=0;
- strcat(buf," [pid ");
- i=str_len(buf);
- buf[i+fmt_ulong(buf+i,root[j].pid)]=0;
- strcat(buf,"].\r\n");
- _puts(buf);
-#endif
- }
}
last=now;
switch (poll(&pfd,nfds,5000)) {
diff --git a/msvc.c b/msvc.c
@@ -3,6 +3,7 @@
#include <signal.h>
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include "str.h"
#include "fmt.h"
#include "buffer.h"
@@ -84,8 +85,7 @@ unsigned long uptime(char *service) {
return atoi(buf);
}
-main(int argc,char *argv[]) {
- int len;
+int main(int argc,char *argv[]) {
if (argc<2) {
buffer_putsflush(buffer_1,
"usage: msvc -[uodpchaitkogC] service\n"
@@ -181,7 +181,7 @@ main(int argc,char *argv[]) {
ret=1;
} else if (pid==1)
continue;
- if (respawn(argv[i],0) || kill(pid,SIGTERM) || kill(pid,SIGCONT));
+ if (respawn(argv[i],0) || kill(pid,SIGTERM) || kill(pid,SIGCONT)) (void)0;
}
break;
case 'u':
@@ -230,7 +230,6 @@ dokill:
buffer_puts(buffer_2," to PID ");
buffer_putulong(buffer_2,pid);
buffer_putsflush(buffer_2,"\n");
-error:
ret=1;
}
}
diff --git a/openreadclose.c b/openreadclose.c
@@ -1,6 +1,7 @@
#ifndef EMBEDDED
#include <unistd.h>
#include <sys/fcntl.h>
+#include <stdlib.h>
#endif
int openreadclose(char *fn, char **buf, unsigned long *len) {
diff --git a/pidfilehack.c b/pidfilehack.c
@@ -2,6 +2,7 @@
#include <errno.h>
#include <stdlib.h>
#include <sys/fcntl.h>
+#include <stdio.h>
/* purpose: argv[1] is the full path to a PID file,
* argv+2 is the daemon to run.
@@ -34,7 +35,6 @@ int main(int argc, char* argv[]) {
}
do {
int fd=open(argv[2],O_RDONLY);
- pid_t p;
if (fd>=0) {
static char buf[100] = "-P";
int len=read(fd,buf+2,100);
diff --git a/shutdown.c b/shutdown.c
@@ -18,12 +18,14 @@
* - cleanup
*/
+#include <sys/types.h>
#include <sys/reboot.h>
#include <signal.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/wait.h>
#ifdef __dietlibc__
#include <write12.h>
@@ -80,7 +82,7 @@ int minit_serviceDown(char *service) {
unsigned long len;
pid_t pid=0;
- if (service < 0) return 0;
+ if (!service || !*service) return 0;
if (chdir(MINITROOT) || chdir(service)) return -1;
if (!openreadclose("depends", &s, &len)) {
@@ -114,10 +116,10 @@ int minit_serviceDown(char *service) {
if (i == 0) __write2("\t\tdone\n");
else __write2("\t\tfailed\n");
}
+ return 0;
}
int minit_shutdown(int level) {
- char* service;
__write2("Shutting down minit services: \n");
infd=open("/etc/minit/in", O_WRONLY);
outfd=open("/etc/minit/out", O_RDONLY);
@@ -128,10 +130,7 @@ int minit_shutdown(int level) {
}
}
- if (!level)
- minit_serviceDown("reboot");
- else
- minit_serviceDown("halt");
+ return minit_serviceDown(level?"halt":"reboot");
}
#endif
@@ -146,7 +145,7 @@ void printUsage() {
"\t -t secs: delay between SIGTERM and SIGKILL\n");
}
-main(int argc, char *const argv[]) {
+int main(int argc, char *const argv[]) {
int c;
int cfg_downlevel=2;
/* 0: reboot
@@ -257,4 +256,5 @@ main(int argc, char *const argv[]) {
} else {
reboot(RB_POWER_OFF);
}
+ return 0;
}
diff --git a/split.c b/split.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
/* split buf into n strings that are separated by c. return n as *len.
* Allocate plus more slots and leave the first ofs of them alone. */