summaryrefslogtreecommitdiffstats
path: root/games
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2004-10-03 15:34:15 +0000
committerstefanf <stefanf@FreeBSD.org>2004-10-03 15:34:15 +0000
commit0de63fceef7039368c7b5222bb95578d140b9e63 (patch)
tree3b15eb116dec207c33c450a81f741792460a7cd3 /games
parent3f19c69c3aaf3489a5ba896c546f4fbcb13f2fd9 (diff)
downloadFreeBSD-src-0de63fceef7039368c7b5222bb95578d140b9e63.zip
FreeBSD-src-0de63fceef7039368c7b5222bb95578d140b9e63.tar.gz
Properly initialise 'filename' so that random -l doesn't try to open NULL.
Const-qualify 'filename' to avoid a strdup() call due to -Wwrite-strings silliness.
Diffstat (limited to 'games')
-rw-r--r--games/random/random.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/games/random/random.c b/games/random/random.c
index e7c85bb..e06c4bc 100644
--- a/games/random/random.c
+++ b/games/random/random.c
@@ -70,10 +70,11 @@ main(int argc, char *argv[])
double denom;
int ch, fd, random_exit, randomize_lines, random_type, ret,
selected, unique_output, unbuffer_output;
- char *ep, *filename;
+ char *ep;
+ const char *filename;
denom = 0;
- filename = NULL;
+ filename = "/dev/fd/0";
random_type = RANDOM_TYPE_UNSET;
random_exit = randomize_lines = random_type = unbuffer_output = 0;
unique_output = 1;
@@ -84,9 +85,7 @@ main(int argc, char *argv[])
break;
case 'f':
randomize_lines = 1;
- if (!strcmp(optarg, "-"))
- filename = strdup("/dev/fd/0");
- else
+ if (strcmp(optarg, "-") != 0)
filename = optarg;
break;
case 'l':
OpenPOWER on IntegriCloud