Skip to content

Commit

Permalink
PTR_RET is now PTR_ERR_OR_ZERO
Browse files Browse the repository at this point in the history
True, it's often used in return statements, but after much bikeshedding
it's probably better to have an explicit name.

(I tried just putting the IS_ERR check inside PTR_ERR itself and gcc
usually generated no more code.  But that clashes current expectations
of how PTR_ERR behaves, so having a separate function is better).

Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Rusty Russell committed Jul 15, 2013
1 parent ad81f05 commit 6e8b872
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/linux/err.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ static inline void * __must_check ERR_CAST(__force const void *ptr)
return (void *) ptr;
}

static inline int __must_check PTR_RET(__force const void *ptr)
static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
{
if (IS_ERR(ptr))
return PTR_ERR(ptr);
else
return 0;
}

/* Deprecated */
#define PTR_RET(p) PTR_ERR_OR_ZERO(p)

#endif

#endif /* _LINUX_ERR_H */

0 comments on commit 6e8b872

Please sign in to comment.