From: Mark Wooding Date: Mon, 8 Dec 2008 10:41:08 +0000 (+0000) Subject: Various minor cleanups. X-Git-Tag: 1.0.0pre8~62 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/commitdiff_plain/6047fbac6ecdaa13a13ea71f7f62eb77b2361eec Various minor cleanups. * Spacing fix in server/peer.c. * Minor reformatting in tunnel drivers and client. * Remove bogus declaration for long-dead u_daemon in common/util.h. * Reformatting of client/tripectl.c. --- diff --git a/client/tripectl.c b/client/tripectl.c index af5c1838..d9f5dd81 100644 --- a/client/tripectl.c +++ b/client/tripectl.c @@ -120,10 +120,7 @@ static void checkbg(char **p) } static void checkfg(void) -{ - if (bgtag) - die(EXIT_FAILURE, "unexpected foreground response"); -} + { if (bgtag) die(EXIT_FAILURE, "unexpected foreground response"); } static void cline(char *p, size_t len, void *b) { @@ -273,18 +270,10 @@ static void logfile(const char *name) static void sighup(int sig, void *v) { logfile(logname); } -static void cleanup(void) -{ - if (pidfile) - unlink(pidfile); -} +static void cleanup(void) { if (pidfile) unlink(pidfile); } static void sigdie(int sig) -{ - cleanup(); - signal(sig, SIG_DFL); - raise(sig); -} + { cleanup(); signal(sig, SIG_DFL); raise(sig); } static void version(FILE *fp) { pquis(fp, "$, TrIPE version " VERSION "\n"); } @@ -473,15 +462,12 @@ int main(int argc, char *argv[]) if (!kid) { dup2(pfd[1], STDIN_FILENO); dup2(pfd[1], STDOUT_FILENO); - close(pfd[1]); close(pfd[0]); - if (logfp) - fclose(logfp); - if (pidfp) - fclose(pidfp); + close(pfd[1]); + if (logfp) fclose(logfp); + if (pidfp) fclose(pidfp); closelog(); - if (f & f_daemon) - detachtty(); + if (f & f_daemon) detachtty(); execvp(DA(&spawnopts)[0], DA(&spawnopts)); die(127, "couldn't exec `%s': %s", spawnpath, strerror(errno)); } diff --git a/common/util.h b/common/util.h index b76e1259..aaef36f3 100644 --- a/common/util.h +++ b/common/util.h @@ -46,29 +46,6 @@ extern void u_quotify(dstr */*d*/, const char */*p*/); -/* --- @u_detach@ --- * - * - * Arguments: --- - * - * Returns: --- - * - * Use: Detaches from the current terminal and ensures it can never - * acquire a new one. Calls @fork@. - */ - -extern void u_detach(void); - -/* --- @u_daemon@ --- * - * - * Arguments: --- - * - * Returns: Zero if OK, nonzero on failure. - * - * Use: Becomes a daemon. - */ - -extern int u_daemon(void); - /*----- That's all, folks -------------------------------------------------*/ #ifdef __cplusplus diff --git a/server/peer.c b/server/peer.c index e57c6ba4..b23ef7bf 100644 --- a/server/peer.c +++ b/server/peer.c @@ -707,10 +707,10 @@ peer *p_create(peerspec *spec) if (kx_init(&p->kx, p, &p->ks, p->spec.kxf)) goto tidy_3; a_notify("ADD", - "?PEER", p, - "%s", p->ifname, - "?ADDR", &p->spec.sa, - A_END); + "?PEER", p, + "%s", p->ifname, + "?ADDR", &p->spec.sa, + A_END); if (!(p->spec.kxf & KXF_CORK)) { a_notify("KXSTART", "?PEER", p, A_END); /* Couldn't tell anyone before */ diff --git a/server/tun-bsd.c b/server/tun-bsd.c index 12765e5d..49b5e0e2 100644 --- a/server/tun-bsd.c +++ b/server/tun-bsd.c @@ -161,11 +161,7 @@ static void t_inject(tunnel *t, buf *b) */ static void t_destroy(tunnel *t) -{ - sel_rmfile(&t->f); - close(t->f.fd); - DESTROY(t); -} + { sel_rmfile(&t->f); close(t->f.fd); DESTROY(t); } const tunnel_ops tun_bsd = { "bsd", diff --git a/server/tun-linux.c b/server/tun-linux.c index 28c20500..cffeb56d 100644 --- a/server/tun-linux.c +++ b/server/tun-linux.c @@ -161,11 +161,7 @@ static void t_inject(tunnel *t, buf *b) */ static void t_destroy(tunnel *t) -{ - sel_rmfile(&t->f); - close(t->f.fd); - DESTROY(t); -} + { sel_rmfile(&t->f); close(t->f.fd); DESTROY(t); } const tunnel_ops tun_linux = { "linux", diff --git a/server/tun-unet.c b/server/tun-unet.c index 5ebcc790..2d11ca0f 100644 --- a/server/tun-unet.c +++ b/server/tun-unet.c @@ -162,11 +162,7 @@ static void t_inject(tunnel *t, buf *b) */ static void t_destroy(tunnel *t) -{ - sel_rmfile(&t->f); - close(t->f.fd); - DESTROY(t); -} + { sel_rmfile(&t->f); close(t->f.fd); DESTROY(t); } const tunnel_ops tun_unet = { "unet",