summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2003-04-03 05:13:27 +0000
committerjmallett <jmallett@FreeBSD.org>2003-04-03 05:13:27 +0000
commiteba71bcf69b1a44d8ff32c0aa0c0400d682b5dec (patch)
treeea700d011536a0f7f4ef18463e1769cfb052ce7e /libexec
parent5b2b2811a19544037b626ef44e598691b3b2f525 (diff)
downloadFreeBSD-src-eba71bcf69b1a44d8ff32c0aa0c0400d682b5dec.zip
FreeBSD-src-eba71bcf69b1a44d8ff32c0aa0c0400d682b5dec.tar.gz
MFp4 @27667: WARNS=5 cleanup on i386.
Remove the unused FILE\ *tf from print_mesg args, and the bogus passing in of an uninitialised FILE* for it. Call a timeval 'now' instead of 'clock' due to shadowing. Remove a nested localtime declaration. Make the delete invite argument match the ID type, u_int32_t. Use const for pointers to const items. Cast to long where printing as such. Include netinet/in.h for htonl/htons. Reviewed by: imp
Diffstat (limited to 'libexec')
-rw-r--r--libexec/talkd/announce.c12
-rw-r--r--libexec/talkd/extern.h4
-rw-r--r--libexec/talkd/print.c12
-rw-r--r--libexec/talkd/table.c3
-rw-r--r--libexec/talkd/talkd.c1
5 files changed, 17 insertions, 15 deletions
diff --git a/libexec/talkd/announce.c b/libexec/talkd/announce.c
index 6d33005..ca64541 100644
--- a/libexec/talkd/announce.c
+++ b/libexec/talkd/announce.c
@@ -74,14 +74,13 @@ int
announce(CTL_MSG *request, const char *remote_machine)
{
char full_tty[32];
- FILE *tf;
struct stat stbuf;
(void)snprintf(full_tty, sizeof(full_tty),
"%s%s", _PATH_DEV, request->r_tty);
if (stat(full_tty, &stbuf) < 0 || (stbuf.st_mode&020) == 0)
return (PERMISSION_DENIED);
- return (print_mesg(request->r_tty, tf, request, remote_machine));
+ return (print_mesg(request->r_tty, request, remote_machine));
}
#define max(a,b) ( (a) > (b) ? (a) : (b) )
@@ -95,13 +94,12 @@ announce(CTL_MSG *request, const char *remote_machine)
* in in vi at the time
*/
int
-print_mesg(const char *tty, FILE *tf, CTL_MSG *request,
+print_mesg(const char *tty, CTL_MSG *request,
const char *remote_machine)
{
- struct timeval clock;
+ struct timeval now;
time_t clock_sec;
struct timezone zone;
- struct tm *localtime();
struct tm *localclock;
struct iovec iovec;
char line_buf[N_LINES][N_CHARS];
@@ -112,8 +110,8 @@ print_mesg(const char *tty, FILE *tf, CTL_MSG *request,
i = 0;
max_size = 0;
- gettimeofday(&clock, &zone);
- clock_sec = clock.tv_sec;
+ gettimeofday(&now, &zone);
+ clock_sec = now.tv_sec;
localclock = localtime(&clock_sec);
(void)snprintf(line_buf[i], N_CHARS, " ");
sizes[i] = strlen(line_buf[i]);
diff --git a/libexec/talkd/extern.h b/libexec/talkd/extern.h
index df4901d..cb231a9 100644
--- a/libexec/talkd/extern.h
+++ b/libexec/talkd/extern.h
@@ -26,14 +26,14 @@
*/
int announce(CTL_MSG *, const char *);
-int delete_invite(int);
+int delete_invite(u_int32_t);
void do_announce(CTL_MSG *, CTL_RESPONSE *);
CTL_MSG *find_match(CTL_MSG *request);
CTL_MSG *find_request(CTL_MSG *request);
int find_user(const char *name, char *tty);
void insert_table(CTL_MSG *, CTL_RESPONSE *);
int new_id(void);
-int print_mesg(const char *, FILE *, CTL_MSG *, const char *);
+int print_mesg(const char *, CTL_MSG *, const char *);
void print_request(const char *, CTL_MSG *);
void print_response(const char *, CTL_RESPONSE *);
void process_request(CTL_MSG *mp, CTL_RESPONSE *rp);
diff --git a/libexec/talkd/print.c b/libexec/talkd/print.c
index 355910c..6c39d8d 100644
--- a/libexec/talkd/print.c
+++ b/libexec/talkd/print.c
@@ -50,10 +50,10 @@ static const char rcsid[] =
#include "extern.h"
-static char *types[] =
+static const char *types[] =
{ "leave_invite", "look_up", "delete", "announce" };
#define NTYPES (sizeof (types) / sizeof (types[0]))
-static char *answers[] =
+static const char *answers[] =
{ "success", "not_here", "failed", "machine_unknown", "permission_denied",
"unknown_request", "badversion", "badaddr", "badctladdr" };
#define NANSWERS (sizeof (answers) / sizeof (answers[0]))
@@ -61,7 +61,8 @@ static char *answers[] =
void
print_request(const char *cp, CTL_MSG *mp)
{
- char tbuf[80], *tp;
+ const char *tp;
+ char tbuf[80];
if (mp->type > NTYPES) {
(void)snprintf(tbuf, sizeof(tbuf), "type %d", mp->type);
@@ -69,13 +70,14 @@ print_request(const char *cp, CTL_MSG *mp)
} else
tp = types[mp->type];
syslog(LOG_DEBUG, "%s: %s: id %lu, l_user %s, r_user %s, r_tty %s",
- cp, tp, mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
+ cp, tp, (long)mp->id_num, mp->l_name, mp->r_name, mp->r_tty);
}
void
print_response(const char *cp, CTL_RESPONSE *rp)
{
- char tbuf[80], *tp, abuf[80], *ap;
+ const char *tp, *ap;
+ char tbuf[80], abuf[80];
if (rp->type > NTYPES) {
(void)snprintf(tbuf, sizeof(tbuf), "type %d", rp->type);
diff --git a/libexec/talkd/table.c b/libexec/talkd/table.c
index 28e8d8e..001e7d4 100644
--- a/libexec/talkd/table.c
+++ b/libexec/talkd/table.c
@@ -50,6 +50,7 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
+#include <netinet/in.h>
#include <protocols/talkd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -198,7 +199,7 @@ new_id(void)
* Delete the invitation with id 'id_num'
*/
int
-delete_invite(int id_num)
+delete_invite(u_int32_t id_num)
{
TABLE_ENTRY *ptr;
diff --git a/libexec/talkd/talkd.c b/libexec/talkd/talkd.c
index d35c0e3..ae2c6eb 100644
--- a/libexec/talkd/talkd.c
+++ b/libexec/talkd/talkd.c
@@ -54,6 +54,7 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
+#include <netinet/in.h>
#include <protocols/talkd.h>
#include <err.h>
#include <errno.h>
OpenPOWER on IntegriCloud