Hi Martin,

Martin Vahlensieck wrote on Sat, Apr 04, 2020 at 07:16:46PM +0200:

> This makes these array derefs consistent with the others in the file.
> Also I believe this is the preferred way to do this.

That depends.  In mandoc, i certainly prefer "pointer + offset"
over "&pointer[offest]", arguing that pointer[offest] is defined
as mere syntactic sugar for *(pointer + offset), so to me
personally, "&pointer[offest]" feels like a slight detour.

But it looks like a matter of personal taste to me, and i doubt
that OpenBSD in general prefers one or the other.

Both are certainly correct, and i consider both readable.

Either way, this doesn't feel like an issue important enough
to patch one way or the other.

I can't really speak for the kernel, but that shouldn't matter
because this doesn't feel like a question specific to the kernel.

Yours,
  Ingo


> Index: kern_unveil.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/kern_unveil.c,v
> retrieving revision 1.39
> diff -u -p -r1.39 kern_unveil.c
> --- kern_unveil.c     22 Mar 2020 20:23:36 -0000      1.39
> +++ kern_unveil.c     4 Apr 2020 17:08:00 -0000
> @@ -204,7 +204,7 @@ unveil_destroy(struct process *ps)
>       size_t i;
>  
>       for (i = 0; ps->ps_uvpaths != NULL && i < ps->ps_uvvcount; i++) {
> -             struct unveil *uv = ps->ps_uvpaths + i;
> +             struct unveil *uv = &ps->ps_uvpaths[i];
>  
>               struct vnode *vp = uv->uv_vp;
>               /* skip any vnodes zapped by unveil_removevnode */
> @@ -244,8 +244,8 @@ unveil_copy(struct process *parent, stru
>       child->ps_uvncount = 0;
>       for (i = 0; parent->ps_uvpaths != NULL && i < parent->ps_uvvcount;
>            i++) {
> -             struct unveil *from = parent->ps_uvpaths + i;
> -             struct unveil *to = child->ps_uvpaths + i;
> +             struct unveil *from = &parent->ps_uvpaths[i];
> +             struct unveil *to = &child->ps_uvpaths[i];
>               struct unvname *unvn, *next;
>  
>               to->uv_vp = from->uv_vp;
> @@ -267,8 +267,8 @@ unveil_copy(struct process *parent, stru
>       }
>       child->ps_uvvcount = parent->ps_uvvcount;
>       if (parent->ps_uvpcwd)
> -             child->ps_uvpcwd = child->ps_uvpaths +
> -                 (parent->ps_uvpcwd - parent->ps_uvpaths);
> +             child->ps_uvpcwd =
> +                 &child->ps_uvpaths[parent->ps_uvpcwd - parent->ps_uvpaths];
>       child->ps_uvdone = parent->ps_uvdone;
>       child->ps_uvshrink = parent->ps_uvshrink;
>  }

Reply via email to