From 22a27dede77166c7bdf1de647d4d2b961fcd92c2 Mon Sep 17 00:00:00 2001 From: hubertf Date: Wed, 10 Feb 1999 00:45:45 +0000 Subject: The game sail(6) has a function Write() which is used both with integer arguments and with string arguments (cast to long, and in one place to int). The patch here cleans this up, making it into two separate functions; this allows for the game to be made const-correct in future and improves portability. The patch also contains two other fragments: a change to use the symbolic constant SEEK_END with fseek(), and a change to use snprintf in one place to avoid a buffer overrun. Via PR 6569 by Joseph Myers . --- sail/pl_main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sail/pl_main.c') diff --git a/sail/pl_main.c b/sail/pl_main.c index 2467951f..64307e8b 100644 --- a/sail/pl_main.c +++ b/sail/pl_main.c @@ -1,4 +1,4 @@ -/* $NetBSD: pl_main.c,v 1.6 1997/10/13 19:45:48 christos Exp $ */ +/* $NetBSD: pl_main.c,v 1.7 1999/02/10 00:45:46 hubertf Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)pl_main.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: pl_main.c,v 1.6 1997/10/13 19:45:48 christos Exp $"); +__RCSID("$NetBSD: pl_main.c,v 1.7 1999/02/10 00:45:46 hubertf Exp $"); #endif #endif /* not lint */ @@ -181,7 +181,7 @@ reprint: mf = ms->file; mc = ms->specs; - Write(W_BEGIN, ms, 0, 0, 0, 0, 0); + Write(W_BEGIN, ms, 0, 0, 0, 0); if (Sync() < 0) leave(LEAVE_SYNC); @@ -214,7 +214,7 @@ reprint: captain[strlen(captain) - 1] = '\0'; } captain[sizeof captain - 1] = '\0'; - Write(W_CAPTAIN, ms, 1, (long)captain, 0, 0, 0); + Writestr(W_CAPTAIN, ms, captain); for (n = 0; n < 2; n++) { char buf[10]; @@ -249,7 +249,8 @@ reprint: initscreen(); draw_board(); - (void) sprintf(message, "Captain %s assuming command", captain); - Write(W_SIGNAL, ms, 1, (long)message, 0, 0, 0); + (void) snprintf(message, sizeof message, "Captain %s assuming command", + captain); + Writestr(W_SIGNAL, ms, message); newturn(0); } -- cgit v1.2.3