Re: time(1): make global flags local

2017-07-22 Thread Ingo Schwarze
Hi,

Scott Cheloha wrote on Thu, Jul 13, 2017 at 07:14:08PM -0500:

> The flags don't need to be global, and there are more obvious
> ways to zero a variable.
> 
> While here, order the stack structures and variables by size.

Committed with tweaks.
  Ingo


> Index: usr.bin/time/time.c
> ===
> RCS file: /cvs/src/usr.bin/time/time.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 time.c
> --- usr.bin/time/time.c   13 Jul 2017 06:39:54 -  1.22
> +++ usr.bin/time/time.c   14 Jul 2017 00:10:09 -
> @@ -42,19 +42,17 @@
>  #include 
>  #include 
>  
> -int lflag;
> -int portableflag;
> -
>  __dead void usage(void);
>  
>  int
>  main(int argc, char *argv[])
>  {
> - pid_t pid;
> - int ch, status;
> - struct timespec before, after, during;
>   struct rusage ru;
> - int exitonsig = 0;
> + struct timespec before, after, during;
> + pid_t pid;
> + int ch, exitonsig, lflag, portableflag, status;
> +
> + exitonsig = lflag = portableflag = 0;
>  
>   if (pledge("stdio proc exec", NULL) == -1)
>   err(1, "pledge");



time(1): make global flags local

2017-07-13 Thread Scott Cheloha
The flags don't need to be global, and there are more obvious
ways to zero a variable.

While here, order the stack structures and variables by size.

--
Scott Cheloha

Index: usr.bin/time/time.c
===
RCS file: /cvs/src/usr.bin/time/time.c,v
retrieving revision 1.22
diff -u -p -r1.22 time.c
--- usr.bin/time/time.c 13 Jul 2017 06:39:54 -  1.22
+++ usr.bin/time/time.c 14 Jul 2017 00:10:09 -
@@ -42,19 +42,17 @@
 #include 
 #include 
 
-int lflag;
-int portableflag;
-
 __dead void usage(void);
 
 int
 main(int argc, char *argv[])
 {
-   pid_t pid;
-   int ch, status;
-   struct timespec before, after, during;
struct rusage ru;
-   int exitonsig = 0;
+   struct timespec before, after, during;
+   pid_t pid;
+   int ch, exitonsig, lflag, portableflag, status;
+
+   exitonsig = lflag = portableflag = 0;
 
if (pledge("stdio proc exec", NULL) == -1)
err(1, "pledge");