Re: [patch 1/5] Introduce __WARN()

2008-01-06 Thread Richard Knutsson

Arjan van de Ven wrote:

On Sun, 06 Jan 2008 17:09:44 +0100
Richard Knutsson <[EMAIL PROTECTED]> wrote:

  

(btw, wouldn't 'var != 0' actually be the proper semantic instead
of playing with '!'s?)



no because var could be a pointer for example...
  
  

You mean because in that case it would be '!= NULL', do you? Sorry,
do not see your point here.



my point is that you don't know which one to use.. 
  
Sorry to be a bother, but why is that relevant? Except semantics, they 
are the same, right? So what problem would it be if you send it a 
pointer? The '!' uses the same "argument/reason" when given a pointer ;).

But this isn't new discussion (nor something I'm changing at all); this has come
up since way back in 2005 :)
If you feel strongly of changing this, feel free to post a patch; for now I much
rather leave things as they are right now.
  
Oh o-well, in such case I may come back and do a larger patching 
someday. Just though since you were in the neighborhood...


Have a good evening
Richard Knutsson

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 1/5] Introduce __WARN()

2008-01-06 Thread Arjan van de Ven
On Sun, 06 Jan 2008 17:09:44 +0100
Richard Knutsson <[EMAIL PROTECTED]> wrote:

> >> (btw, wouldn't 'var != 0' actually be the proper semantic instead
> >> of playing with '!'s?)
> >> 
> >
> > no because var could be a pointer for example...
> >   
> You mean because in that case it would be '!= NULL', do you? Sorry,
> do not see your point here.

my point is that you don't know which one to use.. 
But this isn't new discussion (nor something I'm changing at all); this has come
up since way back in 2005 :)
If you feel strongly of changing this, feel free to post a patch; for now I much
rather leave things as they are right now.


-- 
If you want to reach me at my work email, use [EMAIL PROTECTED]
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 1/5] Introduce __WARN()

2008-01-06 Thread Richard Knutsson

Arjan van de Ven wrote:

On Sun, 06 Jan 2008 12:44:56 +0100
Richard Knutsson <[EMAIL PROTECTED]> wrote:

  

Arjan van de Ven wrote:


From: Olof Johansson <[EMAIL PROTECTED]>

Introduce __WARN() in the generic case, so the generic WARN_ON()
can use arch-specific code for when the condition is true.

Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 include/asm-generic/bug.h |   17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

Index: linux-2.6.24-rc6/include/asm-generic/bug.h
===
--- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
+++ linux-2.6.24-rc6/include/asm-generic/bug.h
@@ -31,14 +31,19 @@ struct bug_entry {
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); }
while(0) #endif
 
-#ifndef HAVE_ARCH_WARN_ON

+#ifndef __WARN
+#define __WARN() do
{   \
+   printk("WARNING: at %s:%d %s()\n",
__FILE__,   \
+   __LINE__,
__FUNCTION__);  \
+
dump_stack();
\ +} while (0) +#endif
+
+#ifndef WARN_ON
 #define WARN_ON(condition)
({  \ int
__ret_warn_on = !!(condition);\ 
  


  

What about using a boolean for __ret_warn_on, which then let us
remove the '!!'?



is iffy.. like what happens if an u64 is cast to a boolean?
No matter what the final assembly code will need to be the same
  

Well, the main point were to use the boolean type instead of an integer...
What about u64? "true" is still "not zero", and is really the assembly 
the same for !!u8, !!u64 and !!pointer? Isn't that the reason to use a 
macro instead of a function?
(If you really mean "what happens?": any 'bool b = some_var;' will set 
'b' according to the C-idiom "if zero: 'false', otherwise 'true'".)
  
(btw, wouldn't 'var != 0' actually be the proper semantic instead of 
playing with '!'s?)



no because var could be a pointer for example...
  
You mean because in that case it would be '!= NULL', do you? Sorry, do 
not see your point here.


regards,
Richard Knutsson

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 1/5] Introduce __WARN()

2008-01-06 Thread Arjan van de Ven
On Sun, 06 Jan 2008 12:44:56 +0100
Richard Knutsson <[EMAIL PROTECTED]> wrote:

> Arjan van de Ven wrote:
> > From: Olof Johansson <[EMAIL PROTECTED]>
> >
> > Introduce __WARN() in the generic case, so the generic WARN_ON()
> > can use arch-specific code for when the condition is true.
> >
> > Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
> > ---
> >
> >  include/asm-generic/bug.h |   17 +++--
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > Index: linux-2.6.24-rc6/include/asm-generic/bug.h
> > ===
> > --- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
> > +++ linux-2.6.24-rc6/include/asm-generic/bug.h
> > @@ -31,14 +31,19 @@ struct bug_entry {
> >  #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); }
> > while(0) #endif
> >  
> > -#ifndef HAVE_ARCH_WARN_ON
> > +#ifndef __WARN
> > +#define __WARN() do
> > {   \
> > +   printk("WARNING: at %s:%d %s()\n",
> > __FILE__,   \
> > +   __LINE__,
> > __FUNCTION__);  \
> > +
> > dump_stack();
> > \ +} while (0) +#endif
> > +
> > +#ifndef WARN_ON
> >  #define WARN_ON(condition)
> > ({  \ int
> > __ret_warn_on = !!(condition);  \ 

> What about using a boolean for __ret_warn_on, which then let us
> remove the '!!'?

is iffy.. like what happens if an u64 is cast to a boolean?
No matter what the final assembly code will need to be the same

> (btw, wouldn't 'var != 0' actually be the proper semantic instead of 
> playing with '!'s?)

no because var could be a pointer for example...

-- 
If you want to reach me at my work email, use [EMAIL PROTECTED]
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 1/5] Introduce __WARN()

2008-01-06 Thread Richard Knutsson

Arjan van de Ven wrote:

From: Olof Johansson <[EMAIL PROTECTED]>

Introduce __WARN() in the generic case, so the generic WARN_ON()
can use arch-specific code for when the condition is true.

Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 include/asm-generic/bug.h |   17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

Index: linux-2.6.24-rc6/include/asm-generic/bug.h
===
--- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
+++ linux-2.6.24-rc6/include/asm-generic/bug.h
@@ -31,14 +31,19 @@ struct bug_entry {
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
 #endif
 
-#ifndef HAVE_ARCH_WARN_ON

+#ifndef __WARN
+#define __WARN() do {  \
+   printk("WARNING: at %s:%d %s()\n", __FILE__,  \
+   __LINE__, __FUNCTION__);\
+   dump_stack();   \
+} while (0)
+#endif
+
+#ifndef WARN_ON
 #define WARN_ON(condition) ({  \
int __ret_warn_on = !!(condition);  \
  
What about using a boolean for __ret_warn_on, which then let us remove 
the '!!'?
(btw, wouldn't 'var != 0' actually be the proper semantic instead of 
playing with '!'s?)

-   if (unlikely(__ret_warn_on)) {  \
-   printk("WARNING: at %s:%d %s()\n", __FILE__,  \
-   __LINE__, __FUNCTION__);\
-   dump_stack();   \
-   }   \
+   if (unlikely(__ret_warn_on))\
+   __WARN();   \
unlikely(__ret_warn_on);\
 })
 #endif

  


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 1/5] Introduce __WARN()

2008-01-06 Thread Richard Knutsson

Arjan van de Ven wrote:

From: Olof Johansson [EMAIL PROTECTED]

Introduce __WARN() in the generic case, so the generic WARN_ON()
can use arch-specific code for when the condition is true.

Signed-off-by: Olof Johansson [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 include/asm-generic/bug.h |   17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

Index: linux-2.6.24-rc6/include/asm-generic/bug.h
===
--- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
+++ linux-2.6.24-rc6/include/asm-generic/bug.h
@@ -31,14 +31,19 @@ struct bug_entry {
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
 #endif
 
-#ifndef HAVE_ARCH_WARN_ON

+#ifndef __WARN
+#define __WARN() do {  \
+   printk(WARNING: at %s:%d %s()\n, __FILE__,  \
+   __LINE__, __FUNCTION__);\
+   dump_stack();   \
+} while (0)
+#endif
+
+#ifndef WARN_ON
 #define WARN_ON(condition) ({  \
int __ret_warn_on = !!(condition);  \
  
What about using a boolean for __ret_warn_on, which then let us remove 
the '!!'?
(btw, wouldn't 'var != 0' actually be the proper semantic instead of 
playing with '!'s?)

-   if (unlikely(__ret_warn_on)) {  \
-   printk(WARNING: at %s:%d %s()\n, __FILE__,  \
-   __LINE__, __FUNCTION__);\
-   dump_stack();   \
-   }   \
+   if (unlikely(__ret_warn_on))\
+   __WARN();   \
unlikely(__ret_warn_on);\
 })
 #endif

  


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 1/5] Introduce __WARN()

2008-01-06 Thread Arjan van de Ven
On Sun, 06 Jan 2008 12:44:56 +0100
Richard Knutsson [EMAIL PROTECTED] wrote:

 Arjan van de Ven wrote:
  From: Olof Johansson [EMAIL PROTECTED]
 
  Introduce __WARN() in the generic case, so the generic WARN_ON()
  can use arch-specific code for when the condition is true.
 
  Signed-off-by: Olof Johansson [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Signed-off-by: Andrew Morton [EMAIL PROTECTED]
  ---
 
   include/asm-generic/bug.h |   17 +++--
   1 file changed, 11 insertions(+), 6 deletions(-)
 
  Index: linux-2.6.24-rc6/include/asm-generic/bug.h
  ===
  --- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
  +++ linux-2.6.24-rc6/include/asm-generic/bug.h
  @@ -31,14 +31,19 @@ struct bug_entry {
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); }
  while(0) #endif
   
  -#ifndef HAVE_ARCH_WARN_ON
  +#ifndef __WARN
  +#define __WARN() do
  {   \
  +   printk(WARNING: at %s:%d %s()\n,
  __FILE__,   \
  +   __LINE__,
  __FUNCTION__);  \
  +
  dump_stack();
  \ +} while (0) +#endif
  +
  +#ifndef WARN_ON
   #define WARN_ON(condition)
  ({  \ int
  __ret_warn_on = !!(condition);  \ 

 What about using a boolean for __ret_warn_on, which then let us
 remove the '!!'?

is iffy.. like what happens if an u64 is cast to a boolean?
No matter what the final assembly code will need to be the same

 (btw, wouldn't 'var != 0' actually be the proper semantic instead of 
 playing with '!'s?)

no because var could be a pointer for example...

-- 
If you want to reach me at my work email, use [EMAIL PROTECTED]
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 1/5] Introduce __WARN()

2008-01-06 Thread Arjan van de Ven
On Sun, 06 Jan 2008 17:09:44 +0100
Richard Knutsson [EMAIL PROTECTED] wrote:

  (btw, wouldn't 'var != 0' actually be the proper semantic instead
  of playing with '!'s?)
  
 
  no because var could be a pointer for example...

 You mean because in that case it would be '!= NULL', do you? Sorry,
 do not see your point here.

my point is that you don't know which one to use.. 
But this isn't new discussion (nor something I'm changing at all); this has come
up since way back in 2005 :)
If you feel strongly of changing this, feel free to post a patch; for now I much
rather leave things as they are right now.


-- 
If you want to reach me at my work email, use [EMAIL PROTECTED]
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch 1/5] Introduce __WARN()

2008-01-06 Thread Richard Knutsson

Arjan van de Ven wrote:

On Sun, 06 Jan 2008 17:09:44 +0100
Richard Knutsson [EMAIL PROTECTED] wrote:

  

(btw, wouldn't 'var != 0' actually be the proper semantic instead
of playing with '!'s?)



no because var could be a pointer for example...
  
  

You mean because in that case it would be '!= NULL', do you? Sorry,
do not see your point here.



my point is that you don't know which one to use.. 
  
Sorry to be a bother, but why is that relevant? Except semantics, they 
are the same, right? So what problem would it be if you send it a 
pointer? The '!' uses the same argument/reason when given a pointer ;).

But this isn't new discussion (nor something I'm changing at all); this has come
up since way back in 2005 :)
If you feel strongly of changing this, feel free to post a patch; for now I much
rather leave things as they are right now.
  
Oh o-well, in such case I may come back and do a larger patching 
someday. Just though since you were in the neighborhood...


Have a good evening
Richard Knutsson

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch 1/5] Introduce __WARN()

2008-01-05 Thread Arjan van de Ven
From: Olof Johansson <[EMAIL PROTECTED]>

Introduce __WARN() in the generic case, so the generic WARN_ON()
can use arch-specific code for when the condition is true.

Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 include/asm-generic/bug.h |   17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

Index: linux-2.6.24-rc6/include/asm-generic/bug.h
===
--- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
+++ linux-2.6.24-rc6/include/asm-generic/bug.h
@@ -31,14 +31,19 @@ struct bug_entry {
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
 #endif
 
-#ifndef HAVE_ARCH_WARN_ON
+#ifndef __WARN
+#define __WARN() do {  \
+   printk("WARNING: at %s:%d %s()\n", __FILE__,\
+   __LINE__, __FUNCTION__);\
+   dump_stack();   \
+} while (0)
+#endif
+
+#ifndef WARN_ON
 #define WARN_ON(condition) ({  \
int __ret_warn_on = !!(condition);  \
-   if (unlikely(__ret_warn_on)) {  \
-   printk("WARNING: at %s:%d %s()\n", __FILE__,\
-   __LINE__, __FUNCTION__);\
-   dump_stack();   \
-   }   \
+   if (unlikely(__ret_warn_on))\
+   __WARN();   \
unlikely(__ret_warn_on);\
 })
 #endif

-- 
If you want to reach me at my work email, use [EMAIL PROTECTED]
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch 1/5] Introduce __WARN()

2008-01-05 Thread Arjan van de Ven
From: Olof Johansson [EMAIL PROTECTED]

Introduce __WARN() in the generic case, so the generic WARN_ON()
can use arch-specific code for when the condition is true.

Signed-off-by: Olof Johansson [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 include/asm-generic/bug.h |   17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

Index: linux-2.6.24-rc6/include/asm-generic/bug.h
===
--- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
+++ linux-2.6.24-rc6/include/asm-generic/bug.h
@@ -31,14 +31,19 @@ struct bug_entry {
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
 #endif
 
-#ifndef HAVE_ARCH_WARN_ON
+#ifndef __WARN
+#define __WARN() do {  \
+   printk(WARNING: at %s:%d %s()\n, __FILE__,\
+   __LINE__, __FUNCTION__);\
+   dump_stack();   \
+} while (0)
+#endif
+
+#ifndef WARN_ON
 #define WARN_ON(condition) ({  \
int __ret_warn_on = !!(condition);  \
-   if (unlikely(__ret_warn_on)) {  \
-   printk(WARNING: at %s:%d %s()\n, __FILE__,\
-   __LINE__, __FUNCTION__);\
-   dump_stack();   \
-   }   \
+   if (unlikely(__ret_warn_on))\
+   __WARN();   \
unlikely(__ret_warn_on);\
 })
 #endif

-- 
If you want to reach me at my work email, use [EMAIL PROTECTED]
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/