mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jani Nikula <ext-jani.1.nikula@nokia.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, ext-phil.2.carmody@nokia.com,
	ext-jani.1.nikula@nokia.com
Subject: [PATCH] err.h: add __must_check to error pointer handlers
Date: Fri, 12 Mar 2010 15:45:40 +0200	[thread overview]
Message-ID: <1268401540-8994-1-git-send-email-ext-jani.1.nikula@nokia.com> (raw)

Add __must_check to error pointer handlers to have the compiler warn
about mistakes like:

	if (err)
		ERR_PTR(err);

Signed-off-by: Jani Nikula <ext-jani.1.nikula@nokia.com>
---
 include/linux/err.h |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/err.h b/include/linux/err.h
index 1b12642..448afc1 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -19,22 +19,22 @@
 
 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
 
-static inline void *ERR_PTR(long error)
+static inline void * __must_check ERR_PTR(long error)
 {
 	return (void *) error;
 }
 
-static inline long PTR_ERR(const void *ptr)
+static inline long __must_check PTR_ERR(const void *ptr)
 {
 	return (long) ptr;
 }
 
-static inline long IS_ERR(const void *ptr)
+static inline long __must_check IS_ERR(const void *ptr)
 {
 	return IS_ERR_VALUE((unsigned long)ptr);
 }
 
-static inline long IS_ERR_OR_NULL(const void *ptr)
+static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
 {
 	return !ptr || IS_ERR_VALUE((unsigned long)ptr);
 }
@@ -46,7 +46,7 @@ static inline long IS_ERR_OR_NULL(const void *ptr)
  * Explicitly cast an error-valued pointer to another pointer type in such a
  * way as to make it clear that's what's going on.
  */
-static inline void *ERR_CAST(const void *ptr)
+static inline void * __must_check ERR_CAST(const void *ptr)
 {
 	/* cast away the const */
 	return (void *) ptr;
-- 
1.6.5.2


             reply	other threads:[~2010-03-12 13:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-12 13:45 Jani Nikula [this message]
2010-03-12 18:40 ` Alexey Dobriyan
2010-03-12 19:45   ` Phil Carmody

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1268401540-8994-1-git-send-email-ext-jani.1.nikula@nokia.com \
    --to=ext-jani.1.nikula@nokia.com \
    --cc=akpm@linux-foundation.org \
    --cc=ext-phil.2.carmody@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®