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
This commit is contained in:
Juli Mallett 2003-04-03 05:13:27 +00:00
parent 55ad402a8f
commit 02a0965ef6
5 changed files with 17 additions and 15 deletions

View File

@ -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]);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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>