linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] futex: s/0/NULL/ in pointer context
@ 2005-01-09  9:23 Alexey Dobriyan
  2005-01-09 14:19 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2005-01-09  9:23 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel

Signed-off-by: Alexey Dobriyan <adobriyan@mail.ru>

Index: linux-2.6.10-bk11-warnings/kernel/futex.c
===================================================================
--- linux-2.6.10-bk11-warnings/kernel/futex.c	(revision 4)
+++ linux-2.6.10-bk11-warnings/kernel/futex.c	(revision 5)
@@ -236,7 +236,7 @@
  */
 static inline void get_key_refs(union futex_key *key)
 {
-	if (key->both.ptr != 0) {
+	if (key->both.ptr != NULL) {
 		if (key->both.offset & 1)
 			atomic_inc(&key->shared.inode->i_count);
 		else
@@ -250,7 +250,7 @@
  */
 static void drop_key_refs(union futex_key *key)
 {
-	if (key->both.ptr != 0) {
+	if (key->both.ptr != NULL) {
 		if (key->both.offset & 1)
 			iput(key->shared.inode);
 		else
@@ -445,7 +445,7 @@
 	/* In the common case we don't take the spinlock, which is nice. */
  retry:
 	lock_ptr = q->lock_ptr;
-	if (lock_ptr != 0) {
+	if (lock_ptr != NULL) {
 		spin_lock(lock_ptr);
 		/*
 		 * q->lock_ptr can change between reading it and

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] futex: s/0/NULL/ in pointer context
  2005-01-09  9:23 [PATCH] futex: s/0/NULL/ in pointer context Alexey Dobriyan
@ 2005-01-09 14:19 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2005-01-09 14:19 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: Rusty Russell, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

On Sünndag 09 Januar 2005 10:23, Alexey Dobriyan wrote:
> @@ -236,7 +236,7 @@
>   */
>  static inline void get_key_refs(union futex_key *key)
>  {
> -	if (key->both.ptr != 0) {
> +	if (key->both.ptr != NULL) {
>  		if (key->both.offset & 1)
>  			atomic_inc(&key->shared.inode->i_count);
>  		else

Actually, many consider the preferred way to write this

	if (key->both.ptr) {

instead, since the condition you want to check is 'is key->both.ptr
a valid pointer', not 'is key->both.ptr inequal to the invalid
pointer'. The normal use for NULL is only in assignments and 
initializations, not in comparisons.

	Arnd <><

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-01-09 14:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-09  9:23 [PATCH] futex: s/0/NULL/ in pointer context Alexey Dobriyan
2005-01-09 14:19 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).