Re: [2.6.12-rc1-mm4] swapped memset arguments

2005-04-05 Thread Denis Vlasenko
On Sunday 03 April 2005 01:38, Jesper Juhl wrote:
> On Sat, 2 Apr 2005, Maciej Soltysiak wrote:
> 
> > Hi,
> > 
> > out of boredom I grepped 2.6.12-rc1-mm4 for swapped memset arguments.
> > I found one:
> > 
> > # grep -nr "memset.*\,\(\ \|\)0\(\ \|\));" *
> > net/ieee80211/ieee80211_tx.c:226:   memset(txb, sizeof(struct 
> > ieee80211_txb), 0);  
> > 
> And here's a patch : 
> 
> 
> Fix swapped memset() arguments in  net/ieee80211/ieee80211_tx.c  
> found by Maciej Soltysiak.

This one will stop these from happening again.
(Well, at least on i386)...
--
vda
--- linux-2.6.11.src/include/asm-i386/string.h.orig	Thu Mar  3 09:31:08 2005
+++ linux-2.6.11.src/include/asm-i386/string.h	Tue Apr  5 18:34:28 2005
@@ -316,8 +345,16 @@ __asm__ __volatile__(
 return s;
 }
 
-/* we might want to write optimized versions of these later */
-#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
+/*
+ * we might want to write optimized versions of this later
+ * for mow, just prevent common mistake of memset(a,c,0)
+ */
+void BUG_memset_with_zero_length(void);
+static inline void * __constant_count_memset(void * s, int c, size_t count)
+{
+	if(!count) BUG_memset_with_zero_length();
+	return __memset_generic(s,c,count);
+}
 
 /*
  * memset(x,0,y) is a reasonably common thing to do, so we want to fill
@@ -376,6 +413,7 @@ static inline void * __constant_c_and_co
 {
 	switch (count) {
 		case 0:
+			BUG_memset_with_zero_length();
 			return s;
 		case 1:
 			*(unsigned char *)s = pattern;


Re: [2.6.12-rc1-mm4] swapped memset arguments

2005-04-05 Thread Denis Vlasenko
On Sunday 03 April 2005 01:38, Jesper Juhl wrote:
 On Sat, 2 Apr 2005, Maciej Soltysiak wrote:
 
  Hi,
  
  out of boredom I grepped 2.6.12-rc1-mm4 for swapped memset arguments.
  I found one:
  
  # grep -nr memset.*\,\(\ \|\)0\(\ \|\)); *
  net/ieee80211/ieee80211_tx.c:226:   memset(txb, sizeof(struct 
  ieee80211_txb), 0);  
  
 And here's a patch : 
 
 
 Fix swapped memset() arguments in  net/ieee80211/ieee80211_tx.c  
 found by Maciej Soltysiak.

This one will stop these from happening again.
(Well, at least on i386)...
--
vda
--- linux-2.6.11.src/include/asm-i386/string.h.orig	Thu Mar  3 09:31:08 2005
+++ linux-2.6.11.src/include/asm-i386/string.h	Tue Apr  5 18:34:28 2005
@@ -316,8 +345,16 @@ __asm__ __volatile__(
 return s;
 }
 
-/* we might want to write optimized versions of these later */
-#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
+/*
+ * we might want to write optimized versions of this later
+ * for mow, just prevent common mistake of memset(a,c,0)
+ */
+void BUG_memset_with_zero_length(void);
+static inline void * __constant_count_memset(void * s, int c, size_t count)
+{
+	if(!count) BUG_memset_with_zero_length();
+	return __memset_generic(s,c,count);
+}
 
 /*
  * memset(x,0,y) is a reasonably common thing to do, so we want to fill
@@ -376,6 +413,7 @@ static inline void * __constant_c_and_co
 {
 	switch (count) {
 		case 0:
+			BUG_memset_with_zero_length();
 			return s;
 		case 1:
 			*(unsigned char *)s = pattern;


Re: [2.6.12-rc1-mm4] swapped memset arguments

2005-04-02 Thread Jesper Juhl
On Sat, 2 Apr 2005, Maciej Soltysiak wrote:

> Hi,
> 
> out of boredom I grepped 2.6.12-rc1-mm4 for swapped memset arguments.
> I found one:
> 
> # grep -nr "memset.*\,\(\ \|\)0\(\ \|\));" *
> net/ieee80211/ieee80211_tx.c:226:   memset(txb, sizeof(struct 
> ieee80211_txb), 0);  
> 
And here's a patch : 


Fix swapped memset() arguments in  net/ieee80211/ieee80211_tx.c  
found by Maciej Soltysiak.

Signed-off-by: Jesper Juhl <[EMAIL PROTECTED]>

--- linux-2.6.12-rc1-mm4-orig/net/ieee80211/ieee80211_tx.c  2005-03-31 
21:20:08.0 +0200
+++ linux-2.6.12-rc1-mm4/net/ieee80211/ieee80211_tx.c   2005-04-03 
00:34:22.0 +0200
@@ -223,7 +223,7 @@ struct ieee80211_txb *ieee80211_alloc_tx
if (!txb)
return NULL;
 
-   memset(txb, sizeof(struct ieee80211_txb), 0);
+   memset(txb, 0, sizeof(struct ieee80211_txb));
txb->nr_frags = nr_frags;
txb->frag_size = txb_size;
 


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


[2.6.12-rc1-mm4] swapped memset arguments

2005-04-02 Thread Maciej Soltysiak
Hi,

out of boredom I grepped 2.6.12-rc1-mm4 for swapped memset arguments.
I found one:

# grep -nr "memset.*\,\(\ \|\)0\(\ \|\));" *
net/ieee80211/ieee80211_tx.c:226:   memset(txb, sizeof(struct 
ieee80211_txb), 0);  

I found none in Linus' bk.

Regards,
Maciej


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


[2.6.12-rc1-mm4] swapped memset arguments

2005-04-02 Thread Maciej Soltysiak
Hi,

out of boredom I grepped 2.6.12-rc1-mm4 for swapped memset arguments.
I found one:

# grep -nr memset.*\,\(\ \|\)0\(\ \|\)); *
net/ieee80211/ieee80211_tx.c:226:   memset(txb, sizeof(struct 
ieee80211_txb), 0);  

I found none in Linus' bk.

Regards,
Maciej


-
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: [2.6.12-rc1-mm4] swapped memset arguments

2005-04-02 Thread Jesper Juhl
On Sat, 2 Apr 2005, Maciej Soltysiak wrote:

 Hi,
 
 out of boredom I grepped 2.6.12-rc1-mm4 for swapped memset arguments.
 I found one:
 
 # grep -nr memset.*\,\(\ \|\)0\(\ \|\)); *
 net/ieee80211/ieee80211_tx.c:226:   memset(txb, sizeof(struct 
 ieee80211_txb), 0);  
 
And here's a patch : 


Fix swapped memset() arguments in  net/ieee80211/ieee80211_tx.c  
found by Maciej Soltysiak.

Signed-off-by: Jesper Juhl [EMAIL PROTECTED]

--- linux-2.6.12-rc1-mm4-orig/net/ieee80211/ieee80211_tx.c  2005-03-31 
21:20:08.0 +0200
+++ linux-2.6.12-rc1-mm4/net/ieee80211/ieee80211_tx.c   2005-04-03 
00:34:22.0 +0200
@@ -223,7 +223,7 @@ struct ieee80211_txb *ieee80211_alloc_tx
if (!txb)
return NULL;
 
-   memset(txb, sizeof(struct ieee80211_txb), 0);
+   memset(txb, 0, sizeof(struct ieee80211_txb));
txb-nr_frags = nr_frags;
txb-frag_size = txb_size;
 


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