]> git.neil.brown.name Git - metad.git/commitdiff
Create Makefile and get it to compile with -Wall
authorNeil Brown <neilb@notabene.(none)>
Tue, 6 Jun 2006 10:33:03 +0000 (20:33 +1000)
committerNeil Brown <neilb@notabene.(none)>
Tue, 6 Jun 2006 10:33:03 +0000 (20:33 +1000)
15 files changed:
broadcast.c
commands.c
control.c
daemon.c
error.c
mainloop.c
meta.c
metad.c
metad.h
read_config.c
sendcmd.c
skip.c
strccmp.c
strlistdup.c
strsplit.c

index b1ffeecb2f8d3a2374d13cd04ca7fbe9f33c2d7f..8baf55c79938f5f2232dd7f6faa637c674bc79eb 100644 (file)
@@ -20,8 +20,6 @@ int udp_port(void);
 static struct ifconf   iflist;
 static int interfaces;
 static int sock;
-static char *packet;
-static struct servent *sv;
 
 static int ifconfinit()
 {
@@ -30,14 +28,16 @@ static int ifconfinit()
 
        iflist.ifc_len = sizeof(buf);
        iflist.ifc_buf = buf;
-/*     printf("ifc_len = %d\n", iflist.ifc_len);       /**/
+/*     printf("ifc_len = %d\n", iflist.ifc_len);       / **/
        if (ioctl(sock, SIOCGIFCONF, (char *)&iflist)< 0) return -1;
-/*     printf("ifc_len = %d\n", iflist.ifc_len);       /**/
+/*     printf("ifc_len = %d\n", iflist.ifc_len);       / **/
        interfaces = iflist.ifc_len / sizeof(struct ifreq);
-/*     printf("interfaces = %d\n",interfaces);         /**/
-/*     for (in=0; in<interfaces ; in++) if (iflist.ifc_req[in].ifr_name[0]=='\0') break;
-       interfaces = in;
-/*     printf("interfaces = %d\n",interfaces);         /**/
+#if 0
+/*     printf("interfaces = %d\n",interfaces);         / **/
+/*     for (in=0; in<interfaces ; in++) if (iflist.ifc_req[in].ifr_name[0]=='\0') break; */
+/*     interfaces = in; */
+/*     printf("interfaces = %d\n",interfaces);         / **/
+#endif
        return 0;
 }
 
index e8d93a58e1cd0fc41f70e6961a9e8ef167715b9a..be79f75670e62598017b665008bf8532af2991a8 100644 (file)
@@ -46,14 +46,14 @@ static void do_broad(char **args, char *host, void *con)
     /* remaining args are packaged up and broadcast on all interfaces */
     char *line;
     line = gather_arg(args+1);
-    log(LOG_INFO, "Broadcast request from %s for %s", host, line);
+    logmsg(LOG_INFO, "Broadcast request from %s for %s", host, line);
     broadcast(line);
     free(line);
 }
 
 static void do_die(char **args, char *host, void *con)
 {
-    log(LOG_WARNING, "Die request from %s", host);
+    logmsg(LOG_WARNING, "Die request from %s", host);
     exit(1); /* FIXME */
 }
 
@@ -67,7 +67,7 @@ static void do_disable(char **args, char *host, void *con)
     else for ( ; sv ; sv=find_service(NULL))
        if (sv->enabled)
        {
-           log(LOG_INFO, "Disable request from %s for %s", host, sv->service);
+           logmsg(LOG_INFO, "Disable request from %s for %s", host, sv->service);
            (sv->class->disable_service)(sv);
            sv->enabled = 0;
        }
@@ -83,7 +83,7 @@ static void do_enable(char **args, char *host, void *con)
     else for ( ; sv ; sv=find_service(NULL))
        if (!sv->enabled)
        {
-           log(LOG_INFO, "Enable request from %s for %s", host, sv->service);
+           logmsg(LOG_INFO, "Enable request from %s for %s", host, sv->service);
            (sv->class->register_service)(sv);
            sv->enabled = 1;
        }
@@ -114,7 +114,7 @@ static void do_run(char **args, char *host, void *con)
                 if ((*pp)->hold_time != 0)
                     (*pp)->hold_time = 1;
             sv->next_hold = 2;
-           log(LOG_INFO,"starting %s for %s : arg = %s", sv->service, host, arg);
+           logmsg(LOG_INFO,"starting %s for %s : arg = %s", sv->service, host, arg);
            new_proc(sv, env);
        }
        free(arg);
@@ -142,7 +142,7 @@ static void do_kill(char **args, char *host, void *con)
        proc_t *pp = skip_search(allprocs, &pid);
        if (pp)
        {
-           log(LOG_INFO, "killing %s for %s", args[2], host);
+           logmsg(LOG_INFO, "killing %s for %s", args[2], host);
            if ((*pp)->exit_time == 0)
                kill((*pp)->pid, sig);
            else if ((*pp)->it_forked > 1)
@@ -159,7 +159,7 @@ static void do_kill(char **args, char *host, void *con)
            for (pp = skip_first(sv->proc_list) ; pp ; pp = skip_next(pp))
                if ((*pp)->exit_time == 0 || (*pp)->it_forked)
                {
-                   log(LOG_INFO,
+                   logmsg(LOG_INFO,
                        "signalling %s:%d with %d for %s", sv->service,
                        (*pp)->exit_time?(*pp)->it_forked:(*pp)->pid,
                        sig, host);
@@ -179,7 +179,7 @@ static void do_reread(char **args, char *host, void *con)
 {
     char *errs = NULL;
     int old;
-    log(LOG_INFO, "Rereading config file for %s", host);
+    logmsg(LOG_INFO, "Rereading config file for %s", host);
     old= errors_to(ERROR_STRING, &errs);
     if (read_config(services, NULL) != 0)
        return_error(con, "%s", errs);
@@ -214,7 +214,7 @@ static void do_list(char **args, char *host, void *con)
 
 void do_restart(char **args, char *host, void *con)
 {
-    log(LOG_INFO, "About to restart for %s", host);
+    logmsg(LOG_INFO, "About to restart for %s", host);
     control_close();
     prepare_restart();
     restart();
index 1d629689c07d33b725f6dffe00c4de0f7aeb8a8f..a5e6d55f53f5cb9433156fa22e367caa5252b895 100644 (file)
--- a/control.c
+++ b/control.c
@@ -185,7 +185,7 @@ void check_control(void)
        char host[1024];
        int n;
        struct sockaddr_in sa;
-       int salen = sizeof(sa);
+       unsigned int salen = sizeof(sa);
        n = recvfrom(udp_sock, buf, sizeof(buf)-1, 0, (struct sockaddr *)&sa, &salen );
        if (n>0 && address_ok(&sa, host))
        {
@@ -274,7 +274,7 @@ void check_control(void)
        if (readyon(tcp_listen))
        {
            struct sockaddr_in sa;
-           int salen = sizeof(sa);
+           unsigned int salen = sizeof(sa);
            tcpcon.buflen = 0;
            tcpcon.outbuf = NULL;
            tcpcon.sock = accept(tcp_listen, (struct sockaddr *)&sa, &salen);
index 88c459251418af5235f4fcec1a3d37327b8996ef..c7c016a62ef54dfcbc01815e055a9f724bd37eb5 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -82,7 +82,7 @@ static void daemon_check(service_t sv)
 static void daemon_copy(service_t from, service_t to)
 {
     /* copy the classinfo - min and period */
-    daemon_t n,o;
+    daemon_t n; // o;
     if (from)
     {
         /* no special state to copy
diff --git a/error.c b/error.c
index 43262bbb6c32300f64070ab8ef0df9b2671f4cb2..db8cf0cec495c055a2c0ac9e16b9f8be8af85ec1 100644 (file)
--- a/error.c
+++ b/error.c
@@ -61,9 +61,9 @@ void error(char *mesg, char *a, char *b, char *c)
 }
 
 #ifdef STDARGS
-void log(int level,...)
+void logmsg(int level,...)
 #else
-void log(va_alist)
+void logmsg(va_alist)
 va_dcl
 #endif
 {
@@ -107,6 +107,6 @@ va_dcl
 
 void dolog(service_t sv, proc_t p, char *buf)
 {
-    log(LOG_INFO, "%s: %d: %s\n", sv->service, p->pid, buf);
+    logmsg(LOG_INFO, "%s: %d: %s\n", sv->service, p->pid, buf);
 }
 
index c7ea270e55c2a43159247fd4a3d653b7b3642195..21da64db9737f5ae6547fd203d7357940c166fce 100644 (file)
@@ -122,9 +122,9 @@ void main_loop()
                    (*pp)->status = saved_pids[i].status;
                    (*pp)->exit_time = saved_pids[i].time;;
                    select_tv.tv_sec = 0;
-                   log(LOG_INFO, "process %d (%s) exited - status 0x%04x", saved_pids[i].pid, (*pp)->service->service, (*pp)->status);
+                   logmsg(LOG_INFO, "process %d (%s) exited - status 0x%04x", saved_pids[i].pid, (*pp)->service->service, (*pp)->status);
                } else 
-                   log(LOG_INFO, "process %d exited - status 0x%04x", saved_pids[i].pid, saved_pids[i].status);
+                   logmsg(LOG_INFO, "process %d exited - status 0x%04x", saved_pids[i].pid, saved_pids[i].status);
                saved_pids[i].pid = 0;
 
            }
diff --git a/meta.c b/meta.c
index 29205be847451405641b22e2785aa29f10786851..49a4e4e2cfb6955c4245dd5f01745d57d286b913 100644 (file)
--- a/meta.c
+++ b/meta.c
@@ -85,7 +85,7 @@ void help()
 
 int send_cmd(char *cmd, int udp, char *host, int verbose);
 
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
 {
     void *cmds = dl_head();
     void *hosts = dl_head();
diff --git a/metad.c b/metad.c
index cd44de09f4e91a1069e9f15b84ab6abbedbbfc7b..9586578c4159faec2f8d029378e7861cfecf0b90 100644 (file)
--- a/metad.c
+++ b/metad.c
@@ -7,7 +7,7 @@
 #endif
 char **gargv;
 
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
 {
     gargv = argv;
 
@@ -29,5 +29,5 @@ void main(int argc, char *argv[])
        open("/dev/null", O_RDONLY);
     }
     main_loop();
-    /* NOT REACHED */
+    exit(0);
 }
diff --git a/metad.h b/metad.h
index 395525cc14458393c90914326b23c5fdd7590d31..2728ad88b95d6325636d3df7d91920fc3d479ad5 100644 (file)
--- a/metad.h
+++ b/metad.h
@@ -119,11 +119,12 @@ void init_recv(char*);
 char *prtime(time_t);
 int udp_port(void);
 int tcp_port(void);
+void nodelay(int socket);
 
 int strccmp(char*, char*);
 #ifndef IN_ERROR
 void error(char *mesg,...);
-void log(int, char*, ...);
+void logmsg(int, char*, ...);
 #endif
 #define        ERROR_STDERR    0
 #define        ERROR_SYSLOG    1
@@ -131,6 +132,7 @@ void log(int, char*, ...);
 int errors_to(int where, char **place);
 
 char **strlistdup(char **l);
+void strlistfree(char **l);
 char **strsplit(char *line, char *sep);
 /*char *strdup(char*);*/
 
index f9c003e1df654d7edd05ad1f8cc59383e20c2400..feab24027208e9d72b5e4381de71fa1298f1379b 100644 (file)
@@ -2,7 +2,7 @@
 #include       "metad.h"
 #undef NULL
 #include       <stdio.h>
-#include       <skip.h>
+#include       "skip.h"
 
 /* read the config file
  *
index 7f115e3d746e97543c0438e699c452fea444ea5a..61094c8b88a0f2a14e5f66a00371f918e74f375c 100644 (file)
--- a/sendcmd.c
+++ b/sendcmd.c
@@ -200,11 +200,11 @@ static void list_service(char *host, int verbose)
        int max, cnt, enabled;
        int i;
        int class;
-       char *classname;
+       char *classname=NULL;
        char *pidfile = NULL;
        int watch_output = 0;
-       int min, period, last;
-       int proto, port, active, backlog;
+       int min=0, period=0, last;
+       int proto, port=0, active=0, backlog=0;
        
        sname = get_str();
        max = get_int();
diff --git a/skip.c b/skip.c
index d7aca1e288c89fd1348fba2b99f2afd2ca1eb61a..06bba30d9a50ddf30cda6dc6e583ffa8427083dd 100644 (file)
--- a/skip.c
+++ b/skip.c
@@ -16,6 +16,7 @@
    */
 #include       <unistd.h>
 #include       <stdlib.h>
+#include       <string.h>
 
 #define false 0
 #define true 1
@@ -136,7 +137,7 @@ valueType value;
     int k;
     node update[MaxNumberOfLevels];
     node p,q;
-    int cm;
+    int cm=0;
 
     p = l->header;
     for (k=l->level ; k>=0 ; k--)
@@ -180,7 +181,7 @@ keyType key;
     int k, m;
     node update[MaxNumberOfLevels];
     node p,q;
-    int cm;
+    int cm = 0;
 
     p = l->header;
 
@@ -217,7 +218,7 @@ keyType key;
 {
     int k;
     node p;
-    int cm;
+    int cm = 0;
 
     p = l->header;
     for (k=l->level ; k>=0 ; k--)
index 36b20d4adface7bf825c38360d844ffab1ccd68c..a4de904724ef48f180461faa06391f4f2f6b0854 100644 (file)
--- a/strccmp.c
+++ b/strccmp.c
@@ -1,9 +1,10 @@
+#include <string.h>
 
 int strnccmp(a,b, n)
 char *a, *b;
 int n;
 {
-    char ac, bc;
+    char ac=0, bc=0;
 
     while(n--)
     {
index 489f943e87eee6de4d0c8e4cc144abc7d2f6e47a..a3f78c38c27718896e3a6f78e8a01951c934f975 100644 (file)
@@ -1,9 +1,8 @@
 
 /* duplicate a list of strings */
 
-#define NULL ((void *)0)
-char *strdup(char *);
-void *malloc(int);
+#include <malloc.h>
+#include <string.h>
 
 char **strlistdup(char **l)
 {
index 7f82a7cf9d4b11f65ed376b82bb49fe3659f45dd..45396d1b7fae65a23dbb473eed4592680b649055 100644 (file)
@@ -1,3 +1,4 @@
+#include <malloc.h>
 #include <string.h>
 #include <stdio.h>
 
@@ -18,8 +19,6 @@ char *s, *fs;
        register unsigned       i, num;
        static char             quote[] = "'";
 
-       extern char             *malloc();
-
        if((ns = malloc((unsigned) strlen(s) + 1)) == NULL)
                return NULL;
        sp = s;