Hi,

pledge "stdio rpath" is already called in main(), so we can remove the
duplicate from parse_args(), along with the pledge commented out from another
era!

The second part is about placing pledge "stdio" in main() instead for better
readability (at least for me).

No functional change is intended here and regress still pass, comments ok?

Index: tsort.c
===================================================================
RCS file: /cvs/src/usr.bin/tsort/tsort.c,v
retrieving revision 1.36
diff -u -p -u -r1.36 tsort.c
--- tsort.c     20 May 2017 09:31:19 -0000      1.36
+++ tsort.c     11 Jul 2019 12:13:00 -0000
@@ -879,10 +879,6 @@ parse_args(int argc, char *argv[], struc
 
        files[i] = NULL;
 
-/*     if (pledge("stdio rpath", files) == -1) */
-       if (pledge("stdio rpath", NULL) == -1)
-               err(1, "pledge");
-
        nodes_init(pairs);
        order = 0;
                
@@ -910,9 +906,6 @@ parse_args(int argc, char *argv[], struc
                order = read_pairs(stdin, pairs, reverse_flag, "stdin",
                    order, hints_flag == 2);
        }
-
-       if (pledge("stdio", NULL) == -1)
-               err(1, "pledge");
 }
 
 static int
@@ -1003,6 +996,10 @@ main(int argc, char *argv[])
                err(1, "pledge");
 
        parse_args(argc, argv, &pairs);
+
+       if (pledge("stdio", NULL) == -1)
+               err(1, "pledge");
+
        return tsort(&pairs);
 }
 

Reply via email to