From b8a2ba9456efb0d5d1970b725d46d45fe8d193fd Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Wed, 2 Mar 2005 05:00:21 +0000 Subject: [PATCH] Merge with FreeBSD, revision 1.16 (stefanf): "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." --- games/random/random.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/games/random/random.c b/games/random/random.c index 79a7bd52d1..7d34a5d7f5 100644 --- a/games/random/random.c +++ b/games/random/random.c @@ -35,8 +35,8 @@ * * @(#) Copyright (c) 1994 The Regents of the University of California. All rights reserved. * @(#)random.c 8.5 (Berkeley) 4/5/94 - * $FreeBSD: src/games/random/random.c,v 1.11.2.1 2003/02/15 10:34:35 seanc Exp $ - * $DragonFly: src/games/random/random.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ + * $FreeBSD: src/games/random/random.c,v 1.16 2004/10/03 15:34:15 stefanf Exp $ + * $DragonFly: src/games/random/random.c,v 1.3 2005/03/02 05:00:21 cpressey Exp $ */ #include @@ -61,10 +61,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; @@ -75,9 +76,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': -- 2.41.0