X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/ec18722d02bd307bd09f30715dc8ba4e1b8a6716..63621a81d16ab743de6b57d47578a9a2c670ad22:/uip/slocal.c diff --git a/uip/slocal.c b/uip/slocal.c index bf58fd0b..fe027ee2 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -27,8 +27,8 @@ #include #include #include -#include "../sbr/lock_file.h" -#include "../sbr/m_mktemp.h" +#include "sbr/lock_file.h" +#include "sbr/m_mktemp.h" #include #include @@ -163,7 +163,7 @@ static int split (char *, char **); static int parse (int); static void expand (char *, char *, int); static void glob (int); -static struct pair *lookup (struct pair *, char *); +static struct pair *lookup (struct pair *, char *) PURE; static int logged_in (void); static int timely (char *, char *); static int usr_file (int, char *, int); @@ -172,9 +172,9 @@ static int usr_folder (int, char *); static void alrmser (int); static void get_sender (char *, char **); static int copy_message (int, char *, int); -static void verbose_printf (char *fmt, ...); -static void adorn (char *, char *, ...); -static void debug_printf (char *fmt, ...); +static void verbose_printf (char *fmt, ...) CHECK_PRINTF(1, 2); +static void adorn (char *, char *, ...) CHECK_PRINTF(2, 3); +static void debug_printf (char *fmt, ...) CHECK_PRINTF(1, 2); static int suppress_duplicates (int, char *); static char *trim (char *); @@ -802,12 +802,12 @@ parse (int fd) p->p_value = getcpy (q ? q->p_value : ""); p->p_flags &= ~P_CHK; if (debug) - debug_printf ("vars[%d]: name=\"%s\" value=\"%s\"\n", + debug_printf ("vars[%ld]: name=\"%s\" value=\"%s\"\n", p - vars, p->p_name, trim(p->p_value)); } if (debug) { for (p = hdrs; p->p_name; p++) - debug_printf ("hdrs[%d]: name=\"%s\" value=\"%s\"\n", + debug_printf ("hdrs[%ld]: name=\"%s\" value=\"%s\"\n", p - hdrs, p->p_name, p->p_value ? trim(p->p_value) : ""); } @@ -887,7 +887,7 @@ glob (int fd) if (debug) { for (p = vars; p->p_name; p++) - debug_printf ("vars[%d]: name=\"%s\" value=\"%s\"\n", + debug_printf ("vars[%ld]: name=\"%s\" value=\"%s\"\n", p - vars, p->p_name, trim(p->p_value)); } } @@ -1046,7 +1046,7 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) { volatile int fd = fd_arg; pid_t child_id; - int i, bytes, seconds, status; + int bytes, seconds, status; struct stat st; if (verbose && !suppress) @@ -1054,9 +1054,7 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) lseek(fd, 0, SEEK_SET); - for (i = 0; (child_id = fork()) == -1 && i < 5; i++) - sleep (5); - + child_id = fork(); switch (child_id) { case -1: /* fork error */ @@ -1085,7 +1083,7 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) } #endif /* TIOCNOTTY */ - setpgid ((pid_t) 0, getpid ()); /* put in own process group */ + setpgid(0, getpid()); /* put in own process group */ *environ = NULL; setenv("USER", pw->pw_name, 1); @@ -1118,11 +1116,10 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) if (verbose) { if (status == 0) verbose_printf (", success.\n"); - else - if ((status & 0xff00) == 0xff00) - verbose_printf (", system error\n"); - else - pidstatus (status, stdout, ", failed"); + else if ((status & 0xff00) == 0xff00) + verbose_printf (", system error\n"); + else + pidstatus (status, stdout, ", failed"); } return (status == 0 ? 0 : -1); } @@ -1296,7 +1293,7 @@ fputs_error: static char * trim (char *cp) { - char buffer[BUFSIZ*4]; + static char buffer[BUFSIZ * 4]; char *bp, *sp; if (cp == NULL) @@ -1323,8 +1320,7 @@ trim (char *cp) if (isspace((unsigned char) *sp)) *sp = ' '; - /* now return a copy */ - return mh_xstrdup(bp); + return bp; } /*