Kill __P(), use ANSI function declarations, constify; WARNS=3.

This commit is contained in:
xtraeme 2005-02-09 13:57:57 +00:00
parent 4d58969864
commit a8d83732cf
9 changed files with 79 additions and 145 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.21 2004/03/01 23:01:18 itojun Exp $
# $NetBSD: Makefile,v 1.22 2005/02/09 13:57:57 xtraeme Exp $
# @(#)Makefile 8.3 (Berkeley) 3/27/94
.include <bsd.own.mk>
@ -10,6 +10,8 @@ SUBDIR= examples
MAN= mount_portal.8
WARNS= 3
CPPFLAGS+= -I${NETBSDSRCDIR}/sys
DPADD+=${LIBUTIL}

View File

@ -1,4 +1,4 @@
/* $NetBSD: activate.c,v 1.12 2003/08/07 10:04:30 agc Exp $ */
/* $NetBSD: activate.c,v 1.13 2005/02/09 13:57:57 xtraeme Exp $ */
/*
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: activate.c,v 1.12 2003/08/07 10:04:30 agc Exp $");
__RCSID("$NetBSD: activate.c,v 1.13 2005/02/09 13:57:57 xtraeme Exp $");
#endif /* not lint */
#include <stdio.h>
@ -55,22 +55,17 @@ __RCSID("$NetBSD: activate.c,v 1.12 2003/08/07 10:04:30 agc Exp $");
#include "portald.h"
static int activate_argv __P((struct portal_cred *, char *, char **,
int, int *));
static int get_request __P((int, struct portal_cred *, char *, int));
static void send_reply __P((int, int, int));
static int activate_argv(struct portal_cred *, char *, char **,
int, int *);
static int get_request(int, struct portal_cred *, char *, int);
static void send_reply(int, int, int);
/*
* Scan the providers list and call the
* appropriate function.
*/
static int
activate_argv(pcr, key, v, so, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int so;
int *fdp;
activate_argv(struct portal_cred *pcr, char *key, char **v, int so, int *fdp)
{
provider *pr;
@ -82,11 +77,7 @@ activate_argv(pcr, key, v, so, fdp)
}
static int
get_request(so, pcr, key, klen)
int so;
struct portal_cred *pcr;
char *key;
int klen;
get_request(int so, struct portal_cred *pcr, char *key, int klen)
{
struct iovec iov[2];
struct msghdr msg;
@ -115,10 +106,7 @@ get_request(so, pcr, key, klen)
}
static void
send_reply(so, fd, error)
int so;
int fd;
int error;
send_reply(int so, int fd, int error)
{
int n;
struct iovec iov;
@ -192,9 +180,7 @@ send_reply(so, fd, error)
}
void
activate(q, so)
qelem *q;
int so;
activate(qelem *q, int so)
{
struct portal_cred pcred;
char key[MAXPATHLEN+1];

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.10 2003/08/07 10:04:30 agc Exp $ */
/* $NetBSD: conf.c,v 1.11 2005/02/09 13:57:57 xtraeme Exp $ */
/*
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: conf.c,v 1.10 2003/08/07 10:04:30 agc Exp $");
__RCSID("$NetBSD: conf.c,v 1.11 2005/02/09 13:57:57 xtraeme Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -67,22 +67,21 @@ struct path {
char **p_argv; /* argv[] pointers into arg string (malloc) */
};
static void ins_que __P((qelem *, qelem *));
static path *palloc __P((char *, int, const char *));
static void pfree __P((path *));
static int pinsert __P((path *, qelem *));
static void preplace __P((qelem *, qelem *));
static void readfp __P((qelem *, FILE *, const char *));
static void rem_que __P((qelem *));
static void *xmalloc __P((size_t));
static void ins_que(qelem *, qelem *);
static path *palloc(char *, int, const char *);
static void pfree(path *);
static int pinsert(path *, qelem *);
static void preplace(qelem *, qelem *);
static void readfp(qelem *, FILE *, const char *);
static void rem_que(qelem *);
static void *xmalloc(size_t);
/*
* Add an element to a 2-way list,
* just after (pred)
*/
static void
ins_que(elem, pred)
qelem *elem, *pred;
ins_que(qelem *elem, qelem *pred)
{
qelem *p = pred->q_forw;
elem->q_back = pred;
@ -95,8 +94,7 @@ ins_que(elem, pred)
* Remove an element from a 2-way list
*/
static void
rem_que(elem)
qelem *elem;
rem_que(qelem *elem)
{
qelem *p = elem->q_forw;
qelem *p2 = elem->q_back;
@ -108,8 +106,7 @@ rem_que(elem)
* Error checking malloc
*/
static void *
xmalloc(siz)
size_t siz;
xmalloc(size_t siz)
{
void *p = malloc(siz);
if (p)
@ -126,9 +123,7 @@ xmalloc(siz)
* and 1 is returned.
*/
static int
pinsert(p0, q0)
path *p0;
qelem *q0;
pinsert(path *p0, qelem *q0)
{
qelem *q;
@ -146,10 +141,7 @@ pinsert(p0, q0)
}
static path *
palloc(cline, lno, conf_file)
char *cline;
int lno;
const char *conf_file;
palloc(char *cline, int lno, const char *conf_file)
{
int c, errcode;
char *s;
@ -230,8 +222,7 @@ palloc(cline, lno, conf_file)
* Free a path structure
*/
static void
pfree(p)
path *p;
pfree(path *p)
{
free(p->p_args);
free((char *) p->p_argv);
@ -245,9 +236,7 @@ pfree(p)
* and add all the ones on xq.
*/
static void
preplace(q0, xq)
qelem *q0;
qelem *xq;
preplace(qelem *q0, qelem *xq)
{
/*
* While the list is not empty,
@ -271,10 +260,7 @@ preplace(q0, xq)
* add them to the list of paths.
*/
static void
readfp(q0, fp, conf_file)
qelem *q0;
FILE *fp;
const char *conf_file;
readfp(qelem *q0, FILE *fp, const char *conf_file)
{
char cline[LINE_MAX];
int nread = 0;
@ -310,9 +296,7 @@ readfp(q0, fp, conf_file)
* If the file is not readable, then no changes take place
*/
void
conf_read(q, conf)
qelem *q;
char *conf;
conf_read(qelem *q, char *conf)
{
FILE *fp = fopen(conf, "r");
if (fp) {
@ -324,9 +308,7 @@ conf_read(q, conf)
char **
conf_match(q0, key)
qelem *q0;
char *key;
conf_match(qelem *q0, char *key)
{
qelem *q;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_portal.c,v 1.26 2005/01/31 05:19:19 erh Exp $ */
/* $NetBSD: mount_portal.c,v 1.27 2005/02/09 13:57:57 xtraeme Exp $ */
/*
* Copyright (c) 1992, 1993, 1994
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95";
#else
__RCSID("$NetBSD: mount_portal.c,v 1.26 2005/01/31 05:19:19 erh Exp $");
__RCSID("$NetBSD: mount_portal.c,v 1.27 2005/02/09 13:57:57 xtraeme Exp $");
#endif
#endif /* not lint */
@ -75,17 +75,15 @@ static const struct mntopt mopts[] = {
static char mountpt[MAXPATHLEN]; /* made available to signal handler */
int main __P((int, char *[]));
static void sigchld __P((int));
static void sighup __P((int));
static void sigterm __P((int));
static void usage __P((void));
static void sigchld(int);
static void sighup(int);
static void sigterm(int);
static void usage(void);
static sig_atomic_t readcf; /* Set when SIGHUP received */
static void
sigchld(sig)
int sig;
sigchld(int sig)
{
pid_t pid;
@ -96,16 +94,14 @@ sigchld(sig)
}
static void
sighup(sig)
int sig;
sighup(int sig)
{
readcf = 1;
}
static void
sigterm(sig)
int sig;
sigterm(int sig)
{
if (unmount(mountpt, MNT_FORCE) < 0)
@ -114,9 +110,7 @@ sigterm(sig)
}
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
struct portal_args args;
struct sockaddr_un un;
@ -308,7 +302,7 @@ main(argc, argv)
}
static void
usage()
usage(void)
{
(void)fprintf(stderr,

View File

@ -1,4 +1,4 @@
/* $NetBSD: portald.h,v 1.6 2003/08/07 10:04:30 agc Exp $ */
/* $NetBSD: portald.h,v 1.7 2005/02/09 13:57:57 xtraeme Exp $ */
/*
* Copyright (c) 1992, 1993
@ -54,30 +54,30 @@ struct qelem {
typedef struct provider provider;
struct provider {
char *pr_match;
int (*pr_func) __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
const char *pr_match;
int (*pr_func)(struct portal_cred *,
char *key, char **v, int so, int *fdp);
};
extern provider providers[];
/*
* Portal providers
*/
extern int portal_exec __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
extern int portal_file __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
extern int portal_tcp __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
extern int portal_rfilter __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
extern int portal_wfilter __P((struct portal_cred *,
char *key, char **v, int so, int *fdp));
extern int portal_exec(struct portal_cred *,
char *key, char **v, int so, int *fdp);
extern int portal_file(struct portal_cred *,
char *key, char **v, int so, int *fdp);
extern int portal_tcp(struct portal_cred *,
char *key, char **v, int so, int *fdp);
extern int portal_rfilter(struct portal_cred *,
char *key, char **v, int so, int *fdp);
extern int portal_wfilter(struct portal_cred *,
char *key, char **v, int so, int *fdp);
/*
* Global functions
*/
extern void activate __P((qelem *q, int so));
extern char **conf_match __P((qelem *q, char *key));
extern void conf_read __P((qelem *q, char *conf));
extern int lose_credentials __P((struct portal_cred *));
extern void activate(qelem *q, int so);
extern char **conf_match(qelem *q, char *key);
extern void conf_read(qelem *q, char *conf);
extern int lose_credentials(struct portal_cred *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pt_exec.c,v 1.7 2003/08/07 10:04:30 agc Exp $ */
/* $NetBSD: pt_exec.c,v 1.8 2005/02/09 13:57:57 xtraeme Exp $ */
/*
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: pt_exec.c,v 1.7 2003/08/07 10:04:30 agc Exp $");
__RCSID("$NetBSD: pt_exec.c,v 1.8 2005/02/09 13:57:57 xtraeme Exp $");
#endif /* not lint */
#include <stdio.h>
@ -51,12 +51,7 @@ __RCSID("$NetBSD: pt_exec.c,v 1.7 2003/08/07 10:04:30 agc Exp $");
#include "portald.h"
int
portal_exec(pcr, key, v, so, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int so;
int *fdp;
portal_exec(struct portal_cred *pcr, char *key, char **v, int so, int *fdp)
{
return (ENOEXEC);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pt_file.c,v 1.15 2003/08/07 10:04:30 agc Exp $ */
/* $NetBSD: pt_file.c,v 1.16 2005/02/09 13:57:57 xtraeme Exp $ */
/*
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: pt_file.c,v 1.15 2003/08/07 10:04:30 agc Exp $");
__RCSID("$NetBSD: pt_file.c,v 1.16 2005/02/09 13:57:57 xtraeme Exp $");
#endif /* not lint */
#include <stdio.h>
@ -63,8 +63,7 @@ __RCSID("$NetBSD: pt_file.c,v 1.15 2003/08/07 10:04:30 agc Exp $");
#endif
int
lose_credentials(pcr)
struct portal_cred *pcr;
lose_credentials(struct portal_cred *pcr)
{
/*
* If we are root, then switch into the caller's credentials.
@ -129,12 +128,7 @@ lose_credentials(pcr)
}
int
portal_file(pcr, key, v, so, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int so;
int *fdp;
portal_file(struct portal_cred *pcr, char *key, char **v, int so, int *fdp)
{
int fd;
char pbuf[MAXPATHLEN];

View File

@ -1,4 +1,4 @@
/* $NetBSD: pt_filter.c,v 1.4 2001/01/10 03:33:16 lukem Exp $ */
/* $NetBSD: pt_filter.c,v 1.5 2005/02/09 13:57:57 xtraeme Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: pt_filter.c,v 1.4 2001/01/10 03:33:16 lukem Exp $");
__RCSID("$NetBSD: pt_filter.c,v 1.5 2005/02/09 13:57:57 xtraeme Exp $");
#endif /* not lint */
#include <stdio.h>
@ -60,14 +60,10 @@ __RCSID("$NetBSD: pt_filter.c,v 1.4 2001/01/10 03:33:16 lukem Exp $");
#define FILTER_CMD_SIZE 8192
static void fill_cmd __P((char **, char *, char *, int));
static void fill_cmd(char **, char *, char *, int);
static void
fill_cmd(cmdv, path, buff, n)
char **cmdv;
char *path;
char *buff;
int n;
fill_cmd(char **cmdv, char *path, char *buff, int n)
{
int i;
/* Make tempbuff at least as large as buff. */
@ -89,12 +85,7 @@ fill_cmd(cmdv, path, buff, n)
* of the path, and exec v[2] v[3] ... on the remainder.
*/
int
portal_rfilter(pcr, key, v, kso, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int kso;
int *fdp;
portal_rfilter(struct portal_cred *pcr, char *key, char **v, int kso, int *fdp)
{
char cmd[FILTER_CMD_SIZE];
char *path;
@ -134,7 +125,7 @@ portal_rfilter(pcr, key, v, kso, fdp)
* v[3] could be NULL, or could point to "".
*/
if (!v[3] || strlen(v[3]) == 0)
v[3] = "%s"; /* Handle above assumption. */
(const char *)v[3] = "%s"; /* Handle above assumption. */
path = key;
/* Strip out stripkey if it matches leading part of key. */
if (!strncmp(v[1], key, strlen(v[1])))
@ -177,12 +168,7 @@ portal_rfilter(pcr, key, v, kso, fdp)
}
int
portal_wfilter(pcr, key, v, kso, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int kso;
int *fdp;
portal_wfilter(struct portal_cred *pcr, char *key, char **v, int kso, int *fdp)
{
char cmd[FILTER_CMD_SIZE];
char *path;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pt_tcp.c,v 1.18 2004/03/01 23:01:18 itojun Exp $ */
/* $NetBSD: pt_tcp.c,v 1.19 2005/02/09 13:57:57 xtraeme Exp $ */
/*
* Copyright (c) 1992, 1993, 1994
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: pt_tcp.c,v 1.18 2004/03/01 23:01:18 itojun Exp $");
__RCSID("$NetBSD: pt_tcp.c,v 1.19 2005/02/09 13:57:57 xtraeme Exp $");
#endif /* not lint */
#include <stdio.h>
@ -63,12 +63,7 @@ __RCSID("$NetBSD: pt_tcp.c,v 1.18 2004/03/01 23:01:18 itojun Exp $");
* An unrecognised suffix is an error.
*/
int
portal_tcp(pcr, key, v, kso, fdp)
struct portal_cred *pcr;
char *key;
char **v;
int kso;
int *fdp;
portal_tcp(struct portal_cred *pcr, char *key, char **v, int kso, int *fdp)
{
char host[MAXHOSTNAMELEN];
char port[MAXHOSTNAMELEN];