diff mbox series

[3/5] dispol: introduce a local variable representing the input file

Message ID 20191008064500.8651-5-yamato@redhat.com (mailing list archive)
State Changes Requested
Headers show
Series dispol: add batch execution mode | expand

Commit Message

Masatake YAMATO Oct. 8, 2019, 6:44 a.m. UTC
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 checkpolicy/test/dispol.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/checkpolicy/test/dispol.c b/checkpolicy/test/dispol.c
index 37b22cf8..26bbba7a 100644
--- a/checkpolicy/test/dispol.c
+++ b/checkpolicy/test/dispol.c
@@ -394,6 +394,7 @@  int main(int argc, char **argv)
 	char *name;
 	int state;
 	struct policy_file pf;
+	char *pf_name;
 
 	if (argc <= 1)
 		usage(argv[0], 1);
@@ -401,23 +402,24 @@  int main(int argc, char **argv)
 		usage(argv[0], 0);
 	else if (argc != 2)
 		usage(argv[0], 1);
+	pf_name = argv[1];
 
-	fd = open(argv[1], O_RDONLY);
+	fd = open(pf_name, O_RDONLY);
 	if (fd < 0) {
 		fprintf(stderr, "Can't open '%s':  %s\n",
-			argv[1], strerror(errno));
+			pf_name, strerror(errno));
 		exit(1);
 	}
 	if (fstat(fd, &sb) < 0) {
 		fprintf(stderr, "Can't stat '%s':  %s\n",
-			argv[1], strerror(errno));
+			pf_name, strerror(errno));
 		exit(1);
 	}
 	map =
 	    mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
 	if (map == MAP_FAILED) {
 		fprintf(stderr, "Can't map '%s':  %s\n",
-			argv[1], strerror(errno));
+			pf_name, strerror(errno));
 		exit(1);
 	}