top: remove duplicate initialisation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

top: remove duplicate initialisation

Klemens Nanni-2
Those are global variables are (zero) initialised as such already and
machine_init() is called only once upon startup.

Feedback? OK?


Index: machine.c
===================================================================
RCS file: /cvs/src/usr.bin/top/machine.c,v
retrieving revision 1.105
diff -u -p -r1.105 machine.c
--- machine.c 25 Jun 2020 20:38:41 -0000 1.105
+++ machine.c 26 Jun 2020 17:21:18 -0000
@@ -203,11 +203,6 @@ machine_init(struct statics *statics)
  if (cpu_online == NULL)
  err(1, NULL);
 
- pbase = NULL;
- pref = NULL;
- onproc = -1;
- nproc = 0;
-
  /*
  * get the page size with "getpagesize" and calculate pageshift from
  * it

Reply | Threaded
Open this post in threaded view
|

Re: top: remove duplicate initialisation

Vitaliy Makkoveev


> On 26 Jun 2020, at 22:00, Klemens Nanni <[hidden email]> wrote:
>
> Those are global variables are (zero) initialised as such already and
> machine_init() is called only once upon startup.
>
> Feedback? OK?
>
>
> Index: machine.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/top/machine.c,v
> retrieving revision 1.105
> diff -u -p -r1.105 machine.c
> --- machine.c 25 Jun 2020 20:38:41 -0000 1.105
> +++ machine.c 26 Jun 2020 17:21:18 -0000
> @@ -203,11 +203,6 @@ machine_init(struct statics *statics)
> if (cpu_online == NULL)
> err(1, NULL);
>
> - pbase = NULL;
> - pref = NULL;
> - onproc = -1;
> - nproc = 0;
> -
> /*
> * get the page size with "getpagesize" and calculate pageshift from
> * it
>

What about “pageshift = 0;” at usr.bin/top/machine.c:216 ?
Reply | Threaded
Open this post in threaded view
|

Re: top: remove duplicate initialisation

Klemens Nanni-2
On Fri, Jun 26, 2020 at 11:07:54PM +0300, Vitaliy Makkoveev wrote:
> What about “pageshift = 0;” at usr.bin/top/machine.c:216 ?
Could be removed as well but I left it in there intentionally to keep
this block of code readable since pageshift is not only set but used
immediately afterwards as well.

Reply | Threaded
Open this post in threaded view
|

Re: top: remove duplicate initialisation

Vitaliy Makkoveev


> On 26 Jun 2020, at 23:12, Klemens Nanni <[hidden email]> wrote:
>
> On Fri, Jun 26, 2020 at 11:07:54PM +0300, Vitaliy Makkoveev wrote:
>> What about “pageshift = 0;” at usr.bin/top/machine.c:216 ?
> Could be removed as well but I left it in there intentionally to keep
> this block of code readable since pageshift is not only set but used
> immediately afterwards as well.
>
I don’t think someone changed value to fill .data section :)
ok mvs@