Re: [PATCH] mm: mempolicy: turn vma_set_policy() intovma_dup_policy()

From: David Rientjes
Date: Thu Jul 11 2013 - 18:27:55 EST


On Thu, 11 Jul 2013, Andrew Morton wrote:

> On Thu, 11 Jul 2013 15:13:03 -0700 (PDT) David Rientjes <rientjes@xxxxxxxxxx> wrote:
>
> > > +int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
> > > +{
> > > + struct mempolicy *pol = mpol_dup(vma_policy(src));
> > > +
> > > + if (IS_ERR(pol))
> > > + return PTR_ERR(pol);
> >
> > PTR_ERR() returns long, so vma_dup_policy() needs to return long.
>
> hm, really? vma_dup_policy() returns an errno and errnos have type "int".
>
> Arguably it is PTR_ERR() which returns the wrong type...
>

PTR_ERR() may not imply IS_ERR(), which I believe Rusty is trying to fix
with his series that fixes up abuses of PTR_ERR(). But I agree that
vma_dup_policy() can return int because of the IS_ERR() check as written.

For complete correctness there should probably be a build error if
MAX_ERRNO cannot fit in an int and then this should do
return (int)PTR_ERR(pol) to make it clear.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/