Module Name: src
Committed By: lukem
Date: Tue Apr 14 09:18:41 UTC 2009
Modified Files:
src/usr.bin/xstr: xstr.c
Log Message:
Fix WARNS=4 (-Wcast-qual).
Fix creation of tempfile
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xstr/xstr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xstr/xstr.c
diff -u src/usr.bin/xstr/xstr.c:1.22 src/usr.bin/xstr/xstr.c:1.23
--- src/usr.bin/xstr/xstr.c:1.22 Mon Jul 21 14:19:28 2008
+++ src/usr.bin/xstr/xstr.c Tue Apr 14 09:18:41 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: xstr.c,v 1.22 2008/07/21 14:19:28 lukem Exp $ */
+/* $NetBSD: xstr.c,v 1.23 2009/04/14 09:18:41 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,11 +39,11 @@
#if 0
static char sccsid[] = "@(#)xstr.c 8.1 (Berkeley) 6/9/93";
#else
-__RCSID("$NetBSD: xstr.c,v 1.22 2008/07/21 14:19:28 lukem Exp $");
+__RCSID("$NetBSD: xstr.c,v 1.23 2009/04/14 09:18:41 lukem Exp $");
#endif
#endif /* not lint */
-#include <sys/types.h>
+#include <sys/param.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
@@ -79,8 +79,9 @@
static off_t tellpt;
static off_t mesgpt;
-static char *strings = "strings";
-static char *array = 0;
+static char stringtmpfile[MAXPATHLEN];
+static const char *strings = "strings";
+static const char *array = 0;
static int cflg;
static int vflg;
static int readstd;
@@ -132,8 +133,10 @@
else {
int fd;
- strings = strdup(_PATH_TMP);
- fd = mkstemp(strings);
+ snprintf(stringtmpfile, sizeof(stringtmpfile),
+ "%s%s.XXXXXX", _PATH_TMP, "xstr");
+ strings = stringtmpfile;
+ fd = mkstemp(stringtmpfile);
if (fd == -1)
err(1, "mkstemp failed");
close(fd);
@@ -261,7 +264,7 @@
char *cp = *cpp;
int c, ch;
char *dbuf, *dp, *edp;
- char *tp;
+ const char *tp;
off_t hash;
size_t bsiz = BUFSIZ;