We can't have 2 billion processes to reach a wrap.

But I agree, it seems quite wrong, and seems better to just observe
match rather than count.


Scott Cheloha <[email protected]> wrote:

> `found' serves as a boolean here.  I'd prefer to simple and set it to
> 1 instead of incrementing it when we find what we're looking for.
> 
> ok?
> 
> Index: kern_resource.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/kern_resource.c,v
> retrieving revision 1.68
> diff -u -p -r1.68 kern_resource.c
> --- kern_resource.c   15 Jul 2019 20:44:48 -0000      1.68
> +++ kern_resource.c   25 Sep 2020 18:54:34 -0000
> @@ -157,7 +157,7 @@ sys_setpriority(struct proc *curp, void 
>               if (pr == NULL)
>                       break;
>               error = donice(curp, pr, SCARG(uap, prio));
> -             found++;
> +             found = 1;
>               break;
>  
>       case PRIO_PGRP: {
> @@ -169,7 +169,7 @@ sys_setpriority(struct proc *curp, void 
>                       break;
>               LIST_FOREACH(pr, &pg->pg_members, ps_pglist) {
>                       error = donice(curp, pr, SCARG(uap, prio));
> -                     found++;
> +                     found = 1;
>               }
>               break;
>       }
> @@ -180,14 +180,14 @@ sys_setpriority(struct proc *curp, void 
>               LIST_FOREACH(pr, &allprocess, ps_list)
>                       if (pr->ps_ucred->cr_uid == SCARG(uap, who)) {
>                               error = donice(curp, pr, SCARG(uap, prio));
> -                             found++;
> +                             found = 1;
>                       }
>               break;
>  
>       default:
>               return (EINVAL);
>       }
> -     if (found == 0)
> +     if (!found)
>               return (ESRCH);
>       return (error);
>  }
> 

Reply via email to