* Nick Hibma <[EMAIL PROTECTED]> [010908 04:51] wrote:
>
> Why don't you add an early-out for namelength => 15 or put the
> if-statement in the loop:
This is a good idea, however it fails for the case when everyone
has been assigned usernames that are less than 15 characters, I
would suggest putting an upper bounds on the amount of times you'll
call getpwent() to something like 200 or some other compile time
(but command line over-rideable) number before defaulting to the
max.
>
> Index: machine.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/top/machine.c,v
> retrieving revision 1.44
> diff -u -r1.44 machine.c
> --- machine.c 2001/05/31 22:36:51 1.44
> +++ machine.c 2001/09/08 09:48:03
> @@ -216,13 +216,16 @@
> while ((pw = getpwent()) != NULL) {
> if (strlen(pw->pw_name) > namelength)
> namelength = strlen(pw->pw_name);
> + if (smpmode && namelength > 13) {
> + namelength = 13;
> + break;
> + } else if (namelength > 15) {
> + namelength = 15;
> + break;
> + }
> }
> if (namelength < 8)
> namelength = 8;
> - if (smpmode && namelength > 13)
> - namelength = 13;
> - else if (namelength > 15)
> - namelength = 15;
>
> if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY,
> "kvm_open")) == NULL)
> return -1;
>
>
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message