summaryrefslogtreecommitdiff
path: root/usr.bin/telnet/utilities.c
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-09-09 03:41:09 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-09-09 03:41:09 +0000
commit3738a71b2e358307482a24229b8cd100ab150eab (patch)
treeeb752407af8f18917bbf5971230e47e2ff66b2c5 /usr.bin/telnet/utilities.c
parente53bf16d9b38d7d93c5dd1cefe25ee6f4a5b8086 (diff)
Eliminate a pile of casts that were superfluous or wrong, or that were
the result of bad type choices, particularly (unsigned char *) vs (const char *). Also, use reallocarray().
Diffstat (limited to 'usr.bin/telnet/utilities.c')
-rw-r--r--usr.bin/telnet/utilities.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/usr.bin/telnet/utilities.c b/usr.bin/telnet/utilities.c
index 76eb0f0f2c8..b3acee87613 100644
--- a/usr.bin/telnet/utilities.c
+++ b/usr.bin/telnet/utilities.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utilities.c,v 1.20 2014/07/22 07:30:24 jsg Exp $ */
+/* $OpenBSD: utilities.c,v 1.21 2014/09/09 03:41:08 guenther Exp $ */
/* $NetBSD: utilities.c,v 1.5 1996/02/28 21:04:21 thorpej Exp $ */
/*
@@ -66,23 +66,23 @@ upcase(char *argument)
* The following are routines used to print out debugging information.
*/
-unsigned char NetTraceFile[PATH_MAX] = "(standard output)";
+char NetTraceFile[PATH_MAX] = "(standard output)";
void
-SetNetTrace(char *file)
+SetNetTrace(const char *file)
{
if (NetTrace && NetTrace != stdout)
fclose(NetTrace);
- if (file && (strcmp(file, "-") != 0)) {
- NetTrace = fopen(file, "w");
+ if (file && (strcmp(file, "-") != 0)) {
+ NetTrace = fopen(file, "we");
if (NetTrace) {
- strlcpy((char *)NetTraceFile, file, sizeof(NetTraceFile));
+ strlcpy(NetTraceFile, file, sizeof(NetTraceFile));
return;
}
fprintf(stderr, "Cannot open %s.\n", file);
}
NetTrace = stdout;
- strlcpy((char *)NetTraceFile, "(standard output)", sizeof(NetTraceFile));
+ strlcpy(NetTraceFile, "(standard output)", sizeof(NetTraceFile));
}
void
@@ -356,15 +356,13 @@ printsub(char direction, /* '<' or '>' */
break;
}
fprintf(NetTrace, " %d %d (%d)",
- pointer[1], pointer[2],
- (int)((((unsigned int)pointer[1])<<8)|((unsigned int)pointer[2])));
+ pointer[1], pointer[2], (pointer[1]<<8) | pointer[2]);
if (length == 4) {
fprintf(NetTrace, " ?%d?", pointer[3]);
break;
}
fprintf(NetTrace, " %d %d (%d)",
- pointer[3], pointer[4],
- (int)((((unsigned int)pointer[3])<<8)|((unsigned int)pointer[4])));
+ pointer[3], pointer[4], (pointer[3]<<8) | pointer[4]);
for (i = 5; i < length; i++)
fprintf(NetTrace, " ?%d?", pointer[i]);
break;
@@ -499,7 +497,7 @@ printsub(char direction, /* '<' or '>' */
case WONT: cp = "WONT"; goto common2;
common2:
i++;
- if (TELOPT_OK((int)pointer[i]))
+ if (TELOPT_OK(pointer[i]))
fprintf(NetTrace, " %s %s", cp, TELOPT(pointer[i]));
else
fprintf(NetTrace, " %s %d", cp, pointer[i]);