Turn on NO_WERROR and set WARNS to 1.

Fix the WARNS 1 warnings except unused variables.

Add prototype for log_netobj().
Don't compare signed/unsigned.
Cast u_int64_t to 'unsigned long long' and print using %llu.
Fix constness of string arrays.
Use a cast to avoid an unused parameter in a signal handler.
alarm(2) can't fail, so don't check for it.
ANSI'ify some functions.
This commit is contained in:
Alfred Perlstein 2001-11-13 11:24:23 +00:00
parent 7e440a74e8
commit 2663693cf8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=86319
5 changed files with 27 additions and 20 deletions

View File

@ -5,6 +5,8 @@ PROG= rpc.lockd
MAN= rpc.lockd.8
MLINKS= rpc.lockd.8 lockd.8
SRCS= kern.c nlm_prot_svc.c lockd.c lock_proc.c lockd_lock.c
NO_WERROR= YES
WARNS?= 1
CFLAGS+= -I. -I${DESTDIR}/usr/include/rpcsvc

View File

@ -62,6 +62,7 @@ __RCSID("$NetBSD: lock_proc.c,v 1.7 2000/10/11 20:23:56 is Exp $");
#define CLIENT_CACHE_LIFETIME 120 /* In seconds */
static void log_from_addr __P((char *, struct svc_req *));
static void log_netobj __P((netobj *obj));
static int addrcmp __P((struct sockaddr *, struct sockaddr *));
/* log_from_addr ----------------------------------------------------------- */
@ -100,7 +101,7 @@ log_netobj(obj)
{
char objvalbuffer[(sizeof(char)*2)*MAX_NETOBJ_SZ+2];
char objascbuffer[sizeof(char)*MAX_NETOBJ_SZ+1];
int i, maxlen;
unsigned int i, maxlen;
char *tmp1, *tmp2;
/* Notify of potential security attacks */
@ -911,8 +912,10 @@ nlm4_test_4_svc(arg, rqstp)
syslog(LOG_DEBUG, "Owner Handle:\n");
log_netobj(&(arg->alock.oh));
syslog(LOG_DEBUG, "SVID: %d\n", arg->alock.svid);
syslog(LOG_DEBUG, "Lock Offset: %d\n", arg->alock.l_offset);
syslog(LOG_DEBUG, "Lock Length: %d\n", arg->alock.l_len);
syslog(LOG_DEBUG, "Lock Offset: %llu\n",
(unsigned long long)arg->alock.l_offset);
syslog(LOG_DEBUG, "Lock Length: %llu\n",
(unsigned long long)arg->alock.l_len);
syslog(LOG_DEBUG, "Exclusive: %s\n",
(arg->exclusive ? "true" : "false"));
}
@ -1007,8 +1010,10 @@ nlm4_lock_4_svc(arg, rqstp)
syslog(LOG_DEBUG, "Owner Handle:\n");
log_netobj(&(arg->alock.oh));
syslog(LOG_DEBUG, "SVID: %d\n", arg->alock.svid);
syslog(LOG_DEBUG, "Lock Offset: %d\n", arg->alock.l_offset);
syslog(LOG_DEBUG, "Lock Length: %d\n", arg->alock.l_len);
syslog(LOG_DEBUG, "Lock Offset: %llu\n",
(unsigned long long)arg->alock.l_offset);
syslog(LOG_DEBUG, "Lock Length: %llu\n",
(unsigned long long)arg->alock.l_len);
syslog(LOG_DEBUG, "Block: %s\n", (arg->block ? "true" : "false"));
syslog(LOG_DEBUG, "Exclusive: %s\n", (arg->exclusive ? "true" : "false"));
syslog(LOG_DEBUG, "Reclaim: %s\n", (arg->reclaim ? "true" : "false"));

View File

@ -82,9 +82,9 @@ void nlm_prog_3 __P((struct svc_req *, SVCXPRT *));
void nlm_prog_4 __P((struct svc_req *, SVCXPRT *));
void usage __P((void));
void sigalarm_handler __P((int));
void sigalarm_handler __P((void));
char *transports[] = { "udp", "tcp", "udp6", "tcp6" };
const char *transports[] = { "udp", "tcp", "udp6", "tcp6" };
int
main(argc, argv)
@ -196,7 +196,7 @@ main(argc, argv)
strerror(errno));
exit(1);
}
sigalarm.sa_handler = sigalarm_handler;
sigalarm.sa_handler = (sig_t) sigalarm_handler;
sigemptyset(&sigalarm.sa_mask);
sigalarm.sa_flags = SA_RESETHAND; /* should only happen once */
sigalarm.sa_flags |= SA_RESTART;
@ -206,11 +206,7 @@ main(argc, argv)
exit(1);
}
grace_expired = 0;
if (alarm(10) < 0) {
syslog(LOG_WARNING, "alarm failed: %s",
strerror(errno));
exit(1);
}
alarm(10);
init_nsm();
@ -221,9 +217,9 @@ main(argc, argv)
}
void
sigalarm_handler(s)
int s;
sigalarm_handler(void)
{
grace_expired = 1;
}

View File

@ -778,7 +778,7 @@ do_mon(hostname)
void
notify(hostname, state)
char *hostname;
const char *hostname;
int state;
{
struct file_lock *fl, *next_fl;

View File

@ -3,11 +3,15 @@
/* Headers and function declarations for file-locking utilities */
struct nlm4_holder * testlock __P((struct nlm4_lock *, int, int));
struct nlm4_holder * testlock(struct nlm4_lock *lock, bool_t exclusive,
int flags);
enum nlm_stats getlock(nlm4_lockargs *lckarg, struct svc_req *rqstp,
const int flags);
enum nlm_stats unlock(nlm4_lock *lock, const int flags);
int lock_answer(int pid, netobj *netcookie, int result, int *pid_p,
int version);
enum nlm_stats getlock __P((nlm4_lockargs *, struct svc_req *, int));
enum nlm_stats unlock __P((nlm4_lock *, int));
void notify __P((char *, int));
void notify(const char *hostname, const int state);
/* flags for testlock, getlock & unlock */
#define LOCK_ASYNC 0x01 /* async version (getlock only) */