Re: Tabs, spaces, indent and 80 character lines

2008-02-25 Thread Richard Knutsson

Miles Bader wrote:

Why do people even respond to these trolls...?

-Miles
  
Obviously, this must to have been discussed before, with a clear 
conclusion. Unfortunately, I have not, during my ~2 years on the list, 
seen anything of the sort and would like to, in that case, request a 
small direction and apologize for the noise.



Richard "_not_ all knowing" Knutsson

BTW, your question:
* they like to be helpful
* they find the question reasonable
* they like furry animals
...
Sorry, am tired, but if you like I can keep you posted when I come up 
with more reasons.


--
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: Tabs, spaces, indent and 80 character lines

2008-02-25 Thread Richard Knutsson

Krzysztof Halasa wrote:

Richard Knutsson <[EMAIL PROTECTED]> writes:

  

I guess we could use tabs only at the line start, for indentation
only. Rather hard to implement, most text editors can't do that yet.
  
  

You mean for split lines?



Syntactic indentation vs alignment (including comments after
non-blank, values for struct initialization etc, split lines too).

  

'alignment', that's the word, thanks!

Hopefully there won't be that many, so there
is just to delete the tabs it added and replace it with spaces.



Actually tabs "should" be used for indentation at start of the
line, then spaces. "Ideally" :-)

I.e., something like
 if (cond && (cond2 ||
 _cond3))
  do_something();

Underline = space.

Perhaps some day...

  

Exactly! But then we can remove the "we use 8 wide tabs in the kernel"
in CodeStyle.



I'm not sure it's practically possible now.
  
Well, can always patch CodeStyle and checkpatch.pl and then see what the 
rest thinks.


Think checkpatch is fairly easy to "fix". It seems to have all the lines 
in an array so there is only a need to check the indent-depth of the 
line above and see if the current is the same with only spaces afterwards.


The idea was to reply with a patch, but it is bit late now.
  

Unpacked sources will be much bigger with not tabs, sure.
  
  

Without no tabs at all, you mean?



With spaces in place of all tabs.

All tabs converted to spaces = 20% more?
"Alignment" tabs converted to spaces? How cares how much more would it
take if it's the correct thing. Except that it's not very practical at
this point.
  

Would guess more...
The reason I reacted were because checkpatch.pl complained about a:
foo(int a,
int b)
with the "use tabs not spaces". There is little point in patching this 
stuff but lets not make it worse (IMHO).


--
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: Tabs, spaces, indent and 80 character lines

2008-02-25 Thread Richard Knutsson

Benny Halevy wrote:

On Feb. 24, 2008, 7:40 -0800, Richard Knutsson <[EMAIL PROTECTED]> wrote:
  

Krzysztof Halasa wrote:


Richard Knutsson <[EMAIL PROTECTED]> writes:

  
  

Why hinder a developer who prefer
2, 4, 6 or any other != 8 width?



I guess we could use tabs only at the line start, for indentation
only. Rather hard to implement, most text editors can't do that yet.
  
  
You mean for split lines? Hopefully there won't be that many, so there 
is just to delete the tabs it added and replace it with spaces.



IMO, tabs SHOULD be used for syntactic indentation and spaces for
decoration purpose only.  I.e. a line should start with a number of tabs
equal to its nesting level and after that only spaces should be used.
for example, the following code

for (i = 0; i < n; i++) printk("a very long format string", some, parameters);

should be formatted like this:

for (i = 0; i < n; i++)
printk("a very long format string",
   some, parameters);

this will show exactly right regardless of your editor's tab expansion setting
as long as you use fixed-width fonts - where the screen width of the space 
character
is equal to all other characters.  Once you start using tabs instead of spaces
to push text right so it appears exactly below some other text on the line above
you make a dependency on *your* editor's tab expansion policy and that's not 
very
considerate for folks who prefer a different one.
  

Don't know what to say more then: Yup! :)

But the CodeStyle-document and checkpatch.pl does not agree with that.

--
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: Tabs, spaces, indent and 80 character lines

2008-02-25 Thread Richard Knutsson

Benny Halevy wrote:

On Feb. 24, 2008, 7:40 -0800, Richard Knutsson [EMAIL PROTECTED] wrote:
  

Krzysztof Halasa wrote:


Richard Knutsson [EMAIL PROTECTED] writes:

  
  

Why hinder a developer who prefer
2, 4, 6 or any other != 8 width?



I guess we could use tabs only at the line start, for indentation
only. Rather hard to implement, most text editors can't do that yet.
  
  
You mean for split lines? Hopefully there won't be that many, so there 
is just to delete the tabs it added and replace it with spaces.



IMO, tabs SHOULD be used for syntactic indentation and spaces for
decoration purpose only.  I.e. a line should start with a number of tabs
equal to its nesting level and after that only spaces should be used.
for example, the following code

for (i = 0; i  n; i++) printk(a very long format string, some, parameters);

should be formatted like this:

tabs...for (i = 0; i  n; i++)
tabs...tabprintk(a very long format string,
tabs...tab   some, parameters);

this will show exactly right regardless of your editor's tab expansion setting
as long as you use fixed-width fonts - where the screen width of the space 
character
is equal to all other characters.  Once you start using tabs instead of spaces
to push text right so it appears exactly below some other text on the line above
you make a dependency on *your* editor's tab expansion policy and that's not 
very
considerate for folks who prefer a different one.
  

Don't know what to say more then: Yup! :)

But the CodeStyle-document and checkpatch.pl does not agree with that.

--
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: Tabs, spaces, indent and 80 character lines

2008-02-25 Thread Richard Knutsson

Krzysztof Halasa wrote:

Richard Knutsson [EMAIL PROTECTED] writes:

  

I guess we could use tabs only at the line start, for indentation
only. Rather hard to implement, most text editors can't do that yet.
  
  

You mean for split lines?



Syntactic indentation vs alignment (including comments after
non-blank, values for struct initialization etc, split lines too).

  

'alignment', that's the word, thanks!

Hopefully there won't be that many, so there
is just to delete the tabs it added and replace it with spaces.



Actually tabs should be used for indentation at start of the
line, then spaces. Ideally :-)

I.e., something like
TAB if (cond  (cond2 ||
TAB _cond3))
TAB TAB do_something();

Underline = space.

Perhaps some day...

  

Exactly! But then we can remove the we use 8 wide tabs in the kernel
in CodeStyle.



I'm not sure it's practically possible now.
  
Well, can always patch CodeStyle and checkpatch.pl and then see what the 
rest thinks.


Think checkpatch is fairly easy to fix. It seems to have all the lines 
in an array so there is only a need to check the indent-depth of the 
line above and see if the current is the same with only spaces afterwards.


The idea was to reply with a patch, but it is bit late now.
  

Unpacked sources will be much bigger with not tabs, sure.
  
  

Without no tabs at all, you mean?



With spaces in place of all tabs.

All tabs converted to spaces = 20% more?
Alignment tabs converted to spaces? How cares how much more would it
take if it's the correct thing. Except that it's not very practical at
this point.
  

Would guess more...
The reason I reacted were because checkpatch.pl complained about a:
tabtabfoo(int a,
tabtabint b)
with the use tabs not spaces. There is little point in patching this 
stuff but lets not make it worse (IMHO).


--
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: Tabs, spaces, indent and 80 character lines

2008-02-25 Thread Richard Knutsson

Miles Bader wrote:

Why do people even respond to these trolls...?

-Miles
  
Obviously, this must to have been discussed before, with a clear 
conclusion. Unfortunately, I have not, during my ~2 years on the list, 
seen anything of the sort and would like to, in that case, request a 
small direction and apologize for the noise.



Richard _not_ all knowing Knutsson

BTW, your question:
* they like to be helpful
* they find the question reasonable
* they like furry animals
...
Sorry, am tired, but if you like I can keep you posted when I come up 
with more reasons.


--
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: Tabs, spaces, indent and 80 character lines

2008-02-24 Thread Richard Knutsson

Krzysztof Halasa wrote:

Richard Knutsson <[EMAIL PROTECTED]> writes:

  

Why hinder a developer who prefer
2, 4, 6 or any other != 8 width?



I guess we could use tabs only at the line start, for indentation
only. Rather hard to implement, most text editors can't do that yet.
  
You mean for split lines? Hopefully there won't be that many, so there 
is just to delete the tabs it added and replace it with spaces.
  

By only using tabs as indents, and
changing the CodeStyle to be something like "maximum 80
characters-wide lines, with a tab-setting of 8 spaces",



This changes nothing.
  
Exactly! But then we can remove the "we use 8 wide tabs in the kernel" 
in CodeStyle.
  

that is
possible + easier to write code-checkers [2].



I doubt it.
  
Easier to write code-checkers? OK, maybe not. Just that I got hit by 
this problem at a time when I wrote a simple checker (don't remember its 
purpose).
  

Or are we really that concerned about the disk-space? ;)



Unpacked sources will be much bigger with not tabs, sure.
  
Without no tabs at all, you mean? Don't want to think about that 
scenario, but with this suggestion, I would estimate maybe 0,5 - 1% bigger.


Thanks for your input

--
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: Tabs, spaces, indent and 80 character lines

2008-02-24 Thread Richard Knutsson

Krzysztof Halasa wrote:

Richard Knutsson [EMAIL PROTECTED] writes:

  

Why hinder a developer who prefer
2, 4, 6 or any other != 8 width?



I guess we could use tabs only at the line start, for indentation
only. Rather hard to implement, most text editors can't do that yet.
  
You mean for split lines? Hopefully there won't be that many, so there 
is just to delete the tabs it added and replace it with spaces.
  

By only using tabs as indents, and
changing the CodeStyle to be something like maximum 80
characters-wide lines, with a tab-setting of 8 spaces,



This changes nothing.
  
Exactly! But then we can remove the we use 8 wide tabs in the kernel 
in CodeStyle.
  

that is
possible + easier to write code-checkers [2].



I doubt it.
  
Easier to write code-checkers? OK, maybe not. Just that I got hit by 
this problem at a time when I wrote a simple checker (don't remember its 
purpose).
  

Or are we really that concerned about the disk-space? ;)



Unpacked sources will be much bigger with not tabs, sure.
  
Without no tabs at all, you mean? Don't want to think about that 
scenario, but with this suggestion, I would estimate maybe 0,5 - 1% bigger.


Thanks for your input

--
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/


Tabs, spaces, indent and 80 character lines

2008-02-23 Thread Richard Knutsson

Good evening

In the thread "Merging of completely unreviewed drivers" I got reminded 
of the "use tabs not spaces"-mentality.

My question is: why?

The tab-character serves us well as a indent-indicator, but for some 
reason there has been focus on its relation to spaces. On the question 
"How long should a line at maximum be?" it is relevant (the question is 
not [1]). So it is set to be as wide as 8 spaces, but when did it become 
a replacement for 8 spaces? Why hinder a developer who prefer 2, 4, 6 or 
any other != 8 width? By only using tabs as indents, and changing the 
CodeStyle to be something like "maximum 80 characters-wide lines, with a 
tab-setting of 8 spaces", that is possible + easier to write 
code-checkers [2].


Or are we really that concerned about the disk-space? ;)

2 cents away...
/Richard Knutsson

[1] As has been pointed out by many, it is the complexity that matters 
(code-checker). A short line can be overly complicated and still under 
80 lines and vice versa. Let the editors handle the long lines for the 
author (even I should be able to write a decent script who can decide 
where to chop-off the line).


[2] As it is now, it can look like the indentation is ex. ... 2, 2, 5, 
3, 3... because the second line is split up. (I think it should have 
been 2, 2, 2, 3, 3 (or even better: 2, 2, 3, 3 ))


--
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/


Tabs, spaces, indent and 80 character lines

2008-02-23 Thread Richard Knutsson

Good evening

In the thread Merging of completely unreviewed drivers I got reminded 
of the use tabs not spaces-mentality.

My question is: why?

The tab-character serves us well as a indent-indicator, but for some 
reason there has been focus on its relation to spaces. On the question 
How long should a line at maximum be? it is relevant (the question is 
not [1]). So it is set to be as wide as 8 spaces, but when did it become 
a replacement for 8 spaces? Why hinder a developer who prefer 2, 4, 6 or 
any other != 8 width? By only using tabs as indents, and changing the 
CodeStyle to be something like maximum 80 characters-wide lines, with a 
tab-setting of 8 spaces, that is possible + easier to write 
code-checkers [2].


Or are we really that concerned about the disk-space? ;)

2 cents away...
/Richard Knutsson

[1] As has been pointed out by many, it is the complexity that matters 
(code-checker). A short line can be overly complicated and still under 
80 lines and vice versa. Let the editors handle the long lines for the 
author (even I should be able to write a decent script who can decide 
where to chop-off the line).


[2] As it is now, it can look like the indentation is ex. ... 2, 2, 5, 
3, 3... because the second line is split up. (I think it should have 
been 2, 2, 2, 3, 3 (or even better: 2, 2, 3, 3 ))


--
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] Silent compiler warning introduced by acea6852f32b8805e166d885ed7e9f0c7cd10d41 ([BLUETOOTH]: Move children of connection device to NULL before connection down.)

2008-02-10 Thread Richard Knutsson

S.Çağlar Onur wrote:

Hi;

Following patch silents

net/bluetooth/hci_sysfs.c: In function `del_conn':
net/bluetooth/hci_sysfs.c:339: warning: suggest parentheses around assignment 
used as truth value

compiler warning introduced by commit acea6852f32b8805e166d885ed7e9f0c7cd10d41 
([BLUETOOTH]: Move children of connection device to NULL before connection 
down.)

Signed-off-by: S.Çağlar Onur <[EMAIL PROTECTED]>

 net/bluetooth/hci_sysfs.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index e13cf5e..d2d1e4f 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -336,7 +336,7 @@ static void del_conn(struct work_struct *work)
struct device *dev;
struct hci_conn *conn = container_of(work, struct hci_conn, work);
 
-	while (dev = device_find_child(>dev, NULL, __match_tty)) {

+   while ((dev = device_find_child(>dev, NULL, __match_tty)) != 
NULL) {
  

Why do you need '!= NULL'?

--
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] Silent compiler warning introduced by acea6852f32b8805e166d885ed7e9f0c7cd10d41 ([BLUETOOTH]: Move children of connection device to NULL before connection down.)

2008-02-10 Thread Richard Knutsson

S.Çağlar Onur wrote:

Hi;

Following patch silents

net/bluetooth/hci_sysfs.c: In function `del_conn':
net/bluetooth/hci_sysfs.c:339: warning: suggest parentheses around assignment 
used as truth value

compiler warning introduced by commit acea6852f32b8805e166d885ed7e9f0c7cd10d41 
([BLUETOOTH]: Move children of connection device to NULL before connection 
down.)

Signed-off-by: S.Çağlar Onur [EMAIL PROTECTED]

 net/bluetooth/hci_sysfs.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index e13cf5e..d2d1e4f 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -336,7 +336,7 @@ static void del_conn(struct work_struct *work)
struct device *dev;
struct hci_conn *conn = container_of(work, struct hci_conn, work);
 
-	while (dev = device_find_child(conn-dev, NULL, __match_tty)) {

+   while ((dev = device_find_child(conn-dev, NULL, __match_tty)) != 
NULL) {
  

Why do you need '!= NULL'?

--
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: [JANITOR PROPOSAL] Switch ioctl functions to ->unlocked_ioctl

2008-01-09 Thread Richard Knutsson

Andre Noll wrote:

On 17:40, Andi Kleen wrote:
 
  

Here's a proposal for some useful code transformations the kernel janitors
could do as opposed to running checkpatch.pl.



Here's my take on drivers/scsi/sg.c. It's only compile-tested on x86-64.
  

... and x86 with all(yes|mod)config. :)

Would had preferred:

if (x) {
   result = -E;
   goto out;
}

then:

result = -E;
if (x)
   goto out;

but it looks correct.

cu,
Richard

--
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: [JANITOR PROPOSAL] Switch ioctl functions to -unlocked_ioctl

2008-01-09 Thread Richard Knutsson

Andre Noll wrote:

On 17:40, Andi Kleen wrote:
 
  

Here's a proposal for some useful code transformations the kernel janitors
could do as opposed to running checkpatch.pl.



Here's my take on drivers/scsi/sg.c. It's only compile-tested on x86-64.
  

... and x86 with all(yes|mod)config. :)

Would had preferred:

if (x) {
   result = -E;
   goto out;
}

then:

result = -E;
if (x)
   goto out;

but it looks correct.

cu,
Richard

--
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][SCSI] megaraid: Convert from "scsi.h" to (and friends)

2008-01-06 Thread Richard Knutsson
Convert glue-include "scsi.h" to  (and friends).

(binary sizes)
allyesconfig: before: 260132
  after:  260048

allmodconfig: before: 261740
  after:  261656

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Do not have the hardware, but since it compiles I hope it is alright.


diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 66c6520..9f1e2c5 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -48,8 +48,9 @@
 #include 
 #include 
 
-#include "scsi.h"
+#include 
 #include 
+#include 
 
 #include "megaraid.h"
 
@@ -1955,7 +1956,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd 
*cmd, int aor)
 cmd->device->id, cmd->device->lun);
 
if(list_empty(>pending_list))
-   return FALSE;
+   return false;
 
list_for_each_safe(pos, next, >pending_list) {
 
@@ -1978,7 +1979,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd 
*cmd, int aor)
(aor==SCB_ABORT) ? "ABORTING":"RESET",
cmd->serial_number, scb->idx);
 
-   return FALSE;
+   return false;
}
else {
 
@@ -2003,12 +2004,12 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd 
*cmd, int aor)
list_add_tail(SCSI_LIST(cmd),
>completed_list);
 
-   return TRUE;
+   return true;
}
}
}
 
-   return FALSE;
+   return false;
 }
 
 static inline int
--
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/


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 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 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][SCSI] megaraid: Convert from scsi.h to scsi.h (and friends)

2008-01-06 Thread Richard Knutsson
Convert glue-include scsi.h to scsi.h (and friends).

(binary sizes)
allyesconfig: before: 260132
  after:  260048

allmodconfig: before: 261740
  after:  261656

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Do not have the hardware, but since it compiles I hope it is alright.


diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 66c6520..9f1e2c5 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -48,8 +48,9 @@
 #include linux/dma-mapping.h
 #include scsi/scsicam.h
 
-#include scsi.h
+#include scsi/scsi_cmnd.h
 #include scsi/scsi_host.h
+#include scsi.h
 
 #include megaraid.h
 
@@ -1955,7 +1956,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd 
*cmd, int aor)
 cmd-device-id, cmd-device-lun);
 
if(list_empty(adapter-pending_list))
-   return FALSE;
+   return false;
 
list_for_each_safe(pos, next, adapter-pending_list) {
 
@@ -1978,7 +1979,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd 
*cmd, int aor)
(aor==SCB_ABORT) ? ABORTING:RESET,
cmd-serial_number, scb-idx);
 
-   return FALSE;
+   return false;
}
else {
 
@@ -2003,12 +2004,12 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd 
*cmd, int aor)
list_add_tail(SCSI_LIST(cmd),
adapter-completed_list);
 
-   return TRUE;
+   return true;
}
}
}
 
-   return FALSE;
+   return false;
 }
 
 static inline int
--
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] [Coding Style]: fs/ext{3,4}/ext{3,4}_jbd{,2}.c

2008-01-04 Thread Richard Knutsson

Mathieu Segaud wrote:

Misc style fixes from checkpatch.pl

Signed-off-by: Mathieu Segaud <[EMAIL PROTECTED]>
---
 fs/ext3/ext3_jbd.c  |   12 ++--
 fs/ext4/ext4_jbd2.c |   12 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/fs/ext3/ext3_jbd.c b/fs/ext3/ext3_jbd.c
index e1f91fd..6c96260 100644
--- a/fs/ext3/ext3_jbd.c
+++ b/fs/ext3/ext3_jbd.c
@@ -9,7 +9,7 @@ int __ext3_journal_get_undo_access(const char *where, handle_t 
*handle,
 {
int err = journal_get_undo_access(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -18,7 +18,7 @@ int __ext3_journal_get_write_access(const char *where, handle_t *handle,

 {
int err = journal_get_write_access(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -27,7 +27,7 @@ int __ext3_journal_forget(const char *where, handle_t *handle,

 {
int err = journal_forget(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -36,7 +36,7 @@ int __ext3_journal_revoke(const char *where, handle_t *handle,

 {
int err = journal_revoke(handle, blocknr, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -45,7 +45,7 @@ int __ext3_journal_get_create_access(const char *where,

 {
int err = journal_get_create_access(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -54,6 +54,6 @@ int __ext3_journal_dirty_metadata(const char *where,

 {
int err = journal_dirty_metadata(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index d6afe4e..2256c43 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -9,7 +9,7 @@ int __ext4_journal_get_undo_access(const char *where, handle_t 
*handle,
 {
int err = jbd2_journal_get_undo_access(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -18,7 +18,7 @@ int __ext4_journal_get_write_access(const char *where, handle_t *handle,

 {
int err = jbd2_journal_get_write_access(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -27,7 +27,7 @@ int __ext4_journal_forget(const char *where, handle_t *handle,

 {
int err = jbd2_journal_forget(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -36,7 +36,7 @@ int __ext4_journal_revoke(const char *where, handle_t *handle,

 {
int err = jbd2_journal_revoke(handle, blocknr, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -45,7 +45,7 @@ int __ext4_journal_get_create_access(const char *where,

 {
int err = jbd2_journal_get_create_access(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -54,6 +54,6 @@ int __ext4_journal_dirty_metadata(const char *where,

 {
int err = jbd2_journal_dirty_metadata(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
  

Hi Mathieu

What about changing the __FUNCTION__ to __func__, while you are at it?

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] [Coding Style]: fs/ext{3,4}/ext{3,4}_jbd{,2}.c

2008-01-04 Thread Richard Knutsson

Mathieu Segaud wrote:

Misc style fixes from checkpatch.pl

Signed-off-by: Mathieu Segaud [EMAIL PROTECTED]
---
 fs/ext3/ext3_jbd.c  |   12 ++--
 fs/ext4/ext4_jbd2.c |   12 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/fs/ext3/ext3_jbd.c b/fs/ext3/ext3_jbd.c
index e1f91fd..6c96260 100644
--- a/fs/ext3/ext3_jbd.c
+++ b/fs/ext3/ext3_jbd.c
@@ -9,7 +9,7 @@ int __ext3_journal_get_undo_access(const char *where, handle_t 
*handle,
 {
int err = journal_get_undo_access(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -18,7 +18,7 @@ int __ext3_journal_get_write_access(const char *where, handle_t *handle,

 {
int err = journal_get_write_access(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -27,7 +27,7 @@ int __ext3_journal_forget(const char *where, handle_t *handle,

 {
int err = journal_forget(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -36,7 +36,7 @@ int __ext3_journal_revoke(const char *where, handle_t *handle,

 {
int err = journal_revoke(handle, blocknr, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -45,7 +45,7 @@ int __ext3_journal_get_create_access(const char *where,

 {
int err = journal_get_create_access(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -54,6 +54,6 @@ int __ext3_journal_dirty_metadata(const char *where,

 {
int err = journal_dirty_metadata(handle, bh);
if (err)
-   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext3_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index d6afe4e..2256c43 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -9,7 +9,7 @@ int __ext4_journal_get_undo_access(const char *where, handle_t 
*handle,
 {
int err = jbd2_journal_get_undo_access(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -18,7 +18,7 @@ int __ext4_journal_get_write_access(const char *where, handle_t *handle,

 {
int err = jbd2_journal_get_write_access(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -27,7 +27,7 @@ int __ext4_journal_forget(const char *where, handle_t *handle,

 {
int err = jbd2_journal_forget(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -36,7 +36,7 @@ int __ext4_journal_revoke(const char *where, handle_t *handle,

 {
int err = jbd2_journal_revoke(handle, blocknr, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -45,7 +45,7 @@ int __ext4_journal_get_create_access(const char *where,

 {
int err = jbd2_journal_get_create_access(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
 
@@ -54,6 +54,6 @@ int __ext4_journal_dirty_metadata(const char *where,

 {
int err = jbd2_journal_dirty_metadata(handle, bh);
if (err)
-   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
+   ext4_journal_abort_handle(where, __FUNCTION__, bh, handle, err);
return err;
 }
  

Hi Mathieu

What about changing the __FUNCTION__ to __func__, while you are at it?

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/3] ipc: Convert handmade 'max' to max().

2008-01-03 Thread Richard Knutsson

Sorry for the late response, have been away during the holidays.

Andrew Morton wrote:

On Mon, 17 Dec 2007 03:35:55 +0100 (MET) Richard Knutsson <[EMAIL PROTECTED]> 
wrote:

  

Convert handmade 'max' to max().

...

--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -473,7 +473,7 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct 
msqid_ds __user *buf)
up_read(_ids(ns).rw_mutex);
if (copy_to_user(buf, , sizeof(struct msginfo)))
return -EFAULT;
-   return (max_id < 0) ? 0 : max_id;
+   return max(max_id, 0);



I don't think I like that much.

I tend to think of max() as being an arithmetic sort of thing: pick the
largest of two scalars.

But the code which you're changing is a _logical_ operation.  It says "if
ipc_get_maxid() returned an error, then return zero.  Otherwise return
whatever ipc_get_maxid() returned".

Yes, max() will do the right thing here, but I think it's a bit of weird
trick?


I mean, if ipc_get_maxid() were a better function, it would return a -ve
errno when something failed rather than the present dopey hard-coded -1. 
In which case the code would read 


return IS_ERR_VALUE(max_id) ? 0 : max_id;

in which case, converting it to max() would be even less appropriate.  If
you see what I mean...
  

Yes, have to agree. Were too quick with the changing...

Thanks
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/3] ipc: Convert handmade 'max' to max().

2008-01-03 Thread Richard Knutsson

Sorry for the late response, have been away during the holidays.

Andrew Morton wrote:

On Mon, 17 Dec 2007 03:35:55 +0100 (MET) Richard Knutsson [EMAIL PROTECTED] 
wrote:

  

Convert handmade 'max' to max().

...

--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -473,7 +473,7 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct 
msqid_ds __user *buf)
up_read(msg_ids(ns).rw_mutex);
if (copy_to_user(buf, msginfo, sizeof(struct msginfo)))
return -EFAULT;
-   return (max_id  0) ? 0 : max_id;
+   return max(max_id, 0);



I don't think I like that much.

I tend to think of max() as being an arithmetic sort of thing: pick the
largest of two scalars.

But the code which you're changing is a _logical_ operation.  It says if
ipc_get_maxid() returned an error, then return zero.  Otherwise return
whatever ipc_get_maxid() returned.

Yes, max() will do the right thing here, but I think it's a bit of weird
trick?


I mean, if ipc_get_maxid() were a better function, it would return a -ve
errno when something failed rather than the present dopey hard-coded -1. 
In which case the code would read 


return IS_ERR_VALUE(max_id) ? 0 : max_id;

in which case, converting it to max() would be even less appropriate.  If
you see what I mean...
  

Yes, have to agree. Were too quick with the changing...

Thanks
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 3/3] ipc: Convert handmade 'min' to min().

2007-12-16 Thread Richard Knutsson
Convert handmade 'min' to min().

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Dependent on 'msg->m_ts' being changed from int to size_t.


diff --git a/ipc/msg.c b/ipc/msg.c
index fdf3db5..74d0709 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -920,7 +920,7 @@ out_unlock:
if (IS_ERR(msg))
return PTR_ERR(msg);
 
-   msgsz = (msgsz > msg->m_ts) ? msg->m_ts : msgsz;
+   msgsz = min(msgsz, msg->m_ts);
*pmtype = msg->m_type;
if (store_msg(mtext, msg, msgsz))
msgsz = -EFAULT;
--
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/3] ipc: Convert handmade 'max' to max().

2007-12-16 Thread Richard Knutsson
Convert handmade 'max' to max().

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---

 msg.c |2 +-
 sem.c |2 +-
 shm.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/ipc/msg.c b/ipc/msg.c
index fdf3db5..74d0709 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -473,7 +473,7 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct 
msqid_ds __user *buf)
up_read(_ids(ns).rw_mutex);
if (copy_to_user(buf, , sizeof(struct msginfo)))
return -EFAULT;
-   return (max_id < 0) ? 0 : max_id;
+   return max(max_id, 0);
}
case MSG_STAT:  /* msqid is an index rather than a msg queue id */
case IPC_STAT:
diff --git a/ipc/sem.c b/ipc/sem.c
index 35952c0..9ac00ac 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -641,7 +641,7 @@ static int semctl_nolock(struct ipc_namespace *ns, int 
semid, int semnum,
up_read(_ids(ns).rw_mutex);
if (copy_to_user (arg.__buf, , sizeof(struct seminfo))) 
return -EFAULT;
-   return (max_id < 0) ? 0: max_id;
+   return max(max_id, 0);
}
case SEM_STAT:
{
diff --git a/ipc/shm.c b/ipc/shm.c
index 3818fae..45e154a 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -704,7 +704,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct 
shmid_ds __user *buf)
goto out;
}
 
-   err = err < 0 ? 0 : err;
+   err = max(err, 0);
goto out;
}
case SHM_STAT:
--
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 2/3] msg.h: Convert m_ts from int to size_t.

2007-12-16 Thread Richard Knutsson
Convert m_ts ("message text size") from int to size_t.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Remove some trailing spaces, since we are in the neighborhood.


diff --git a/include/linux/msg.h b/include/linux/msg.h
index 10a3d5a..7a61952 100644
--- a/include/linux/msg.h
+++ b/include/linux/msg.h
@@ -67,8 +67,8 @@ struct msginfo {
 /* one msg_msg structure for each message */
 struct msg_msg {
struct list_head m_list; 
-   long  m_type;  
-   int m_ts;   /* message text size */
+   long  m_type;
+   size_t m_ts;   /* message text size */
struct msg_msgseg* next;
void *security;
/* the actual message follows immediately */
--
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/3] ipc: Convert handmade 'max' to max().

2007-12-16 Thread Richard Knutsson
Convert handmade 'max' to max().

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---

 msg.c |2 +-
 sem.c |2 +-
 shm.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/ipc/msg.c b/ipc/msg.c
index fdf3db5..74d0709 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -473,7 +473,7 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct 
msqid_ds __user *buf)
up_read(msg_ids(ns).rw_mutex);
if (copy_to_user(buf, msginfo, sizeof(struct msginfo)))
return -EFAULT;
-   return (max_id  0) ? 0 : max_id;
+   return max(max_id, 0);
}
case MSG_STAT:  /* msqid is an index rather than a msg queue id */
case IPC_STAT:
diff --git a/ipc/sem.c b/ipc/sem.c
index 35952c0..9ac00ac 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -641,7 +641,7 @@ static int semctl_nolock(struct ipc_namespace *ns, int 
semid, int semnum,
up_read(sem_ids(ns).rw_mutex);
if (copy_to_user (arg.__buf, seminfo, sizeof(struct seminfo))) 
return -EFAULT;
-   return (max_id  0) ? 0: max_id;
+   return max(max_id, 0);
}
case SEM_STAT:
{
diff --git a/ipc/shm.c b/ipc/shm.c
index 3818fae..45e154a 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -704,7 +704,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct 
shmid_ds __user *buf)
goto out;
}
 
-   err = err  0 ? 0 : err;
+   err = max(err, 0);
goto out;
}
case SHM_STAT:
--
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 2/3] msg.h: Convert m_ts from int to size_t.

2007-12-16 Thread Richard Knutsson
Convert m_ts (message text size) from int to size_t.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Remove some trailing spaces, since we are in the neighborhood.


diff --git a/include/linux/msg.h b/include/linux/msg.h
index 10a3d5a..7a61952 100644
--- a/include/linux/msg.h
+++ b/include/linux/msg.h
@@ -67,8 +67,8 @@ struct msginfo {
 /* one msg_msg structure for each message */
 struct msg_msg {
struct list_head m_list; 
-   long  m_type;  
-   int m_ts;   /* message text size */
+   long  m_type;
+   size_t m_ts;   /* message text size */
struct msg_msgseg* next;
void *security;
/* the actual message follows immediately */
--
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 3/3] ipc: Convert handmade 'min' to min().

2007-12-16 Thread Richard Knutsson
Convert handmade 'min' to min().

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Dependent on 'msg-m_ts' being changed from int to size_t.


diff --git a/ipc/msg.c b/ipc/msg.c
index fdf3db5..74d0709 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -920,7 +920,7 @@ out_unlock:
if (IS_ERR(msg))
return PTR_ERR(msg);
 
-   msgsz = (msgsz  msg-m_ts) ? msg-m_ts : msgsz;
+   msgsz = min(msgsz, msg-m_ts);
*pmtype = msg-m_type;
if (store_msg(mtext, msg, msgsz))
msgsz = -EFAULT;
--
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/6] pcmcia/3c574_cs: Fix dubious bitfield warning

2007-12-11 Thread Richard Knutsson

Alan Cox wrote:

On Tue, 11 Dec 2007 05:32:38 +0100 (MET)
Richard Knutsson <[EMAIL PROTECTED]> wrote:

  

Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without 
explicit `signed' or `unsigned'
drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without 
explicit `signed' or `unsigned'

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Is there a reason for not doing it this way?



How is the endianness handled here (I suspect its always been broken)
  
Guess so, but it should not handle the endians differently with such a 
change, does it?
  

diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..97b6daa 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -190,10 +190,10 @@ enum Window3 {/* Window 3: MAC/config 
bits. */
 union wn3_config {
int i;
struct w3_config_fields {
-   unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
-   int pad8:8;
-   unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, 
autoselect:1;
-   int pad24:7;
+   u8 ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
+   u8 pad8;
+   u8 ram_split:2, pad18:2, xcvr:3, pad21:1;
+   u8 autoselect:1, pad24:7;



Just changing the int pad to unsigned int pad would be safer in terms of
not causing changes. Simply delcaring a 32bit field and bit masks to
and/or into it is probably a lot saner in the general case.
  
Thought about it before and with the endian-issue it seem like a better 
solution.

So, something like this?

Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without explicit `signed' or `unsigned'
drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without explicit `signed' or `unsigned'

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Moved 'autoselect' to the last line to make every line 8 bits.
Is there a reason for not doing it this way?


diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..e549427 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -190,10 +190,10 @@ enum Window3 {			/* Window 3: MAC/config bits. */
 union wn3_config {
 	int i;
 	struct w3_config_fields {
-		unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
-		int pad8:8;
-		unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, autoselect:1;
-		int pad24:7;
+		u32 ram_size:3, ram_width:1, ram_speed:2, rom_size:2,
+		pad8:8,
+		ram_split:2, pad18:2, xcvr:3, pad21:1,
+		autoselect:1, pad24:7;
 	} u;
 };
 


Re: [PATCH 1/6] pcmcia/3c574_cs: Fix dubious bitfield warning

2007-12-11 Thread Richard Knutsson

Alan Cox wrote:

On Tue, 11 Dec 2007 05:32:38 +0100 (MET)
Richard Knutsson [EMAIL PROTECTED] wrote:

  

Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without 
explicit `signed' or `unsigned'
drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without 
explicit `signed' or `unsigned'

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Is there a reason for not doing it this way?



How is the endianness handled here (I suspect its always been broken)
  
Guess so, but it should not handle the endians differently with such a 
change, does it?
  

diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..97b6daa 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -190,10 +190,10 @@ enum Window3 {/* Window 3: MAC/config 
bits. */
 union wn3_config {
int i;
struct w3_config_fields {
-   unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
-   int pad8:8;
-   unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, 
autoselect:1;
-   int pad24:7;
+   u8 ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
+   u8 pad8;
+   u8 ram_split:2, pad18:2, xcvr:3, pad21:1;
+   u8 autoselect:1, pad24:7;



Just changing the int pad to unsigned int pad would be safer in terms of
not causing changes. Simply delcaring a 32bit field and bit masks to
and/or into it is probably a lot saner in the general case.
  
Thought about it before and with the endian-issue it seem like a better 
solution.

So, something like this?

Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without explicit `signed' or `unsigned'
drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without explicit `signed' or `unsigned'

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Moved 'autoselect' to the last line to make every line 8 bits.
Is there a reason for not doing it this way?


diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..e549427 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -190,10 +190,10 @@ enum Window3 {			/* Window 3: MAC/config bits. */
 union wn3_config {
 	int i;
 	struct w3_config_fields {
-		unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
-		int pad8:8;
-		unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, autoselect:1;
-		int pad24:7;
+		u32 ram_size:3, ram_width:1, ram_speed:2, rom_size:2,
+		pad8:8,
+		ram_split:2, pad18:2, xcvr:3, pad21:1,
+		autoselect:1, pad24:7;
 	} u;
 };
 


[PATCH 6/6] pcmcia/pcnet_cs: Fix 'shadow variable' warning

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/pcnet_cs.c
drivers/net/pcmcia/pcnet_cs.c:523:15: warning: symbol 'hw_info' shadows an 
earlier one
drivers/net/pcmcia/pcnet_cs.c:148:18: originally declared here

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---


diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index db6a97d..5779344 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -520,7 +520,7 @@ static int pcnet_config(struct pcmcia_device *link)
 int i, last_ret, last_fn, start_pg, stop_pg, cm_offset;
 int has_shmem = 0;
 u_short buf[64];
-hw_info_t *hw_info;
+hw_info_t *local_hw_info;
 DECLARE_MAC_BUF(mac);
 
 DEBUG(0, "pcnet_config(0x%p)\n", link);
@@ -589,23 +589,23 @@ static int pcnet_config(struct pcmcia_device *link)
dev->if_port = 0;
 }
 
-hw_info = get_hwinfo(link);
-if (hw_info == NULL)
-   hw_info = get_prom(link);
-if (hw_info == NULL)
-   hw_info = get_dl10019(link);
-if (hw_info == NULL)
-   hw_info = get_ax88190(link);
-if (hw_info == NULL)
-   hw_info = get_hwired(link);
-
-if (hw_info == NULL) {
+local_hw_info = get_hwinfo(link);
+if (local_hw_info == NULL)
+   local_hw_info = get_prom(link);
+if (local_hw_info == NULL)
+   local_hw_info = get_dl10019(link);
+if (local_hw_info == NULL)
+   local_hw_info = get_ax88190(link);
+if (local_hw_info == NULL)
+   local_hw_info = get_hwired(link);
+
+if (local_hw_info == NULL) {
printk(KERN_NOTICE "pcnet_cs: unable to read hardware net"
   " address for io base %#3lx\n", dev->base_addr);
goto failed;
 }
 
-info->flags = hw_info->flags;
+info->flags = local_hw_info->flags;
 /* Check for user overrides */
 info->flags |= (delay_output) ? DELAY_OUTPUT : 0;
 if ((link->manf_id == MANFID_SOCKET) &&
--
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 4/6] pcmcia/axnet_cs: Make use of 'max()' instead of handcrafted one

2007-12-10 Thread Richard Knutsson
Use 'max(x,y)' instead of 'x < y ? y : x'.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---


diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 8d910a3..96931cc 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -1091,8 +1091,8 @@ static int ei_start_xmit(struct sk_buff *skb, struct 
net_device *dev)

ei_local->irqlock = 1;
 
-   send_length = ETH_ZLEN < length ? length : ETH_ZLEN;
-   
+   send_length = max(length, ETH_ZLEN);
+
/*
 * We have two Tx slots available for use. Find the first free
 * slot, and then perform some sanity checks. With two Tx bufs,
--
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 5/6] pcmcia/fmvj18x_cs: Fix 'shadow variable' warning

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/fmvj18x_cs.c
drivers/net/pcmcia/fmvj18x_cs.c:1205:6: warning: symbol 'i' shadows an earlier 
one
drivers/net/pcmcia/fmvj18x_cs.c:1179:9: originally declared here

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---


diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 8c719b4..4f604ae 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -1202,8 +1202,7 @@ static void set_rx_mode(struct net_device *dev)
outb(1, ioaddr + RX_MODE);  /* Ignore almost all multicasts. */
 } else {
struct dev_mc_list *mclist;
-   int i;
-   
+
memset(mc_filter, 0, sizeof(mc_filter));
for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
 i++, mclist = mclist->next) {
--
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 2/6] pcmcia/3c574_cs: Fix 'shadow variable' warning

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:695:7: warning: symbol 'i' shadows an earlier one
drivers/net/pcmcia/3c574_cs.c:636:6: originally declared here

Signed-off-by: Richard Knutson <[EMAIL PROTECTED]>
---


diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..97b6daa 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -692,7 +692,7 @@ static void tc574_reset(struct net_device *dev)
mdio_write(ioaddr, lp->phys, 4, lp->advertising);
if (!auto_polarity) {
/* works for TDK 78Q2120 series MII's */
-   int i = mdio_read(ioaddr, lp->phys, 16) | 0x20;
+   i = mdio_read(ioaddr, lp->phys, 16) | 0x20;
mdio_write(ioaddr, lp->phys, 16, i);
}
 
--
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/6] pcmcia/3c574_cs: Fix dubious bitfield warning

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without 
explicit `signed' or `unsigned'
drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without 
explicit `signed' or `unsigned'

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Is there a reason for not doing it this way?


diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..97b6daa 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -190,10 +190,10 @@ enum Window3 {/* Window 3: MAC/config 
bits. */
 union wn3_config {
int i;
struct w3_config_fields {
-   unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
-   int pad8:8;
-   unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, 
autoselect:1;
-   int pad24:7;
+   u8 ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
+   u8 pad8;
+   u8 ram_split:2, pad18:2, xcvr:3, pad21:1;
+   u8 autoselect:1, pad24:7;
} u;
 };
 
--
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 3/6] pcmcia/axnet_cs: Make functions static

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/axnet_cs.c
drivers/net/pcmcia/axnet_cs.c:994:5: warning: symbol 'ax_close' was not 
declared. Should it be static?
drivers/net/pcmcia/axnet_cs.c:1017:6: warning: symbol 'ei_tx_timeout' was not 
declared. Should it be static?

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---


diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 8d910a3..96931cc 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -991,7 +991,7 @@ static int ax_open(struct net_device *dev)
  *
  * Opposite of ax_open(). Only used when "ifconfig  down" is done.
  */
-int ax_close(struct net_device *dev)
+static int ax_close(struct net_device *dev)
 {
unsigned long flags;
 
@@ -1014,7 +1014,7 @@ int ax_close(struct net_device *dev)
  * completed (or failed) - i.e. never posted a Tx related interrupt.
  */
 
-void ei_tx_timeout(struct net_device *dev)
+static void ei_tx_timeout(struct net_device *dev)
 {
long e8390_base = dev->base_addr;
struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
--
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] drivers/net/ipg: Remove local definition of TRUE/FALSE

2007-12-10 Thread Richard Knutsson

Pekka Enberg wrote:

Hi Richard,

On Dec 10, 2007 9:29 PM, Richard Knutsson <[EMAIL PROTECTED]> wrote:
  

Remove local definition of TRUE/FALSE.



This is already fixed in Francois' tree:

http://git.kernel.org/?p=linux/kernel/git/romieu/netdev-2.6.git;a=commitdiff;h=2af61e99e3d1c959840ea007ff56b15db794fb99
  

I see, thanks.

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] drivers/net/ipg: Remove local definition of TRUE/FALSE

2007-12-10 Thread Richard Knutsson
Remove local definition of TRUE/FALSE.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---


diff --git a/drivers/net/ipg.h b/drivers/net/ipg.h
index d5d092c..4484778 100644
--- a/drivers/net/ipg.h
+++ b/drivers/net/ipg.h
@@ -490,38 +490,34 @@ enum ipg_regs {
  * Tune
  */
 
-/* Miscellaneous Constants. */
-#define   TRUE  1
-#define   FALSE 0
-
 /* Assign IPG_APPEND_FCS_ON_TX > 0 for auto FCS append on TX. */
-#define IPG_APPEND_FCS_ON_TX TRUE
+#define IPG_APPEND_FCS_ON_TX true
 
 /* Assign IPG_APPEND_FCS_ON_TX > 0 for auto FCS strip on RX. */
-#define IPG_STRIP_FCS_ON_RX  TRUE
+#define IPG_STRIP_FCS_ON_RX  true
 
 /* Assign IPG_DROP_ON_RX_ETH_ERRORS > 0 to drop RX frames with
  * Ethernet errors.
  */
-#define IPG_DROP_ON_RX_ETH_ERRORSTRUE
+#define IPG_DROP_ON_RX_ETH_ERRORStrue
 
 /* Assign IPG_INSERT_MANUAL_VLAN_TAG > 0 to insert VLAN tags manually
  * (via TFC).
  */
-#defineIPG_INSERT_MANUAL_VLAN_TAG   FALSE
+#defineIPG_INSERT_MANUAL_VLAN_TAG   false
 
 /* Assign IPG_ADD_IPCHECKSUM_ON_TX > 0 for auto IP checksum on TX. */
-#define IPG_ADD_IPCHECKSUM_ON_TX FALSE
+#define IPG_ADD_IPCHECKSUM_ON_TX false
 
 /* Assign IPG_ADD_TCPCHECKSUM_ON_TX > 0 for auto TCP checksum on TX.
  * DO NOT USE FOR SILICON REVISIONS B3 AND EARLIER.
  */
-#define IPG_ADD_TCPCHECKSUM_ON_TXFALSE
+#define IPG_ADD_TCPCHECKSUM_ON_TXfalse
 
 /* Assign IPG_ADD_UDPCHECKSUM_ON_TX > 0 for auto UDP checksum on TX.
  * DO NOT USE FOR SILICON REVISIONS B3 AND EARLIER.
  */
-#define IPG_ADD_UDPCHECKSUM_ON_TXFALSE
+#define IPG_ADD_UDPCHECKSUM_ON_TXfalse
 
 /* If inserting VLAN tags manually, assign the IPG_MANUAL_VLAN_xx
  * constants as desired.
--
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] drivers/net/ipg: Remove local definition of TRUE/FALSE

2007-12-10 Thread Richard Knutsson
Remove local definition of TRUE/FALSE.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---


diff --git a/drivers/net/ipg.h b/drivers/net/ipg.h
index d5d092c..4484778 100644
--- a/drivers/net/ipg.h
+++ b/drivers/net/ipg.h
@@ -490,38 +490,34 @@ enum ipg_regs {
  * Tune
  */
 
-/* Miscellaneous Constants. */
-#define   TRUE  1
-#define   FALSE 0
-
 /* Assign IPG_APPEND_FCS_ON_TX  0 for auto FCS append on TX. */
-#define IPG_APPEND_FCS_ON_TX TRUE
+#define IPG_APPEND_FCS_ON_TX true
 
 /* Assign IPG_APPEND_FCS_ON_TX  0 for auto FCS strip on RX. */
-#define IPG_STRIP_FCS_ON_RX  TRUE
+#define IPG_STRIP_FCS_ON_RX  true
 
 /* Assign IPG_DROP_ON_RX_ETH_ERRORS  0 to drop RX frames with
  * Ethernet errors.
  */
-#define IPG_DROP_ON_RX_ETH_ERRORSTRUE
+#define IPG_DROP_ON_RX_ETH_ERRORStrue
 
 /* Assign IPG_INSERT_MANUAL_VLAN_TAG  0 to insert VLAN tags manually
  * (via TFC).
  */
-#defineIPG_INSERT_MANUAL_VLAN_TAG   FALSE
+#defineIPG_INSERT_MANUAL_VLAN_TAG   false
 
 /* Assign IPG_ADD_IPCHECKSUM_ON_TX  0 for auto IP checksum on TX. */
-#define IPG_ADD_IPCHECKSUM_ON_TX FALSE
+#define IPG_ADD_IPCHECKSUM_ON_TX false
 
 /* Assign IPG_ADD_TCPCHECKSUM_ON_TX  0 for auto TCP checksum on TX.
  * DO NOT USE FOR SILICON REVISIONS B3 AND EARLIER.
  */
-#define IPG_ADD_TCPCHECKSUM_ON_TXFALSE
+#define IPG_ADD_TCPCHECKSUM_ON_TXfalse
 
 /* Assign IPG_ADD_UDPCHECKSUM_ON_TX  0 for auto UDP checksum on TX.
  * DO NOT USE FOR SILICON REVISIONS B3 AND EARLIER.
  */
-#define IPG_ADD_UDPCHECKSUM_ON_TXFALSE
+#define IPG_ADD_UDPCHECKSUM_ON_TXfalse
 
 /* If inserting VLAN tags manually, assign the IPG_MANUAL_VLAN_xx
  * constants as desired.
--
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] drivers/net/ipg: Remove local definition of TRUE/FALSE

2007-12-10 Thread Richard Knutsson

Pekka Enberg wrote:

Hi Richard,

On Dec 10, 2007 9:29 PM, Richard Knutsson [EMAIL PROTECTED] wrote:
  

Remove local definition of TRUE/FALSE.



This is already fixed in Francois' tree:

http://git.kernel.org/?p=linux/kernel/git/romieu/netdev-2.6.git;a=commitdiff;h=2af61e99e3d1c959840ea007ff56b15db794fb99
  

I see, thanks.

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 2/6] pcmcia/3c574_cs: Fix 'shadow variable' warning

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:695:7: warning: symbol 'i' shadows an earlier one
drivers/net/pcmcia/3c574_cs.c:636:6: originally declared here

Signed-off-by: Richard Knutson [EMAIL PROTECTED]
---


diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..97b6daa 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -692,7 +692,7 @@ static void tc574_reset(struct net_device *dev)
mdio_write(ioaddr, lp-phys, 4, lp-advertising);
if (!auto_polarity) {
/* works for TDK 78Q2120 series MII's */
-   int i = mdio_read(ioaddr, lp-phys, 16) | 0x20;
+   i = mdio_read(ioaddr, lp-phys, 16) | 0x20;
mdio_write(ioaddr, lp-phys, 16, i);
}
 
--
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/6] pcmcia/3c574_cs: Fix dubious bitfield warning

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c574_cs.c:194:13: warning: dubious bitfield without 
explicit `signed' or `unsigned'
drivers/net/pcmcia/3c574_cs.c:196:14: warning: dubious bitfield without 
explicit `signed' or `unsigned'

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Is there a reason for not doing it this way?


diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index ad134a6..97b6daa 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -190,10 +190,10 @@ enum Window3 {/* Window 3: MAC/config 
bits. */
 union wn3_config {
int i;
struct w3_config_fields {
-   unsigned int ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
-   int pad8:8;
-   unsigned int ram_split:2, pad18:2, xcvr:3, pad21:1, 
autoselect:1;
-   int pad24:7;
+   u8 ram_size:3, ram_width:1, ram_speed:2, rom_size:2;
+   u8 pad8;
+   u8 ram_split:2, pad18:2, xcvr:3, pad21:1;
+   u8 autoselect:1, pad24:7;
} u;
 };
 
--
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 3/6] pcmcia/axnet_cs: Make functions static

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/axnet_cs.c
drivers/net/pcmcia/axnet_cs.c:994:5: warning: symbol 'ax_close' was not 
declared. Should it be static?
drivers/net/pcmcia/axnet_cs.c:1017:6: warning: symbol 'ei_tx_timeout' was not 
declared. Should it be static?

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---


diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 8d910a3..96931cc 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -991,7 +991,7 @@ static int ax_open(struct net_device *dev)
  *
  * Opposite of ax_open(). Only used when ifconfig devname down is done.
  */
-int ax_close(struct net_device *dev)
+static int ax_close(struct net_device *dev)
 {
unsigned long flags;
 
@@ -1014,7 +1014,7 @@ int ax_close(struct net_device *dev)
  * completed (or failed) - i.e. never posted a Tx related interrupt.
  */
 
-void ei_tx_timeout(struct net_device *dev)
+static void ei_tx_timeout(struct net_device *dev)
 {
long e8390_base = dev-base_addr;
struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
--
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 4/6] pcmcia/axnet_cs: Make use of 'max()' instead of handcrafted one

2007-12-10 Thread Richard Knutsson
Use 'max(x,y)' instead of 'x  y ? y : x'.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---


diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 8d910a3..96931cc 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -1091,8 +1091,8 @@ static int ei_start_xmit(struct sk_buff *skb, struct 
net_device *dev)

ei_local-irqlock = 1;
 
-   send_length = ETH_ZLEN  length ? length : ETH_ZLEN;
-   
+   send_length = max(length, ETH_ZLEN);
+
/*
 * We have two Tx slots available for use. Find the first free
 * slot, and then perform some sanity checks. With two Tx bufs,
--
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 5/6] pcmcia/fmvj18x_cs: Fix 'shadow variable' warning

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/fmvj18x_cs.c
drivers/net/pcmcia/fmvj18x_cs.c:1205:6: warning: symbol 'i' shadows an earlier 
one
drivers/net/pcmcia/fmvj18x_cs.c:1179:9: originally declared here

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---


diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 8c719b4..4f604ae 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -1202,8 +1202,7 @@ static void set_rx_mode(struct net_device *dev)
outb(1, ioaddr + RX_MODE);  /* Ignore almost all multicasts. */
 } else {
struct dev_mc_list *mclist;
-   int i;
-   
+
memset(mc_filter, 0, sizeof(mc_filter));
for (i = 0, mclist = dev-mc_list; mclist  i  dev-mc_count;
 i++, mclist = mclist-next) {
--
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 6/6] pcmcia/pcnet_cs: Fix 'shadow variable' warning

2007-12-10 Thread Richard Knutsson
Fixing:
  CHECK   drivers/net/pcmcia/pcnet_cs.c
drivers/net/pcmcia/pcnet_cs.c:523:15: warning: symbol 'hw_info' shadows an 
earlier one
drivers/net/pcmcia/pcnet_cs.c:148:18: originally declared here

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---


diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index db6a97d..5779344 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -520,7 +520,7 @@ static int pcnet_config(struct pcmcia_device *link)
 int i, last_ret, last_fn, start_pg, stop_pg, cm_offset;
 int has_shmem = 0;
 u_short buf[64];
-hw_info_t *hw_info;
+hw_info_t *local_hw_info;
 DECLARE_MAC_BUF(mac);
 
 DEBUG(0, pcnet_config(0x%p)\n, link);
@@ -589,23 +589,23 @@ static int pcnet_config(struct pcmcia_device *link)
dev-if_port = 0;
 }
 
-hw_info = get_hwinfo(link);
-if (hw_info == NULL)
-   hw_info = get_prom(link);
-if (hw_info == NULL)
-   hw_info = get_dl10019(link);
-if (hw_info == NULL)
-   hw_info = get_ax88190(link);
-if (hw_info == NULL)
-   hw_info = get_hwired(link);
-
-if (hw_info == NULL) {
+local_hw_info = get_hwinfo(link);
+if (local_hw_info == NULL)
+   local_hw_info = get_prom(link);
+if (local_hw_info == NULL)
+   local_hw_info = get_dl10019(link);
+if (local_hw_info == NULL)
+   local_hw_info = get_ax88190(link);
+if (local_hw_info == NULL)
+   local_hw_info = get_hwired(link);
+
+if (local_hw_info == NULL) {
printk(KERN_NOTICE pcnet_cs: unable to read hardware net
address for io base %#3lx\n, dev-base_addr);
goto failed;
 }
 
-info-flags = hw_info-flags;
+info-flags = local_hw_info-flags;
 /* Check for user overrides */
 info-flags |= (delay_output) ? DELAY_OUTPUT : 0;
 if ((link-manf_id == MANFID_SOCKET) 
--
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] ivtv: Some general fixes

2007-12-08 Thread Richard Knutsson
Fix "warning: Using plain integer as NULL pointer".
Convert 'x < y ? x : y' to use min() instead.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
Signed-off-by: Hans Verkuil <[EMAIL PROTECTED]>
---
Compile-tested on i386 with "allyesconfig" and "allmodconfig".
Resend, since the 'Remove a gcc-2.95 requirement'-part is taken away.
Was sent 2007-12-04

 ivtv-driver.c  |2 +-
 ivtv-ioctl.c   |2 +-
 ivtv-irq.c |4 ++--
 ivtv-streams.c |4 ++--
 ivtvfb.c   |2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)


diff --git a/drivers/media/video/ivtv/ivtv-driver.c 
b/drivers/media/video/ivtv/ivtv-driver.c
index 6d2dd87..96f340c 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -979,7 +979,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
}
 
itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC);
-   if (itv == 0) {
+   if (itv == NULL) {
spin_unlock(_cards_lock);
return -ENOMEM;
}
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index fd6826f..24270de 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -688,7 +688,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned 
int cmd, void *arg)
ivtv_reset_ir_gpio(itv);
}
if (val & 0x02) {
-   itv->video_dec_func(itv, cmd, 0);
+   itv->video_dec_func(itv, cmd, NULL);
}
break;
}
diff --git a/drivers/media/video/ivtv/ivtv-irq.c 
b/drivers/media/video/ivtv/ivtv-irq.c
index fd1688e..1384615 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -204,7 +204,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 
data[CX2341X_MBOX_MA
s->sg_pending[idx].dst = buf->dma_handle;
s->sg_pending[idx].src = offset;
s->sg_pending[idx].size = s->buf_size;
-   buf->bytesused = (size < s->buf_size) ? size : s->buf_size;
+   buf->bytesused = min(size, s->buf_size);
buf->dma_xfer_cnt = s->dma_xfer_cnt;
 
s->q_predma.bytesused += buf->bytesused;
@@ -705,7 +705,7 @@ static void ivtv_irq_dec_data_req(struct ivtv *itv)
s = >streams[IVTV_DEC_STREAM_TYPE_YUV];
}
else {
-   itv->dma_data_req_size = data[2] >= 0x1 ? 0x1 : data[2];
+   itv->dma_data_req_size = min_t(u32, data[2], 0x1);
itv->dma_data_req_offset = data[1];
s = >streams[IVTV_DEC_STREAM_TYPE_MPG];
}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c 
b/drivers/media/video/ivtv/ivtv-streams.c
index aa03e61..0e9e7d0 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -572,10 +572,10 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
clear_bit(IVTV_F_I_EOS, >i_flags);
 
/* Initialize Digitizer for Capture */
-   itv->video_dec_func(itv, VIDIOC_STREAMOFF, 0);
+   itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
ivtv_msleep_timeout(300, 1);
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
-   itv->video_dec_func(itv, VIDIOC_STREAMON, 0);
+   itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
}
 
/* begin_capture */
diff --git a/drivers/media/video/ivtv/ivtvfb.c 
b/drivers/media/video/ivtv/ivtvfb.c
index 52ffd15..f73ce98 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -1053,7 +1053,7 @@ static int ivtvfb_init_card(struct ivtv *itv)
}
 
itv->osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC);
-   if (itv->osd_info == 0) {
+   if (itv->osd_info == NULL) {
IVTVFB_ERR("Failed to allocate memory for osd_info\n");
return -ENOMEM;
}
--
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] kernel/params.c: Remove sparse-warning (different signedness).

2007-12-08 Thread Richard Knutsson
Fixing:
  CHECK   kernel/params.c
kernel/params.c:329:41: warning: incorrect type in argument 8 (different 
signedness)
kernel/params.c:329:41:expected int *num
kernel/params.c:329:41:got unsigned int *

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on x86 with all[yes|mod|no]config.
Since 'num' is initialized to '0', then only increments, it can/should be 
unsigned.


diff --git a/kernel/params.c b/kernel/params.c
index 2a4c514..de1d0c4 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -272,7 +272,7 @@ static int param_array(const char *name,
   unsigned int min, unsigned int max,
   void *elem, int elemsize,
   int (*set)(const char *, struct kernel_param *kp),
-  int *num)
+  unsigned int *num)
 {
int ret;
struct kernel_param kp;
--
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] mm/mmap: Remove sparse-warning (NULL as 0).

2007-12-08 Thread Richard Knutsson
Fixing:
  CHECK   mm/mmap.c
mm/mmap.c:1623:29: warning: Using plain integer as NULL pointer
mm/mmap.c:1623:29: warning: Using plain integer as NULL pointer
mm/mmap.c:1944:29: warning: Using plain integer as NULL pointer

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Added by: 8869477a49c3e99def1fcdadd6bbc407fea14b45 (Linus' tree)
Compile-tested on i386 with all[yes|mod|no]config.


diff --git a/mm/mmap.c b/mm/mmap.c
index 15678aa..bfa389f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1620,7 +1620,7 @@ static inline int expand_downwards(struct vm_area_struct 
*vma,
return -ENOMEM;
 
address &= PAGE_MASK;
-   error = security_file_mmap(0, 0, 0, 0, address, 1);
+   error = security_file_mmap(NULL, 0, 0, 0, address, 1);
if (error)
return error;
 
@@ -1941,7 +1941,7 @@ unsigned long do_brk(unsigned long addr, unsigned long 
len)
if (is_hugepage_only_range(mm, addr, len))
return -EINVAL;
 
-   error = security_file_mmap(0, 0, 0, 0, addr, 1);
+   error = security_file_mmap(NULL, 0, 0, 0, addr, 1);
if (error)
return error;
 
--
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] mm/mmap: Remove sparse-warning (NULL as 0).

2007-12-08 Thread Richard Knutsson
Fixing:
  CHECK   mm/mmap.c
mm/mmap.c:1623:29: warning: Using plain integer as NULL pointer
mm/mmap.c:1623:29: warning: Using plain integer as NULL pointer
mm/mmap.c:1944:29: warning: Using plain integer as NULL pointer

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Added by: 8869477a49c3e99def1fcdadd6bbc407fea14b45 (Linus' tree)
Compile-tested on i386 with all[yes|mod|no]config.


diff --git a/mm/mmap.c b/mm/mmap.c
index 15678aa..bfa389f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1620,7 +1620,7 @@ static inline int expand_downwards(struct vm_area_struct 
*vma,
return -ENOMEM;
 
address = PAGE_MASK;
-   error = security_file_mmap(0, 0, 0, 0, address, 1);
+   error = security_file_mmap(NULL, 0, 0, 0, address, 1);
if (error)
return error;
 
@@ -1941,7 +1941,7 @@ unsigned long do_brk(unsigned long addr, unsigned long 
len)
if (is_hugepage_only_range(mm, addr, len))
return -EINVAL;
 
-   error = security_file_mmap(0, 0, 0, 0, addr, 1);
+   error = security_file_mmap(NULL, 0, 0, 0, addr, 1);
if (error)
return error;
 
--
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] kernel/params.c: Remove sparse-warning (different signedness).

2007-12-08 Thread Richard Knutsson
Fixing:
  CHECK   kernel/params.c
kernel/params.c:329:41: warning: incorrect type in argument 8 (different 
signedness)
kernel/params.c:329:41:expected int *num
kernel/params.c:329:41:got unsigned int *

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on x86 with all[yes|mod|no]config.
Since 'num' is initialized to '0', then only increments, it can/should be 
unsigned.


diff --git a/kernel/params.c b/kernel/params.c
index 2a4c514..de1d0c4 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -272,7 +272,7 @@ static int param_array(const char *name,
   unsigned int min, unsigned int max,
   void *elem, int elemsize,
   int (*set)(const char *, struct kernel_param *kp),
-  int *num)
+  unsigned int *num)
 {
int ret;
struct kernel_param kp;
--
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] ivtv: Some general fixes

2007-12-08 Thread Richard Knutsson
Fix warning: Using plain integer as NULL pointer.
Convert 'x  y ? x : y' to use min() instead.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
Signed-off-by: Hans Verkuil [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig and allmodconfig.
Resend, since the 'Remove a gcc-2.95 requirement'-part is taken away.
Was sent 2007-12-04

 ivtv-driver.c  |2 +-
 ivtv-ioctl.c   |2 +-
 ivtv-irq.c |4 ++--
 ivtv-streams.c |4 ++--
 ivtvfb.c   |2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)


diff --git a/drivers/media/video/ivtv/ivtv-driver.c 
b/drivers/media/video/ivtv/ivtv-driver.c
index 6d2dd87..96f340c 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -979,7 +979,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
}
 
itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC);
-   if (itv == 0) {
+   if (itv == NULL) {
spin_unlock(ivtv_cards_lock);
return -ENOMEM;
}
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index fd6826f..24270de 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -688,7 +688,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned 
int cmd, void *arg)
ivtv_reset_ir_gpio(itv);
}
if (val  0x02) {
-   itv-video_dec_func(itv, cmd, 0);
+   itv-video_dec_func(itv, cmd, NULL);
}
break;
}
diff --git a/drivers/media/video/ivtv/ivtv-irq.c 
b/drivers/media/video/ivtv/ivtv-irq.c
index fd1688e..1384615 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -204,7 +204,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 
data[CX2341X_MBOX_MA
s-sg_pending[idx].dst = buf-dma_handle;
s-sg_pending[idx].src = offset;
s-sg_pending[idx].size = s-buf_size;
-   buf-bytesused = (size  s-buf_size) ? size : s-buf_size;
+   buf-bytesused = min(size, s-buf_size);
buf-dma_xfer_cnt = s-dma_xfer_cnt;
 
s-q_predma.bytesused += buf-bytesused;
@@ -705,7 +705,7 @@ static void ivtv_irq_dec_data_req(struct ivtv *itv)
s = itv-streams[IVTV_DEC_STREAM_TYPE_YUV];
}
else {
-   itv-dma_data_req_size = data[2] = 0x1 ? 0x1 : data[2];
+   itv-dma_data_req_size = min_t(u32, data[2], 0x1);
itv-dma_data_req_offset = data[1];
s = itv-streams[IVTV_DEC_STREAM_TYPE_MPG];
}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c 
b/drivers/media/video/ivtv/ivtv-streams.c
index aa03e61..0e9e7d0 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -572,10 +572,10 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
clear_bit(IVTV_F_I_EOS, itv-i_flags);
 
/* Initialize Digitizer for Capture */
-   itv-video_dec_func(itv, VIDIOC_STREAMOFF, 0);
+   itv-video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
ivtv_msleep_timeout(300, 1);
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
-   itv-video_dec_func(itv, VIDIOC_STREAMON, 0);
+   itv-video_dec_func(itv, VIDIOC_STREAMON, NULL);
}
 
/* begin_capture */
diff --git a/drivers/media/video/ivtv/ivtvfb.c 
b/drivers/media/video/ivtv/ivtvfb.c
index 52ffd15..f73ce98 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -1053,7 +1053,7 @@ static int ivtvfb_init_card(struct ivtv *itv)
}
 
itv-osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC);
-   if (itv-osd_info == 0) {
+   if (itv-osd_info == NULL) {
IVTVFB_ERR(Failed to allocate memory for osd_info\n);
return -ENOMEM;
}
--
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] net/xfrm/xfrm_policy.c: Some small improvements

2007-12-07 Thread Richard Knutsson

David Miller wrote:

From: Richard Knutsson <[EMAIL PROTECTED]>
Date: Thu, 06 Dec 2007 15:37:46 +0100

  

David Miller wrote:


But this time I'll just let you know up front that I
don't see much value in this patch.  It is not a clear
improvement to replace int's with bool's in my mind and
the other changes are just whitespace changes.
  
  
Is it not an improvement to distinct booleans from actual values? Do you 
use integers for ASCII characters too? It can also avoid some potential 
bugs like the 'if (i == TRUE)'...
What is wrong with 'size_t' (since it is unsigned, compared to (some) 
'int')?



When you say "int found;" is there any doubt in your mind that
this integer is going to hold a 1 or a 0 depending upon whether
we "found" something?

That's the problem I have with these kinds of patches, they do
not increase clarity, it's just pure mindless edits.
  
But is there not a good thing if also the compiler knows + names are 
sometime not as clear as that one?

In new code, fine, use booleans if you want.

I would even accept that it helps to change to boolean for
arguments to functions that are global in scope.

But not for function local variables in cases like this.
  
Oh, I see your point now. Believed it to be yet another 'booleans is not 
C idiom'.


Sorry about the noise
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] net/xfrm/xfrm_policy.c: Some small improvements

2007-12-07 Thread Richard Knutsson

David Miller wrote:

From: Richard Knutsson [EMAIL PROTECTED]
Date: Thu, 06 Dec 2007 15:37:46 +0100

  

David Miller wrote:


But this time I'll just let you know up front that I
don't see much value in this patch.  It is not a clear
improvement to replace int's with bool's in my mind and
the other changes are just whitespace changes.
  
  
Is it not an improvement to distinct booleans from actual values? Do you 
use integers for ASCII characters too? It can also avoid some potential 
bugs like the 'if (i == TRUE)'...
What is wrong with 'size_t' (since it is unsigned, compared to (some) 
'int')?



When you say int found; is there any doubt in your mind that
this integer is going to hold a 1 or a 0 depending upon whether
we found something?

That's the problem I have with these kinds of patches, they do
not increase clarity, it's just pure mindless edits.
  
But is there not a good thing if also the compiler knows + names are 
sometime not as clear as that one?

In new code, fine, use booleans if you want.

I would even accept that it helps to change to boolean for
arguments to functions that are global in scope.

But not for function local variables in cases like this.
  
Oh, I see your point now. Believed it to be yet another 'booleans is not 
C idiom'.


Sorry about the noise
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] net/xfrm/xfrm_policy.c: Some small improvements

2007-12-06 Thread Richard Knutsson

David Miller wrote:

From: WANG Cong <[EMAIL PROTECTED]>
Date: Thu, 6 Dec 2007 19:01:23 +0800

  

This patch contains the following changes.

- Use 'bool' instead of 'int' for booleans.
- Use 'size_t' instead of 'int' for 'sizeof' return value.
- Some style fixes.

Cc: Herbert Xu <[EMAIL PROTECTED]>
Cc: David Miller <[EMAIL PROTECTED]>
Signed-off-by: WANG Cong <[EMAIL PROTECTED]>



Normally I would let a patch like this sit in my mailbox
for a week and then delete it.
  

That is evil! ;)

But this time I'll just let you know up front that I
don't see much value in this patch.  It is not a clear
improvement to replace int's with bool's in my mind and
the other changes are just whitespace changes.
  
Is it not an improvement to distinct booleans from actual values? Do you 
use integers for ASCII characters too? It can also avoid some potential 
bugs like the 'if (i == TRUE)'...
What is wrong with 'size_t' (since it is unsigned, compared to (some) 
'int')?


/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] net/xfrm/xfrm_policy.c: Some small improvements

2007-12-06 Thread Richard Knutsson

David Miller wrote:

From: WANG Cong [EMAIL PROTECTED]
Date: Thu, 6 Dec 2007 19:01:23 +0800

  

This patch contains the following changes.

- Use 'bool' instead of 'int' for booleans.
- Use 'size_t' instead of 'int' for 'sizeof' return value.
- Some style fixes.

Cc: Herbert Xu [EMAIL PROTECTED]
Cc: David Miller [EMAIL PROTECTED]
Signed-off-by: WANG Cong [EMAIL PROTECTED]



Normally I would let a patch like this sit in my mailbox
for a week and then delete it.
  

That is evil! ;)

But this time I'll just let you know up front that I
don't see much value in this patch.  It is not a clear
improvement to replace int's with bool's in my mind and
the other changes are just whitespace changes.
  
Is it not an improvement to distinct booleans from actual values? Do you 
use integers for ASCII characters too? It can also avoid some potential 
bugs like the 'if (i == TRUE)'...
What is wrong with 'size_t' (since it is unsigned, compared to (some) 
'int')?


/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] ivtv: Some general fixes

2007-12-03 Thread Richard Knutsson
Fix "warning: Using plain integer as NULL pointer".
Convert 'x < y ? x : y' to use min() instead.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
Signed-off-by: Hans Verkuil <[EMAIL PROTECTED]>
---
Compile-tested on i386 with "allyesconfig" and "allmodconfig".
Resend, since the 'Remove a gcc-2.95 requirement'-part is taken away.

 ivtv-driver.c  |2 +-
 ivtv-ioctl.c   |2 +-
 ivtv-irq.c |4 ++--
 ivtv-streams.c |4 ++--
 ivtvfb.c   |2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)


diff --git a/drivers/media/video/ivtv/ivtv-driver.c 
b/drivers/media/video/ivtv/ivtv-driver.c
index 6d2dd87..96f340c 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -979,7 +979,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
}
 
itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC);
-   if (itv == 0) {
+   if (itv == NULL) {
spin_unlock(_cards_lock);
return -ENOMEM;
}
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index fd6826f..24270de 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -688,7 +688,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned 
int cmd, void *arg)
ivtv_reset_ir_gpio(itv);
}
if (val & 0x02) {
-   itv->video_dec_func(itv, cmd, 0);
+   itv->video_dec_func(itv, cmd, NULL);
}
break;
}
diff --git a/drivers/media/video/ivtv/ivtv-irq.c 
b/drivers/media/video/ivtv/ivtv-irq.c
index fd1688e..1384615 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -204,7 +204,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 
data[CX2341X_MBOX_MA
s->sg_pending[idx].dst = buf->dma_handle;
s->sg_pending[idx].src = offset;
s->sg_pending[idx].size = s->buf_size;
-   buf->bytesused = (size < s->buf_size) ? size : s->buf_size;
+   buf->bytesused = min(size, s->buf_size);
buf->dma_xfer_cnt = s->dma_xfer_cnt;
 
s->q_predma.bytesused += buf->bytesused;
@@ -705,7 +705,7 @@ static void ivtv_irq_dec_data_req(struct ivtv *itv)
s = >streams[IVTV_DEC_STREAM_TYPE_YUV];
}
else {
-   itv->dma_data_req_size = data[2] >= 0x1 ? 0x1 : data[2];
+   itv->dma_data_req_size = min_t(u32, data[2], 0x1);
itv->dma_data_req_offset = data[1];
s = >streams[IVTV_DEC_STREAM_TYPE_MPG];
}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c 
b/drivers/media/video/ivtv/ivtv-streams.c
index aa03e61..0e9e7d0 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -572,10 +572,10 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
clear_bit(IVTV_F_I_EOS, >i_flags);
 
/* Initialize Digitizer for Capture */
-   itv->video_dec_func(itv, VIDIOC_STREAMOFF, 0);
+   itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
ivtv_msleep_timeout(300, 1);
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
-   itv->video_dec_func(itv, VIDIOC_STREAMON, 0);
+   itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
}
 
/* begin_capture */
diff --git a/drivers/media/video/ivtv/ivtvfb.c 
b/drivers/media/video/ivtv/ivtvfb.c
index 52ffd15..f73ce98 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -1053,7 +1053,7 @@ static int ivtvfb_init_card(struct ivtv *itv)
}
 
itv->osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC);
-   if (itv->osd_info == 0) {
+   if (itv->osd_info == NULL) {
IVTVFB_ERR("Failed to allocate memory for osd_info\n");
return -ENOMEM;
}
--
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] ivtv: Some general fixes

2007-12-03 Thread Richard Knutsson
Fix warning: Using plain integer as NULL pointer.
Convert 'x  y ? x : y' to use min() instead.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
Signed-off-by: Hans Verkuil [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig and allmodconfig.
Resend, since the 'Remove a gcc-2.95 requirement'-part is taken away.

 ivtv-driver.c  |2 +-
 ivtv-ioctl.c   |2 +-
 ivtv-irq.c |4 ++--
 ivtv-streams.c |4 ++--
 ivtvfb.c   |2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)


diff --git a/drivers/media/video/ivtv/ivtv-driver.c 
b/drivers/media/video/ivtv/ivtv-driver.c
index 6d2dd87..96f340c 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -979,7 +979,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
}
 
itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC);
-   if (itv == 0) {
+   if (itv == NULL) {
spin_unlock(ivtv_cards_lock);
return -ENOMEM;
}
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index fd6826f..24270de 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -688,7 +688,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned 
int cmd, void *arg)
ivtv_reset_ir_gpio(itv);
}
if (val  0x02) {
-   itv-video_dec_func(itv, cmd, 0);
+   itv-video_dec_func(itv, cmd, NULL);
}
break;
}
diff --git a/drivers/media/video/ivtv/ivtv-irq.c 
b/drivers/media/video/ivtv/ivtv-irq.c
index fd1688e..1384615 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -204,7 +204,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 
data[CX2341X_MBOX_MA
s-sg_pending[idx].dst = buf-dma_handle;
s-sg_pending[idx].src = offset;
s-sg_pending[idx].size = s-buf_size;
-   buf-bytesused = (size  s-buf_size) ? size : s-buf_size;
+   buf-bytesused = min(size, s-buf_size);
buf-dma_xfer_cnt = s-dma_xfer_cnt;
 
s-q_predma.bytesused += buf-bytesused;
@@ -705,7 +705,7 @@ static void ivtv_irq_dec_data_req(struct ivtv *itv)
s = itv-streams[IVTV_DEC_STREAM_TYPE_YUV];
}
else {
-   itv-dma_data_req_size = data[2] = 0x1 ? 0x1 : data[2];
+   itv-dma_data_req_size = min_t(u32, data[2], 0x1);
itv-dma_data_req_offset = data[1];
s = itv-streams[IVTV_DEC_STREAM_TYPE_MPG];
}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c 
b/drivers/media/video/ivtv/ivtv-streams.c
index aa03e61..0e9e7d0 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -572,10 +572,10 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
clear_bit(IVTV_F_I_EOS, itv-i_flags);
 
/* Initialize Digitizer for Capture */
-   itv-video_dec_func(itv, VIDIOC_STREAMOFF, 0);
+   itv-video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
ivtv_msleep_timeout(300, 1);
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
-   itv-video_dec_func(itv, VIDIOC_STREAMON, 0);
+   itv-video_dec_func(itv, VIDIOC_STREAMON, NULL);
}
 
/* begin_capture */
diff --git a/drivers/media/video/ivtv/ivtvfb.c 
b/drivers/media/video/ivtv/ivtvfb.c
index 52ffd15..f73ce98 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -1053,7 +1053,7 @@ static int ivtvfb_init_card(struct ivtv *itv)
}
 
itv-osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC);
-   if (itv-osd_info == 0) {
+   if (itv-osd_info == NULL) {
IVTVFB_ERR(Failed to allocate memory for osd_info\n);
return -ENOMEM;
}
--
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: [v4l-dvb-maintainer] [PATCH 1/2] ivtv: Some general fixes

2007-12-02 Thread Richard Knutsson

Hans Verkuil wrote:

On Sunday 02 December 2007 18:46, Richard Knutsson wrote:
  

Fix "warning: Using plain integer as NULL pointer".



Signed-off-by: Hans Verkuil <[EMAIL PROTECTED]>

  

Remove a gcc-2.95 requirement.



NACK! The main v4l-dvb repository that contains this driver can also be 
compiled on older systems. I'd like to keep the option that the driver 
can be compiled with an older gcc version, unless Mauro thinks 
otherwise. Other than the removal of one comment and one space there 
are no other benefits of this change, so I'd prefer to keep it.


  
Oh alright, thought it was just a leftover since the support for the 
2.95 ended.
Maybe add something to the text to let others know the status? (Since I 
found it by doing a 'grep' for "gcc 2.95"'s...)

Convert 'x < y ? x : y' to use min() instead.



Signed-off-by: Hans Verkuil <[EMAIL PROTECTED]>

Thanks,

Hans

  

Thanks for the fast turnaround
Richard

--
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 2/2] ivtv: Remove a invalid shadow-variable

2007-12-02 Thread Richard Knutsson
Remove the shadowing 'struct v4l2_chip_ident *chip', since it already exists
and makes the if-statement useless.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on i386 with "allyesconfig" and "allmodconfig".


diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index fd6826f..874aa22 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -660,11 +660,8 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned 
int cmd, void *arg)
chip->ident = V4L2_IDENT_NONE;
chip->revision = 0;
if (reg->match_type == V4L2_CHIP_MATCH_HOST) {
-   if (v4l2_chip_match_host(reg->match_type, 
reg->match_chip)) {
-   struct v4l2_chip_ident *chip = arg;
-
+   if (v4l2_chip_match_host(reg->match_type, 
reg->match_chip))
chip->ident = itv->has_cx23415 ? 
V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416;
-   }
return 0;
}
if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
--
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/2] ivtv: Some general fixes

2007-12-02 Thread Richard Knutsson
Fix "warning: Using plain integer as NULL pointer".
Remove a gcc-2.95 requirement.
Convert 'x < y ? x : y' to use min() instead.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on i386 with "allyesconfig" and "allmodconfig".

 ivtv-driver.c  |2 +-
 ivtv-driver.h  |4 +---
 ivtv-ioctl.c   |2 +-
 ivtv-irq.c |4 ++--
 ivtv-streams.c |4 ++--
 ivtvfb.c   |2 +-
 6 files changed, 8 insertions(+), 10 deletions(-)


diff --git a/drivers/media/video/ivtv/ivtv-driver.c 
b/drivers/media/video/ivtv/ivtv-driver.c
index 6d2dd87..96f340c 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -979,7 +979,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
}
 
itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC);
-   if (itv == 0) {
+   if (itv == NULL) {
spin_unlock(_cards_lock);
return -ENOMEM;
}
diff --git a/drivers/media/video/ivtv/ivtv-driver.h 
b/drivers/media/video/ivtv/ivtv-driver.h
index 49ce14d..5c4956c 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -132,12 +132,10 @@ extern int ivtv_debug;
 /* Flag to turn on high volume debugging */
 #define IVTV_DBGFLG_HIGHVOL (1 << 10)
 
-/* NOTE: extra space before comma in 'itv->num , ## args' is required for
-   gcc-2.95, otherwise it won't compile. */
 #define IVTV_DEBUG(x, type, fmt, args...) \
do { \
if ((x) & ivtv_debug) \
-   printk(KERN_INFO "ivtv%d " type ": " fmt, itv->num , ## 
args); \
+   printk(KERN_INFO "ivtv%d " type ": " fmt, itv->num, ## 
args); \
} while (0)
 #define IVTV_DEBUG_WARN(fmt, args...)  IVTV_DEBUG(IVTV_DBGFLG_WARN,  "warn",  
fmt , ## args)
 #define IVTV_DEBUG_INFO(fmt, args...)  IVTV_DEBUG(IVTV_DBGFLG_INFO,  "info",  
fmt , ## args)
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index fd6826f..24270de 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -688,7 +688,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned 
int cmd, void *arg)
ivtv_reset_ir_gpio(itv);
}
if (val & 0x02) {
-   itv->video_dec_func(itv, cmd, 0);
+   itv->video_dec_func(itv, cmd, NULL);
}
break;
}
diff --git a/drivers/media/video/ivtv/ivtv-irq.c 
b/drivers/media/video/ivtv/ivtv-irq.c
index fd1688e..1384615 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -204,7 +204,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 
data[CX2341X_MBOX_MA
s->sg_pending[idx].dst = buf->dma_handle;
s->sg_pending[idx].src = offset;
s->sg_pending[idx].size = s->buf_size;
-   buf->bytesused = (size < s->buf_size) ? size : s->buf_size;
+   buf->bytesused = min(size, s->buf_size);
buf->dma_xfer_cnt = s->dma_xfer_cnt;
 
s->q_predma.bytesused += buf->bytesused;
@@ -705,7 +705,7 @@ static void ivtv_irq_dec_data_req(struct ivtv *itv)
s = >streams[IVTV_DEC_STREAM_TYPE_YUV];
}
else {
-   itv->dma_data_req_size = data[2] >= 0x1 ? 0x1 : data[2];
+   itv->dma_data_req_size = min_t(u32, data[2], 0x1);
itv->dma_data_req_offset = data[1];
s = >streams[IVTV_DEC_STREAM_TYPE_MPG];
}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c 
b/drivers/media/video/ivtv/ivtv-streams.c
index aa03e61..0e9e7d0 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -572,10 +572,10 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
clear_bit(IVTV_F_I_EOS, >i_flags);
 
/* Initialize Digitizer for Capture */
-   itv->video_dec_func(itv, VIDIOC_STREAMOFF, 0);
+   itv->video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
ivtv_msleep_timeout(300, 1);
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
-   itv->video_dec_func(itv, VIDIOC_STREAMON, 0);
+   itv->video_dec_func(itv, VIDIOC_STREAMON, NULL);
}
 
/* begin_capture */
diff --git a/drivers/media/video/ivtv/ivtvfb.c 
b/drivers/media/video/ivtv/ivtvfb.c
index 52ffd15..f73ce98 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -1053,7 +1053,7 @@ static int ivtvfb_init_card(struct ivtv *itv)
}
 
itv->osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC);
-   

[PATCH 1/2] ivtv: Some general fixes

2007-12-02 Thread Richard Knutsson
Fix warning: Using plain integer as NULL pointer.
Remove a gcc-2.95 requirement.
Convert 'x  y ? x : y' to use min() instead.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig and allmodconfig.

 ivtv-driver.c  |2 +-
 ivtv-driver.h  |4 +---
 ivtv-ioctl.c   |2 +-
 ivtv-irq.c |4 ++--
 ivtv-streams.c |4 ++--
 ivtvfb.c   |2 +-
 6 files changed, 8 insertions(+), 10 deletions(-)


diff --git a/drivers/media/video/ivtv/ivtv-driver.c 
b/drivers/media/video/ivtv/ivtv-driver.c
index 6d2dd87..96f340c 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -979,7 +979,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
}
 
itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC);
-   if (itv == 0) {
+   if (itv == NULL) {
spin_unlock(ivtv_cards_lock);
return -ENOMEM;
}
diff --git a/drivers/media/video/ivtv/ivtv-driver.h 
b/drivers/media/video/ivtv/ivtv-driver.h
index 49ce14d..5c4956c 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -132,12 +132,10 @@ extern int ivtv_debug;
 /* Flag to turn on high volume debugging */
 #define IVTV_DBGFLG_HIGHVOL (1  10)
 
-/* NOTE: extra space before comma in 'itv-num , ## args' is required for
-   gcc-2.95, otherwise it won't compile. */
 #define IVTV_DEBUG(x, type, fmt, args...) \
do { \
if ((x)  ivtv_debug) \
-   printk(KERN_INFO ivtv%d  type :  fmt, itv-num , ## 
args); \
+   printk(KERN_INFO ivtv%d  type :  fmt, itv-num, ## 
args); \
} while (0)
 #define IVTV_DEBUG_WARN(fmt, args...)  IVTV_DEBUG(IVTV_DBGFLG_WARN,  warn,  
fmt , ## args)
 #define IVTV_DEBUG_INFO(fmt, args...)  IVTV_DEBUG(IVTV_DBGFLG_INFO,  info,  
fmt , ## args)
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index fd6826f..24270de 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -688,7 +688,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned 
int cmd, void *arg)
ivtv_reset_ir_gpio(itv);
}
if (val  0x02) {
-   itv-video_dec_func(itv, cmd, 0);
+   itv-video_dec_func(itv, cmd, NULL);
}
break;
}
diff --git a/drivers/media/video/ivtv/ivtv-irq.c 
b/drivers/media/video/ivtv/ivtv-irq.c
index fd1688e..1384615 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -204,7 +204,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 
data[CX2341X_MBOX_MA
s-sg_pending[idx].dst = buf-dma_handle;
s-sg_pending[idx].src = offset;
s-sg_pending[idx].size = s-buf_size;
-   buf-bytesused = (size  s-buf_size) ? size : s-buf_size;
+   buf-bytesused = min(size, s-buf_size);
buf-dma_xfer_cnt = s-dma_xfer_cnt;
 
s-q_predma.bytesused += buf-bytesused;
@@ -705,7 +705,7 @@ static void ivtv_irq_dec_data_req(struct ivtv *itv)
s = itv-streams[IVTV_DEC_STREAM_TYPE_YUV];
}
else {
-   itv-dma_data_req_size = data[2] = 0x1 ? 0x1 : data[2];
+   itv-dma_data_req_size = min_t(u32, data[2], 0x1);
itv-dma_data_req_offset = data[1];
s = itv-streams[IVTV_DEC_STREAM_TYPE_MPG];
}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c 
b/drivers/media/video/ivtv/ivtv-streams.c
index aa03e61..0e9e7d0 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -572,10 +572,10 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
clear_bit(IVTV_F_I_EOS, itv-i_flags);
 
/* Initialize Digitizer for Capture */
-   itv-video_dec_func(itv, VIDIOC_STREAMOFF, 0);
+   itv-video_dec_func(itv, VIDIOC_STREAMOFF, NULL);
ivtv_msleep_timeout(300, 1);
ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
-   itv-video_dec_func(itv, VIDIOC_STREAMON, 0);
+   itv-video_dec_func(itv, VIDIOC_STREAMON, NULL);
}
 
/* begin_capture */
diff --git a/drivers/media/video/ivtv/ivtvfb.c 
b/drivers/media/video/ivtv/ivtvfb.c
index 52ffd15..f73ce98 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -1053,7 +1053,7 @@ static int ivtvfb_init_card(struct ivtv *itv)
}
 
itv-osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC);
-   if (itv-osd_info == 0) {
+   if (itv-osd_info == NULL) {
IVTVFB_ERR(Failed to allocate memory for osd_info\n);
return -ENOMEM;
}
--
To unsubscribe from this list: send the line unsubscribe linux-kernel

[PATCH 2/2] ivtv: Remove a invalid shadow-variable

2007-12-02 Thread Richard Knutsson
Remove the shadowing 'struct v4l2_chip_ident *chip', since it already exists
and makes the if-statement useless.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig and allmodconfig.


diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c 
b/drivers/media/video/ivtv/ivtv-ioctl.c
index fd6826f..874aa22 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -660,11 +660,8 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned 
int cmd, void *arg)
chip-ident = V4L2_IDENT_NONE;
chip-revision = 0;
if (reg-match_type == V4L2_CHIP_MATCH_HOST) {
-   if (v4l2_chip_match_host(reg-match_type, 
reg-match_chip)) {
-   struct v4l2_chip_ident *chip = arg;
-
+   if (v4l2_chip_match_host(reg-match_type, 
reg-match_chip))
chip-ident = itv-has_cx23415 ? 
V4L2_IDENT_CX23415 : V4L2_IDENT_CX23416;
-   }
return 0;
}
if (reg-match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
--
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: [v4l-dvb-maintainer] [PATCH 1/2] ivtv: Some general fixes

2007-12-02 Thread Richard Knutsson

Hans Verkuil wrote:

On Sunday 02 December 2007 18:46, Richard Knutsson wrote:
  

Fix warning: Using plain integer as NULL pointer.



Signed-off-by: Hans Verkuil [EMAIL PROTECTED]

  

Remove a gcc-2.95 requirement.



NACK! The main v4l-dvb repository that contains this driver can also be 
compiled on older systems. I'd like to keep the option that the driver 
can be compiled with an older gcc version, unless Mauro thinks 
otherwise. Other than the removal of one comment and one space there 
are no other benefits of this change, so I'd prefer to keep it.


  
Oh alright, thought it was just a leftover since the support for the 
2.95 ended.
Maybe add something to the text to let others know the status? (Since I 
found it by doing a 'grep' for gcc 2.95's...)

Convert 'x  y ? x : y' to use min() instead.



Signed-off-by: Hans Verkuil [EMAIL PROTECTED]

Thanks,

Hans

  

Thanks for the fast turnaround
Richard

--
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: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-28 Thread Richard Knutsson

Vegard Nossum wrote:

Hi,

On Nov 28, 2007 7:51 AM, Richard Knutsson <[EMAIL PROTECTED]> wrote:
  

Vegard Nossum wrote:


+static int
  

Not 'static bool'?


+page_is_tracked(struct page *page)
  

Why not returning 'false' and 'true'?



Sorry, I am not used to using bool in C :-) I will change this if bool
is preferred in kernel code.

  
Well, why not use them since we have them (C99 standard and over a year 
in the kernel). ;)
What is "preferred" in a group of a few thousands, is hard to say, but I 
believe it is the way to go. The only "resistance" to it I know, is "it 
is not a C idiom". A quite illogical statement, at best. However, the 
0/1 vs false/true is just a preference. (I like false/true, since I also 
say "true AND false = false" for example... (NOT true = false, makes 
sense to me, NOT 1 = 0 seem strange, why can't it be 2, or -1 ;) ))

+static unsigned int
+opcode_get_size(const uint8_t *opcode)
  

Are we not using 'u8' in the kernel?



Actually, I don't see any reason to use u8 when uint8_t is already
standard and used in other places in the kernel.
  
I believe I have heard they can be a problem in some situations. It also 
have the benefit of uniforming the kernel-code.


cu
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: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-28 Thread Richard Knutsson

Vegard Nossum wrote:

Hi,

On Nov 28, 2007 7:51 AM, Richard Knutsson [EMAIL PROTECTED] wrote:
  

Vegard Nossum wrote:


+static int
  

Not 'static bool'?


+page_is_tracked(struct page *page)
  

Why not returning 'false' and 'true'?



Sorry, I am not used to using bool in C :-) I will change this if bool
is preferred in kernel code.

  
Well, why not use them since we have them (C99 standard and over a year 
in the kernel). ;)
What is preferred in a group of a few thousands, is hard to say, but I 
believe it is the way to go. The only resistance to it I know, is it 
is not a C idiom. A quite illogical statement, at best. However, the 
0/1 vs false/true is just a preference. (I like false/true, since I also 
say true AND false = false for example... (NOT true = false, makes 
sense to me, NOT 1 = 0 seem strange, why can't it be 2, or -1 ;) ))

+static unsigned int
+opcode_get_size(const uint8_t *opcode)
  

Are we not using 'u8' in the kernel?



Actually, I don't see any reason to use u8 when uint8_t is already
standard and used in other places in the kernel.
  
I believe I have heard they can be a problem in some situations. It also 
have the benefit of uniforming the kernel-code.


cu
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: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-27 Thread Richard Knutsson
get_shadow_slab(address, head);
+
+return NULL;
+}
+
+static int

'static bool'?

+test(void *shadow, unsigned int size)
+{
+switch (size) {
+case 8:
+return *(uint8_t *) shadow == 0xff;
+case 16:
+return *(uint16_t *) shadow == 0x;
+case 32:
+return *(uint32_t *) shadow == 0x;
+}
+
+BUG();
+return 0;

'return false;'?

+}
+



cu
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] [VIDEO]: Complement va_start() with va_end() + style fixes

2007-11-27 Thread Richard Knutsson
Please ignore the previous patch. Have resent it, but since my 
mail-client (Thunderbird) seem to be having a bad day, I had to use 
'sendpatchset' and it can't continue on a thread.


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] [VIDEO]: Complement va_start() with va_end() + style fixes

2007-11-27 Thread Richard Knutsson
Complement va_start() with va_end() + minor style fixes in the same function.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on i386 with allyesconfig and allmodconfig.
Thanks to WANG Cong for pointing out the missing 'style fix'-description.
(Sorry about the repost, but Thunderbird seem unhappy now, so I use
'sendpatchset' and can't post in the previous thread)

 saa5246a.c |   10 ++
 saa5249.c  |8 +---
 2 files changed, 11 insertions(+), 7 deletions(-)


diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index ad02329..996b494 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -187,12 +187,14 @@ static int i2c_senddata(struct saa5246a_device *t, ...)
 {
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
-   va_start(argp,t);
+   va_start(argp, t);
 
-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
 }
 
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 94bb59a..da5ca30 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -282,12 +282,14 @@ static int i2c_senddata(struct saa5249_device *t, ...)
 {
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
va_start(argp,t);
 
-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
 }
 
-
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] [VIDEO]: Complement va_start() with va_end() + style fixes

2007-11-27 Thread Richard Knutsson

Complement va_start() with va_end() + minor style fixes in the same function.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on i386 with allyesconfig and allmodconfig.
Thanks to WANG Cong for pointing out the missing 'style fix'-description.

saa5246a.c |   10 ++
saa5249.c  |8 +---
2 files changed, 11 insertions(+), 7 deletions(-)


diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index ad02329..996b494 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -187,12 +187,14 @@ static int i2c_senddata(struct saa5246a_device *t, ...)
{
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
-   va_start(argp,t);
+   va_start(argp, t);

-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
}

diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 94bb59a..da5ca30 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -282,12 +282,14 @@ static int i2c_senddata(struct saa5249_device *t, ...)
{
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
va_start(argp,t);

-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
}



-
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] [VIDEO]: Complement va_start() with va_end() + style fixes

2007-11-27 Thread Richard Knutsson

Complement va_start() with va_end() + minor style fixes in the same function.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig and allmodconfig.
Thanks to WANG Cong for pointing out the missing 'style fix'-description.

saa5246a.c |   10 ++
saa5249.c  |8 +---
2 files changed, 11 insertions(+), 7 deletions(-)


diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index ad02329..996b494 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -187,12 +187,14 @@ static int i2c_senddata(struct saa5246a_device *t, ...)
{
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
-   va_start(argp,t);
+   va_start(argp, t);

-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
}

diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 94bb59a..da5ca30 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -282,12 +282,14 @@ static int i2c_senddata(struct saa5249_device *t, ...)
{
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
va_start(argp,t);

-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
}



-
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] [VIDEO]: Complement va_start() with va_end() + style fixes

2007-11-27 Thread Richard Knutsson
Complement va_start() with va_end() + minor style fixes in the same function.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig and allmodconfig.
Thanks to WANG Cong for pointing out the missing 'style fix'-description.
(Sorry about the repost, but Thunderbird seem unhappy now, so I use
'sendpatchset' and can't post in the previous thread)

 saa5246a.c |   10 ++
 saa5249.c  |8 +---
 2 files changed, 11 insertions(+), 7 deletions(-)


diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index ad02329..996b494 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -187,12 +187,14 @@ static int i2c_senddata(struct saa5246a_device *t, ...)
 {
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
-   va_start(argp,t);
+   va_start(argp, t);
 
-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
 }
 
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 94bb59a..da5ca30 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -282,12 +282,14 @@ static int i2c_senddata(struct saa5249_device *t, ...)
 {
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
va_start(argp,t);
 
-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
 }
 
-
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] [VIDEO]: Complement va_start() with va_end() + style fixes

2007-11-27 Thread Richard Knutsson
Please ignore the previous patch. Have resent it, but since my 
mail-client (Thunderbird) seem to be having a bad day, I had to use 
'sendpatchset' and it can't continue on a thread.


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: [RFC] kmemcheck: trap uses of uninitialized memory (v2)

2007-11-27 Thread Richard Knutsson
 NULL;
+}
+
+static int

'static bool'?

+test(void *shadow, unsigned int size)
+{
+switch (size) {
+case 8:
+return *(uint8_t *) shadow == 0xff;
+case 16:
+return *(uint16_t *) shadow == 0x;
+case 32:
+return *(uint32_t *) shadow == 0x;
+}
+
+BUG();
+return 0;

'return false;'?

+}
+

snip

cu
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] [VIDEO]: Complement va_start() with va_end().

2007-11-26 Thread Richard Knutsson
Complement va_start() with va_end().

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on i386 with allyesconfig and allmodconfig.


diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index ad02329..996b494 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -187,12 +187,14 @@ static int i2c_senddata(struct saa5246a_device *t, ...)
 {
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
-   va_start(argp,t);
+   va_start(argp, t);
 
-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
 }
 
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 94bb59a..da5ca30 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -282,12 +282,14 @@ static int i2c_senddata(struct saa5249_device *t, ...)
 {
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
va_start(argp,t);
 
-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
 }
 
-
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] [RESEND] crypto test: use print_hex_dump from kernel.h instead

2007-11-26 Thread Richard Knutsson

Denis Cheng wrote:

Cc: Randy Dunlap <[EMAIL PROTECTED]>
Signed-off-by: Denis Cheng <[EMAIL PROTECTED]>
---
this is against the lastest cryptodev tree.

 crypto/tcrypt.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 1e12b86..ae762c2 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -87,12 +87,11 @@ static char *check[] = {
"camellia", "seed", "salsa20", NULL
 };
 
-static void hexdump(unsigned char *buf, unsigned int len)

+static inline void hexdump(unsigned char *buf, unsigned int len)
 {
-   while (len--)
-   printk("%02x", *buf++);
-
-   printk("\n");
+   print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+   16, 1,
+   buf, len, 0);
  

Not important, but why use '0' instead of 'false'?

 }
 
 static void tcrypt_complete(struct crypto_async_request *req, int err)
  

cu
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] [ACPI] utilities/: Compliment va_start() with va_end().

2007-11-26 Thread Richard Knutsson

Moore, Robert wrote:

Yes, it's official ANSI C, so I agree with the portability. I'm probably
asking more about the history of the thing.

  
"the history of the thing"? Sorry, you lost me there. I know there were 
a pre-ANSI
version of va_start() & co., but they seemed quite messy. When it comes 
to va_end()
and maintainers, they often seem positive to this. I guess the 
occasional lack off

va_end() is usually an oversight.
  

-Original Message-
From: Richard Knutsson [mailto:[EMAIL PROTECTED]
Sent: Monday, November 26, 2007 4:16 PM
To: Moore, Robert
Cc: Len Brown; linux-kernel@vger.kernel.org; [EMAIL PROTECTED]
Subject: Re: [PATCH] [ACPI] utilities/: Compliment va_start() with
va_end().

Moore, Robert wrote:


This is an interesting one to me.

From various documentation:

After all arguments have been retrieved, va_end resets the pointer to
NULL.

va_end
Each invocation of va_start must be matched by a corresponding
invocation of va_end in the same function. After the call va_end(ap)
  

the
  

variable ap is undefined. Multiple transversals of the list, each
bracketed by va_start and va_end are possible. va_end may be a macro
  

or
  

a function.

Now, I'm all for defensive programming, but I don't really see the
  

point
  

of va_end when the list will be only traversed once.


  

First off, I think it is a good idea to follow the documentation, which
stated:
"va_end
Each invocation of va_start must be matched by a corresponding
invocation of va_end in the same function."

Then if it is not really needed, does it take up extra cycles?
"In practice, with most C compilers, calling |va_end| does nothing
and you do not really need to call it.  This is always true in the GNU


C
  

compiler."[1]

Portability:
"But you might as well call |va_end| just in case your
program is someday compiled with a peculiar compiler."[2]
This argument is not as likely thou, but who knows? (Since I guess


Intel's
  

compiler is included in the 'most C compilers')



We don't set all local pointers to NULL at function exit, what is the
point of doing it here?

  

I think it is a good thing if the code follows the documentation, both
for the person who tries
to understand the code (to see when the 'args' is no longer needed and
not getting confused
by the absent of va_end(), after all, IMHO we should write the code how
we want things to
work and let the compiler do the optimizations (it usually does a


better
  

job at it then we do))
and to automated searches (that is how I found this one).


I suppose some implementation could allocate memory at va_start, but
  

in
  

practice, does this happen?

  

Not sure what you mean.


Bob


  

cu
Richard Knutsson

[1]
http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.ht


ml
  

[2] The rest of [1]'s line.


-
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/
  


-
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] [ACPI] utilities/: Compliment va_start() with va_end().

2007-11-26 Thread Richard Knutsson

Moore, Robert wrote:

This is an interesting one to me.

From various documentation:

After all arguments have been retrieved, va_end resets the pointer to
NULL.

va_end
Each invocation of va_start must be matched by a corresponding
invocation of va_end in the same function. After the call va_end(ap) the
variable ap is undefined. Multiple transversals of the list, each
bracketed by va_start and va_end are possible. va_end may be a macro or
a function.   


Now, I'm all for defensive programming, but I don't really see the point
of va_end when the list will be only traversed once.

  

First off, I think it is a good idea to follow the documentation, which stated:
"va_end
Each invocation of va_start must be matched by a corresponding
invocation of va_end in the same function."

Then if it is not really needed, does it take up extra cycles?
"In practice, with most C compilers, calling |va_end| does nothing
and you do not really need to call it.  This is always true in the GNU C
compiler."[1]

Portability:
"But you might as well call |va_end| just in case your
program is someday compiled with a peculiar compiler."[2]
This argument is not as likely thou, but who knows? (Since I guess Intel's
compiler is included in the 'most C compilers')



We don't set all local pointers to NULL at function exit, what is the
point of doing it here?
  
I think it is a good thing if the code follows the documentation, both 
for the person who tries
to understand the code (to see when the 'args' is no longer needed and 
not getting confused
by the absent of va_end(), after all, IMHO we should write the code how 
we want things to
work and let the compiler do the optimizations (it usually does a better 
job at it then we do))

and to automated searches (that is how I found this one).

I suppose some implementation could allocate memory at va_start, but in
practice, does this happen?
  

Not sure what you mean.

Bob

  

cu
Richard Knutsson

[1] 
http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.html

[2] The rest of [1]'s line.

-
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] [REISERFS]: Complement va_start() with va_end().

2007-11-26 Thread Richard Knutsson
Complement va_start() with va_end().

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on i386 with allyesconfig and allmodconfig.
BTW, the nested if()'s (lines above) may look better if unnested.


diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
index 5e7388b..740bb8c 100644
--- a/fs/reiserfs/prints.c
+++ b/fs/reiserfs/prints.c
@@ -575,6 +575,8 @@ void print_block(struct buffer_head *bh, ...)   //int 
print_mode, int first, int l
printk
("Block %llu contains unformatted 
data\n",
 (unsigned long long)bh->b_blocknr);
+
+   va_end(args);
 }
 
 static char print_tb_buf[2048];
-
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] [REISERFS]: Complement va_start() with va_end().

2007-11-26 Thread Richard Knutsson
Complement va_start() with va_end().

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig and allmodconfig.
BTW, the nested if()'s (lines above) may look better if unnested.


diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
index 5e7388b..740bb8c 100644
--- a/fs/reiserfs/prints.c
+++ b/fs/reiserfs/prints.c
@@ -575,6 +575,8 @@ void print_block(struct buffer_head *bh, ...)   //int 
print_mode, int first, int l
printk
(Block %llu contains unformatted 
data\n,
 (unsigned long long)bh-b_blocknr);
+
+   va_end(args);
 }
 
 static char print_tb_buf[2048];
-
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] [ACPI] utilities/: Compliment va_start() with va_end().

2007-11-26 Thread Richard Knutsson

Moore, Robert wrote:

This is an interesting one to me.

From various documentation:

After all arguments have been retrieved, va_end resets the pointer to
NULL.

va_end
Each invocation of va_start must be matched by a corresponding
invocation of va_end in the same function. After the call va_end(ap) the
variable ap is undefined. Multiple transversals of the list, each
bracketed by va_start and va_end are possible. va_end may be a macro or
a function.   


Now, I'm all for defensive programming, but I don't really see the point
of va_end when the list will be only traversed once.

  

First off, I think it is a good idea to follow the documentation, which stated:
va_end
Each invocation of va_start must be matched by a corresponding
invocation of va_end in the same function.

Then if it is not really needed, does it take up extra cycles?
In practice, with most C compilers, calling |va_end| does nothing
and you do not really need to call it.  This is always true in the GNU C
compiler.[1]

Portability:
But you might as well call |va_end| just in case your
program is someday compiled with a peculiar compiler.[2]
This argument is not as likely thou, but who knows? (Since I guess Intel's
compiler is included in the 'most C compilers')



We don't set all local pointers to NULL at function exit, what is the
point of doing it here?
  
I think it is a good thing if the code follows the documentation, both 
for the person who tries
to understand the code (to see when the 'args' is no longer needed and 
not getting confused
by the absent of va_end(), after all, IMHO we should write the code how 
we want things to
work and let the compiler do the optimizations (it usually does a better 
job at it then we do))

and to automated searches (that is how I found this one).

I suppose some implementation could allocate memory at va_start, but in
practice, does this happen?
  

Not sure what you mean.

Bob

  

cu
Richard Knutsson

[1] 
http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.html

[2] The rest of [1]'s line.

-
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] [ACPI] utilities/: Compliment va_start() with va_end().

2007-11-26 Thread Richard Knutsson

Moore, Robert wrote:

Yes, it's official ANSI C, so I agree with the portability. I'm probably
asking more about the history of the thing.

  
the history of the thing? Sorry, you lost me there. I know there were 
a pre-ANSI
version of va_start()  co., but they seemed quite messy. When it comes 
to va_end()
and maintainers, they often seem positive to this. I guess the 
occasional lack off

va_end() is usually an oversight.
  

-Original Message-
From: Richard Knutsson [mailto:[EMAIL PROTECTED]
Sent: Monday, November 26, 2007 4:16 PM
To: Moore, Robert
Cc: Len Brown; linux-kernel@vger.kernel.org; [EMAIL PROTECTED]
Subject: Re: [PATCH] [ACPI] utilities/: Compliment va_start() with
va_end().

Moore, Robert wrote:


This is an interesting one to me.

From various documentation:

After all arguments have been retrieved, va_end resets the pointer to
NULL.

va_end
Each invocation of va_start must be matched by a corresponding
invocation of va_end in the same function. After the call va_end(ap)
  

the
  

variable ap is undefined. Multiple transversals of the list, each
bracketed by va_start and va_end are possible. va_end may be a macro
  

or
  

a function.

Now, I'm all for defensive programming, but I don't really see the
  

point
  

of va_end when the list will be only traversed once.


  

First off, I think it is a good idea to follow the documentation, which
stated:
va_end
Each invocation of va_start must be matched by a corresponding
invocation of va_end in the same function.

Then if it is not really needed, does it take up extra cycles?
In practice, with most C compilers, calling |va_end| does nothing
and you do not really need to call it.  This is always true in the GNU


C
  

compiler.[1]

Portability:
But you might as well call |va_end| just in case your
program is someday compiled with a peculiar compiler.[2]
This argument is not as likely thou, but who knows? (Since I guess


Intel's
  

compiler is included in the 'most C compilers')



We don't set all local pointers to NULL at function exit, what is the
point of doing it here?

  

I think it is a good thing if the code follows the documentation, both
for the person who tries
to understand the code (to see when the 'args' is no longer needed and
not getting confused
by the absent of va_end(), after all, IMHO we should write the code how
we want things to
work and let the compiler do the optimizations (it usually does a


better
  

job at it then we do))
and to automated searches (that is how I found this one).


I suppose some implementation could allocate memory at va_start, but
  

in
  

practice, does this happen?

  

Not sure what you mean.


Bob


  

cu
Richard Knutsson

[1]
http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.ht


ml
  

[2] The rest of [1]'s line.


-
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/
  


-
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] [RESEND] crypto test: use print_hex_dump from kernel.h instead

2007-11-26 Thread Richard Knutsson

Denis Cheng wrote:

Cc: Randy Dunlap [EMAIL PROTECTED]
Signed-off-by: Denis Cheng [EMAIL PROTECTED]
---
this is against the lastest cryptodev tree.

 crypto/tcrypt.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 1e12b86..ae762c2 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -87,12 +87,11 @@ static char *check[] = {
camellia, seed, salsa20, NULL
 };
 
-static void hexdump(unsigned char *buf, unsigned int len)

+static inline void hexdump(unsigned char *buf, unsigned int len)
 {
-   while (len--)
-   printk(%02x, *buf++);
-
-   printk(\n);
+   print_hex_dump(KERN_CONT, , DUMP_PREFIX_OFFSET,
+   16, 1,
+   buf, len, 0);
  

Not important, but why use '0' instead of 'false'?

 }
 
 static void tcrypt_complete(struct crypto_async_request *req, int err)
  

cu
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] [VIDEO]: Complement va_start() with va_end().

2007-11-26 Thread Richard Knutsson
Complement va_start() with va_end().

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig and allmodconfig.


diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index ad02329..996b494 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -187,12 +187,14 @@ static int i2c_senddata(struct saa5246a_device *t, ...)
 {
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
-   va_start(argp,t);
+   va_start(argp, t);
 
-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
 }
 
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 94bb59a..da5ca30 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -282,12 +282,14 @@ static int i2c_senddata(struct saa5249_device *t, ...)
 {
unsigned char buf[64];
int v;
-   int ct=0;
+   int ct = 0;
va_list argp;
va_start(argp,t);
 
-   while((v=va_arg(argp,int))!=-1)
-   buf[ct++]=v;
+   while ((v = va_arg(argp, int)) != -1)
+   buf[ct++] = v;
+
+   va_end(argp);
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
 }
 
-
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] net/irda/parameters.c: Trivial fixes

2007-11-25 Thread Richard Knutsson

Samuel Ortiz wrote:

Hi Richard,

On Sat, Nov 24, 2007 at 09:44:05PM +0100, Richard Knutsson wrote:
  

Make a single va_start() -> va_end() path + fixing:


Ok, this should be 2 separate patches then.
  
Thought about it, but they were so simple, I believed they would better 
be merged...

The warning fixes are all good, but I fail to see the point of the va_end()
one. That doesn't seem to bring any sort of improvement while adding one
variable to the stack and one loop test. Any explanation here ?
  
Not really. Many seem to like a single return and since this made it one 
va_end() to every va_start(), I thought it would be appropriate. But if 
not, then I will only filter this hit out from the 
va_start()->va_end()-testing and get going.

I'll push the warning fix for now, thanks.
  

Alright, thank you.

Cheers,
Samuel.

  

cu
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] include/asm-m68k: Remove atari_joystick.h

2007-11-25 Thread Richard Knutsson
Remove include/asm-m68k/atari_joystick.h and clean up.

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Not compiled, but should be trivial.
(if FIXED_ATARI_JOYSTICK is defined somehow, please tell how)

 b/arch/m68k/atari/atakeyb.c|8 
 b/arch/m68k/atari/atari_ksyms.c|1 -
 b/drivers/input/mouse/atarimouse.c |   10 --
 include/asm-m68k/atari_joystick.h  |   22 --
 4 files changed, 41 deletions(-)


diff --git a/arch/m68k/atari/atakeyb.c b/arch/m68k/atari/atakeyb.c
index 880add1..11a622b 100644
--- a/arch/m68k/atari/atakeyb.c
+++ b/arch/m68k/atari/atakeyb.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 extern unsigned int keymap_count;
@@ -272,9 +271,6 @@ repeat:
case JOYSTICK:
kb_state.buf[1] = scancode;
kb_state.state = KEYBOARD;
-#ifdef FIXED_ATARI_JOYSTICK
-   atari_joystick_interrupt(kb_state.buf);
-#endif
break;
 
case CLOCK:
@@ -623,10 +619,6 @@ int __init atari_keyb_init(void)
ikbd_mouse_disable();
ikbd_joystick_disable();
 
-#ifdef FIXED_ATARI_JOYSTICK
-   atari_joystick_init();
-#endif
-
// flag init done
atari_keyb_done = 1;
return 0;
diff --git a/arch/m68k/atari/atari_ksyms.c b/arch/m68k/atari/atari_ksyms.c
index a047571..c6113b4 100644
--- a/arch/m68k/atari/atari_ksyms.c
+++ b/arch/m68k/atari/atari_ksyms.c
@@ -5,7 +5,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
diff --git a/drivers/input/mouse/atarimouse.c b/drivers/input/mouse/atarimouse.c
index 98a3561..b8de36f 100644
--- a/drivers/input/mouse/atarimouse.c
+++ b/drivers/input/mouse/atarimouse.c
@@ -62,9 +62,6 @@ static int mouse_threshold[2] = {2,2};
 #ifdef __MODULE__
 MODULE_PARM(mouse_threshold, "2i");
 #endif
-#ifdef FIXED_ATARI_JOYSTICK
-extern int atari_mouse_buttons;
-#endif
 static int atamouse_used = 0;
 
 static struct input_dev *atamouse_dev;
@@ -74,10 +71,6 @@ static void atamouse_interrupt(char *buf)
int buttons, dx, dy;
 
buttons = (buf[0] & 1) | ((buf[0] & 2) << 1);
-#ifdef FIXED_ATARI_JOYSTICK
-   buttons |= atari_mouse_buttons & 2;
-   atari_mouse_buttons = buttons;
-#endif
 
/* only relative events get here */
dx =  buf[1];
@@ -100,9 +93,6 @@ static int atamouse_open(struct input_dev *dev)
if (atamouse_used++)
return 0;
 
-#ifdef FIXED_ATARI_JOYSTICK
-   atari_mouse_buttons = 0;
-#endif
ikbd_mouse_y0_top();
ikbd_mouse_thresh(mouse_threshold[0], mouse_threshold[1]);
ikbd_mouse_rel_pos();
diff --git a/include/asm-m68k/atari_joystick.h 
b/include/asm-m68k/atari_joystick.h
deleted file mode 100644
index 93be7da..000
--- a/include/asm-m68k/atari_joystick.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef _LINUX_ATARI_JOYSTICK_H
-#define _LINUX_ATARI_JOYSTICK_H
-
-/*
- * linux/include/linux/atari_joystick.h
- * header file for Atari Joystick driver
- * by Robert de Vries ([EMAIL PROTECTED]) on 19Jul93
- */
-
-void atari_joystick_interrupt(char*);
-int atari_joystick_init(void);
-extern int atari_mouse_buttons;
-
-struct joystick_status {
-   charfire;
-   chardir;
-   int ready;
-   int active;
-   wait_queue_head_t wait;
-};
-
-#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/


[PATCH] include/asm-m68k: Remove atari_joystick.h

2007-11-25 Thread Richard Knutsson
Remove include/asm-m68k/atari_joystick.h and clean up.

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Not compiled, but should be trivial.
(if FIXED_ATARI_JOYSTICK is defined somehow, please tell how)

 b/arch/m68k/atari/atakeyb.c|8 
 b/arch/m68k/atari/atari_ksyms.c|1 -
 b/drivers/input/mouse/atarimouse.c |   10 --
 include/asm-m68k/atari_joystick.h  |   22 --
 4 files changed, 41 deletions(-)


diff --git a/arch/m68k/atari/atakeyb.c b/arch/m68k/atari/atakeyb.c
index 880add1..11a622b 100644
--- a/arch/m68k/atari/atakeyb.c
+++ b/arch/m68k/atari/atakeyb.c
@@ -30,7 +30,6 @@
 #include asm/atariints.h
 #include asm/atarihw.h
 #include asm/atarikb.h
-#include asm/atari_joystick.h
 #include asm/irq.h
 
 extern unsigned int keymap_count;
@@ -272,9 +271,6 @@ repeat:
case JOYSTICK:
kb_state.buf[1] = scancode;
kb_state.state = KEYBOARD;
-#ifdef FIXED_ATARI_JOYSTICK
-   atari_joystick_interrupt(kb_state.buf);
-#endif
break;
 
case CLOCK:
@@ -623,10 +619,6 @@ int __init atari_keyb_init(void)
ikbd_mouse_disable();
ikbd_joystick_disable();
 
-#ifdef FIXED_ATARI_JOYSTICK
-   atari_joystick_init();
-#endif
-
// flag init done
atari_keyb_done = 1;
return 0;
diff --git a/arch/m68k/atari/atari_ksyms.c b/arch/m68k/atari/atari_ksyms.c
index a047571..c6113b4 100644
--- a/arch/m68k/atari/atari_ksyms.c
+++ b/arch/m68k/atari/atari_ksyms.c
@@ -5,7 +5,6 @@
 #include asm/atarihw.h
 #include asm/atariints.h
 #include asm/atarikb.h
-#include asm/atari_joystick.h
 #include asm/atari_stdma.h
 #include asm/atari_stram.h
 
diff --git a/drivers/input/mouse/atarimouse.c b/drivers/input/mouse/atarimouse.c
index 98a3561..b8de36f 100644
--- a/drivers/input/mouse/atarimouse.c
+++ b/drivers/input/mouse/atarimouse.c
@@ -62,9 +62,6 @@ static int mouse_threshold[2] = {2,2};
 #ifdef __MODULE__
 MODULE_PARM(mouse_threshold, 2i);
 #endif
-#ifdef FIXED_ATARI_JOYSTICK
-extern int atari_mouse_buttons;
-#endif
 static int atamouse_used = 0;
 
 static struct input_dev *atamouse_dev;
@@ -74,10 +71,6 @@ static void atamouse_interrupt(char *buf)
int buttons, dx, dy;
 
buttons = (buf[0]  1) | ((buf[0]  2)  1);
-#ifdef FIXED_ATARI_JOYSTICK
-   buttons |= atari_mouse_buttons  2;
-   atari_mouse_buttons = buttons;
-#endif
 
/* only relative events get here */
dx =  buf[1];
@@ -100,9 +93,6 @@ static int atamouse_open(struct input_dev *dev)
if (atamouse_used++)
return 0;
 
-#ifdef FIXED_ATARI_JOYSTICK
-   atari_mouse_buttons = 0;
-#endif
ikbd_mouse_y0_top();
ikbd_mouse_thresh(mouse_threshold[0], mouse_threshold[1]);
ikbd_mouse_rel_pos();
diff --git a/include/asm-m68k/atari_joystick.h 
b/include/asm-m68k/atari_joystick.h
deleted file mode 100644
index 93be7da..000
--- a/include/asm-m68k/atari_joystick.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef _LINUX_ATARI_JOYSTICK_H
-#define _LINUX_ATARI_JOYSTICK_H
-
-/*
- * linux/include/linux/atari_joystick.h
- * header file for Atari Joystick driver
- * by Robert de Vries ([EMAIL PROTECTED]) on 19Jul93
- */
-
-void atari_joystick_interrupt(char*);
-int atari_joystick_init(void);
-extern int atari_mouse_buttons;
-
-struct joystick_status {
-   charfire;
-   chardir;
-   int ready;
-   int active;
-   wait_queue_head_t wait;
-};
-
-#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] net/irda/parameters.c: Trivial fixes

2007-11-25 Thread Richard Knutsson

Samuel Ortiz wrote:

Hi Richard,

On Sat, Nov 24, 2007 at 09:44:05PM +0100, Richard Knutsson wrote:
  

Make a single va_start() - va_end() path + fixing:


Ok, this should be 2 separate patches then.
  
Thought about it, but they were so simple, I believed they would better 
be merged...

The warning fixes are all good, but I fail to see the point of the va_end()
one. That doesn't seem to bring any sort of improvement while adding one
variable to the stack and one loop test. Any explanation here ?
  
Not really. Many seem to like a single return and since this made it one 
va_end() to every va_start(), I thought it would be appropriate. But if 
not, then I will only filter this hit out from the 
va_start()-va_end()-testing and get going.

I'll push the warning fix for now, thanks.
  

Alright, thank you.

Cheers,
Samuel.

  

cu
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] kernel: Compliment va_copy with va_end()

2007-11-24 Thread Richard Knutsson
Compliment va_copy() with va_end().

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on i386 with allyesconfig & allmodconfig.


diff --git a/kernel/audit.c b/kernel/audit.c
index f93c271..836626c 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1245,6 +1245,7 @@ static void audit_log_vformat(struct audit_buffer *ab, 
const char *fmt,
goto out;
len = vsnprintf(skb_tail_pointer(skb), avail, fmt, args2);
}
+   va_end(args2);
if (len > 0)
skb_put(skb, len);
 out:
-
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] [MIPS]: Compliment va_start() with va_end().

2007-11-24 Thread Richard Knutsson
Compliment va_start() with va_end().

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---

 ieee754.c   |2 ++
 ieee754dp.c |2 ++
 ieee754sp.c |2 ++
 3 files changed, 6 insertions(+)


diff --git a/arch/mips/math-emu/ieee754.c b/arch/mips/math-emu/ieee754.c
index 946aee3..cb1b682 100644
--- a/arch/mips/math-emu/ieee754.c
+++ b/arch/mips/math-emu/ieee754.c
@@ -108,6 +108,7 @@ int ieee754si_xcpt(int r, const char *op, ...)
ax.rv.si = r;
va_start(ax.ap, op);
ieee754_xcpt();
+   va_end(ax.ap);
return ax.rv.si;
 }
 
@@ -122,5 +123,6 @@ s64 ieee754di_xcpt(s64 r, const char *op, ...)
ax.rv.di = r;
va_start(ax.ap, op);
ieee754_xcpt();
+   va_end(ax.ap);
return ax.rv.di;
 }
diff --git a/arch/mips/math-emu/ieee754dp.c b/arch/mips/math-emu/ieee754dp.c
index 3e214aa..6d2d89f 100644
--- a/arch/mips/math-emu/ieee754dp.c
+++ b/arch/mips/math-emu/ieee754dp.c
@@ -57,6 +57,7 @@ ieee754dp ieee754dp_xcpt(ieee754dp r, const char *op, ...)
ax.rv.dp = r;
va_start(ax.ap, op);
ieee754_xcpt();
+   va_end(ax.ap);
return ax.rv.dp;
 }
 
@@ -83,6 +84,7 @@ ieee754dp ieee754dp_nanxcpt(ieee754dp r, const char *op, ...)
ax.rv.dp = r;
va_start(ax.ap, op);
ieee754_xcpt();
+   va_end(ax.ap);
return ax.rv.dp;
 }
 
diff --git a/arch/mips/math-emu/ieee754sp.c b/arch/mips/math-emu/ieee754sp.c
index adda851..4635340 100644
--- a/arch/mips/math-emu/ieee754sp.c
+++ b/arch/mips/math-emu/ieee754sp.c
@@ -58,6 +58,7 @@ ieee754sp ieee754sp_xcpt(ieee754sp r, const char *op, ...)
ax.rv.sp = r;
va_start(ax.ap, op);
ieee754_xcpt();
+   va_end(ax.ap);
return ax.rv.sp;
 }
 
@@ -84,6 +85,7 @@ ieee754sp ieee754sp_nanxcpt(ieee754sp r, const char *op, ...)
ax.rv.sp = r;
va_start(ax.ap, op);
ieee754_xcpt();
+   va_end(ax.ap);
return ax.rv.sp;
 }
 
-
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] net/irda/parameters.c: Trivial fixes

2007-11-24 Thread Richard Knutsson
Make a single va_start() -> va_end() path + fixing:
  CHECK   /home/kernel/src/net/irda/parameters.c
/home/kernel/src/net/irda/parameters.c:466:2: warning: Using plain integer as 
NULL pointer
/home/kernel/src/net/irda/parameters.c:520:2: warning: Using plain integer as 
NULL pointer
/home/kernel/src/net/irda/parameters.c:573:2: warning: Using plain integer as 
NULL pointer

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on i386 with allyesconfig and allmodconfig.


diff --git a/net/irda/parameters.c b/net/irda/parameters.c
index 2627dad..bf19071 100644
--- a/net/irda/parameters.c
+++ b/net/irda/parameters.c
@@ -368,10 +368,11 @@ int irda_param_pack(__u8 *buf, char *fmt, ...)
va_list args;
char *p;
int n = 0;
+   int retval = 0;
 
va_start(args, fmt);
 
-   for (p = fmt; *p != '\0'; p++) {
+   for (p = fmt; *p != '\0' && retval == 0; p++) {
switch (*p) {
case 'b':  /* 8 bits unsigned byte */
buf[n++] = (__u8)va_arg(args, int);
@@ -392,13 +393,12 @@ int irda_param_pack(__u8 *buf, char *fmt, ...)
break;
 #endif
default:
-   va_end(args);
-   return -1;
+   retval = -1;
}
}
va_end(args);
 
-   return 0;
+   return retval;
 }
 EXPORT_SYMBOL(irda_param_pack);
 
@@ -411,10 +411,11 @@ static int irda_param_unpack(__u8 *buf, char *fmt, ...)
va_list args;
char *p;
int n = 0;
+   int retval = 0;
 
va_start(args, fmt);
 
-   for (p = fmt; *p != '\0'; p++) {
+   for (p = fmt; *p != '\0' && retval == 0; p++) {
switch (*p) {
case 'b':  /* 8 bits byte */
arg.ip = va_arg(args, __u32 *);
@@ -436,14 +437,13 @@ static int irda_param_unpack(__u8 *buf, char *fmt, ...)
break;
 #endif
default:
-   va_end(args);
-   return -1;
+   retval = -1;
}
 
}
va_end(args);
 
-   return 0;
+   return retval;
 }
 
 /*
@@ -463,7 +463,7 @@ int irda_param_insert(void *self, __u8 pi, __u8 *buf, int 
len,
int n = 0;
 
IRDA_ASSERT(buf != NULL, return ret;);
-   IRDA_ASSERT(info != 0, return ret;);
+   IRDA_ASSERT(info != NULL, return ret;);
 
pi_minor = pi & info->pi_mask;
pi_major = pi >> info->pi_major_offset;
@@ -517,7 +517,7 @@ static int irda_param_extract(void *self, __u8 *buf, int 
len,
int n = 0;
 
IRDA_ASSERT(buf != NULL, return ret;);
-   IRDA_ASSERT(info != 0, return ret;);
+   IRDA_ASSERT(info != NULL, return ret;);
 
pi_minor = buf[n] & info->pi_mask;
pi_major = buf[n] >> info->pi_major_offset;
@@ -570,7 +570,7 @@ int irda_param_extract_all(void *self, __u8 *buf, int len,
int n = 0;
 
IRDA_ASSERT(buf != NULL, return ret;);
-   IRDA_ASSERT(info != 0, return ret;);
+   IRDA_ASSERT(info != NULL, return ret;);
 
/*
 * Parse all parameters. Each parameter must be at least two bytes
-
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] [ACPI] utilities/: Compliment va_start() with va_end().

2007-11-24 Thread Richard Knutsson
Compliment va_start() with va_end().

Signed-off-by: Richard Knutsson <[EMAIL PROTECTED]>
---
Compile-tested on i386 with allyesconfig & allmodconfig.

 utdebug.c |2 ++
 utmisc.c  |4 
 2 files changed, 6 insertions(+)


diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index c7e128e..f45e3d5 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -203,6 +203,7 @@ acpi_ut_debug_print(u32 requested_debug_level,
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
 }
 
 ACPI_EXPORT_SYMBOL(acpi_ut_debug_print)
@@ -240,6 +241,7 @@ acpi_ut_debug_print_raw(u32 requested_debug_level,
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
 }
 
 ACPI_EXPORT_SYMBOL(acpi_ut_debug_print_raw)
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 2d19f71..ca4904c 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -1032,6 +1032,7 @@ acpi_ut_error(char *module_name, u32 line_number, char 
*format, ...)
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
 }
 
@@ -1046,6 +1047,7 @@ acpi_ut_exception(char *module_name,
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
 }
 
@@ -1060,6 +1062,7 @@ acpi_ut_warning(char *module_name, u32 line_number, char 
*format, ...)
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
 }
 
@@ -1076,5 +1079,6 @@ acpi_ut_info(char *module_name, u32 line_number, char 
*format, ...)
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
acpi_os_printf("\n");
 }
-
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] [ACPI] utilities/: Compliment va_start() with va_end().

2007-11-24 Thread Richard Knutsson
Compliment va_start() with va_end().

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig  allmodconfig.

 utdebug.c |2 ++
 utmisc.c  |4 
 2 files changed, 6 insertions(+)


diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index c7e128e..f45e3d5 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -203,6 +203,7 @@ acpi_ut_debug_print(u32 requested_debug_level,
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
 }
 
 ACPI_EXPORT_SYMBOL(acpi_ut_debug_print)
@@ -240,6 +241,7 @@ acpi_ut_debug_print_raw(u32 requested_debug_level,
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
 }
 
 ACPI_EXPORT_SYMBOL(acpi_ut_debug_print_raw)
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 2d19f71..ca4904c 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -1032,6 +1032,7 @@ acpi_ut_error(char *module_name, u32 line_number, char 
*format, ...)
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
acpi_os_printf( [%X]\n, ACPI_CA_VERSION);
 }
 
@@ -1046,6 +1047,7 @@ acpi_ut_exception(char *module_name,
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
acpi_os_printf( [%X]\n, ACPI_CA_VERSION);
 }
 
@@ -1060,6 +1062,7 @@ acpi_ut_warning(char *module_name, u32 line_number, char 
*format, ...)
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
acpi_os_printf( [%X]\n, ACPI_CA_VERSION);
 }
 
@@ -1076,5 +1079,6 @@ acpi_ut_info(char *module_name, u32 line_number, char 
*format, ...)
 
va_start(args, format);
acpi_os_vprintf(format, args);
+   va_end(args);
acpi_os_printf(\n);
 }
-
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] net/irda/parameters.c: Trivial fixes

2007-11-24 Thread Richard Knutsson
Make a single va_start() - va_end() path + fixing:
  CHECK   /home/kernel/src/net/irda/parameters.c
/home/kernel/src/net/irda/parameters.c:466:2: warning: Using plain integer as 
NULL pointer
/home/kernel/src/net/irda/parameters.c:520:2: warning: Using plain integer as 
NULL pointer
/home/kernel/src/net/irda/parameters.c:573:2: warning: Using plain integer as 
NULL pointer

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig and allmodconfig.


diff --git a/net/irda/parameters.c b/net/irda/parameters.c
index 2627dad..bf19071 100644
--- a/net/irda/parameters.c
+++ b/net/irda/parameters.c
@@ -368,10 +368,11 @@ int irda_param_pack(__u8 *buf, char *fmt, ...)
va_list args;
char *p;
int n = 0;
+   int retval = 0;
 
va_start(args, fmt);
 
-   for (p = fmt; *p != '\0'; p++) {
+   for (p = fmt; *p != '\0'  retval == 0; p++) {
switch (*p) {
case 'b':  /* 8 bits unsigned byte */
buf[n++] = (__u8)va_arg(args, int);
@@ -392,13 +393,12 @@ int irda_param_pack(__u8 *buf, char *fmt, ...)
break;
 #endif
default:
-   va_end(args);
-   return -1;
+   retval = -1;
}
}
va_end(args);
 
-   return 0;
+   return retval;
 }
 EXPORT_SYMBOL(irda_param_pack);
 
@@ -411,10 +411,11 @@ static int irda_param_unpack(__u8 *buf, char *fmt, ...)
va_list args;
char *p;
int n = 0;
+   int retval = 0;
 
va_start(args, fmt);
 
-   for (p = fmt; *p != '\0'; p++) {
+   for (p = fmt; *p != '\0'  retval == 0; p++) {
switch (*p) {
case 'b':  /* 8 bits byte */
arg.ip = va_arg(args, __u32 *);
@@ -436,14 +437,13 @@ static int irda_param_unpack(__u8 *buf, char *fmt, ...)
break;
 #endif
default:
-   va_end(args);
-   return -1;
+   retval = -1;
}
 
}
va_end(args);
 
-   return 0;
+   return retval;
 }
 
 /*
@@ -463,7 +463,7 @@ int irda_param_insert(void *self, __u8 pi, __u8 *buf, int 
len,
int n = 0;
 
IRDA_ASSERT(buf != NULL, return ret;);
-   IRDA_ASSERT(info != 0, return ret;);
+   IRDA_ASSERT(info != NULL, return ret;);
 
pi_minor = pi  info-pi_mask;
pi_major = pi  info-pi_major_offset;
@@ -517,7 +517,7 @@ static int irda_param_extract(void *self, __u8 *buf, int 
len,
int n = 0;
 
IRDA_ASSERT(buf != NULL, return ret;);
-   IRDA_ASSERT(info != 0, return ret;);
+   IRDA_ASSERT(info != NULL, return ret;);
 
pi_minor = buf[n]  info-pi_mask;
pi_major = buf[n]  info-pi_major_offset;
@@ -570,7 +570,7 @@ int irda_param_extract_all(void *self, __u8 *buf, int len,
int n = 0;
 
IRDA_ASSERT(buf != NULL, return ret;);
-   IRDA_ASSERT(info != 0, return ret;);
+   IRDA_ASSERT(info != NULL, return ret;);
 
/*
 * Parse all parameters. Each parameter must be at least two bytes
-
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] [MIPS]: Compliment va_start() with va_end().

2007-11-24 Thread Richard Knutsson
Compliment va_start() with va_end().

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---

 ieee754.c   |2 ++
 ieee754dp.c |2 ++
 ieee754sp.c |2 ++
 3 files changed, 6 insertions(+)


diff --git a/arch/mips/math-emu/ieee754.c b/arch/mips/math-emu/ieee754.c
index 946aee3..cb1b682 100644
--- a/arch/mips/math-emu/ieee754.c
+++ b/arch/mips/math-emu/ieee754.c
@@ -108,6 +108,7 @@ int ieee754si_xcpt(int r, const char *op, ...)
ax.rv.si = r;
va_start(ax.ap, op);
ieee754_xcpt(ax);
+   va_end(ax.ap);
return ax.rv.si;
 }
 
@@ -122,5 +123,6 @@ s64 ieee754di_xcpt(s64 r, const char *op, ...)
ax.rv.di = r;
va_start(ax.ap, op);
ieee754_xcpt(ax);
+   va_end(ax.ap);
return ax.rv.di;
 }
diff --git a/arch/mips/math-emu/ieee754dp.c b/arch/mips/math-emu/ieee754dp.c
index 3e214aa..6d2d89f 100644
--- a/arch/mips/math-emu/ieee754dp.c
+++ b/arch/mips/math-emu/ieee754dp.c
@@ -57,6 +57,7 @@ ieee754dp ieee754dp_xcpt(ieee754dp r, const char *op, ...)
ax.rv.dp = r;
va_start(ax.ap, op);
ieee754_xcpt(ax);
+   va_end(ax.ap);
return ax.rv.dp;
 }
 
@@ -83,6 +84,7 @@ ieee754dp ieee754dp_nanxcpt(ieee754dp r, const char *op, ...)
ax.rv.dp = r;
va_start(ax.ap, op);
ieee754_xcpt(ax);
+   va_end(ax.ap);
return ax.rv.dp;
 }
 
diff --git a/arch/mips/math-emu/ieee754sp.c b/arch/mips/math-emu/ieee754sp.c
index adda851..4635340 100644
--- a/arch/mips/math-emu/ieee754sp.c
+++ b/arch/mips/math-emu/ieee754sp.c
@@ -58,6 +58,7 @@ ieee754sp ieee754sp_xcpt(ieee754sp r, const char *op, ...)
ax.rv.sp = r;
va_start(ax.ap, op);
ieee754_xcpt(ax);
+   va_end(ax.ap);
return ax.rv.sp;
 }
 
@@ -84,6 +85,7 @@ ieee754sp ieee754sp_nanxcpt(ieee754sp r, const char *op, ...)
ax.rv.sp = r;
va_start(ax.ap, op);
ieee754_xcpt(ax);
+   va_end(ax.ap);
return ax.rv.sp;
 }
 
-
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] kernel: Compliment va_copy with va_end()

2007-11-24 Thread Richard Knutsson
Compliment va_copy() with va_end().

Signed-off-by: Richard Knutsson [EMAIL PROTECTED]
---
Compile-tested on i386 with allyesconfig  allmodconfig.


diff --git a/kernel/audit.c b/kernel/audit.c
index f93c271..836626c 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1245,6 +1245,7 @@ static void audit_log_vformat(struct audit_buffer *ab, 
const char *fmt,
goto out;
len = vsnprintf(skb_tail_pointer(skb), avail, fmt, args2);
}
+   va_end(args2);
if (len  0)
skb_put(skb, len);
 out:
-
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 02/13] dio: ARRAY_SIZE() cleanup

2007-11-20 Thread Richard Knutsson

Geert Uytterhoeven wrote:


-#define NUMNAMES (sizeof(names) / sizeof(struct dioname))
+#define NUMNAMES ARRAY_SIZE(names)


Why not replace NUMNAMES?

/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/


  1   2   3   4   >