Re: [PATCH 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread David Miller
From: Matthew Wilcox <[EMAIL PROTECTED]>
Date: Wed, 26 Sep 2007 15:01:17 -0400

> Check that 'align' is a power of two, like the API specifies.
> Align 'size' to 'align' correctly -- the current code has an off-by-one.
> The ALIGN macro in kernel.h doesn't.
> 
> Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>

Acked-by: David S. Miller <[EMAIL PROTECTED]>
-
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 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread roel
Matthew Wilcox wrote:
> On Wed, Sep 26, 2007 at 09:47:41PM +0200, roel wrote:
>> The brackets in the first if/else are not required, and you could combine 
>> the two statements:
> 
> You mean braces, not brackets.  And I find this little fetish of yours
> highly disturbing.  I prefer to use braces, and will continue to do so,
> regardless of your nitpicking.

Well as you say it, you like the braces, so it appears to be your fetish. Of 
course you don't 
have to make any changes, I am just reporting them cause they aren't needed. No 
need for the
offensive tone either.

Roel
-
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 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread roel
Matthew Wilcox wrote:
> Check that 'align' is a power of two, like the API specifies.
> Align 'size' to 'align' correctly -- the current code has an off-by-one.
> The ALIGN macro in kernel.h doesn't.
> 
> Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
> ---
>  mm/dmapool.c |   15 ---
>  1 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/dmapool.c b/mm/dmapool.c
> index a359b5e..f5d12a7 100644
> --- a/mm/dmapool.c
> +++ b/mm/dmapool.c
> @@ -107,17 +107,18 @@ struct dma_pool *dma_pool_create(const char *name, 
> struct device *dev,
>  {
>   struct dma_pool *retval;
>  
> - if (align == 0)
> + if (align == 0) {
>   align = 1;
> - if (size == 0)
> + } else if (align & (align - 1)) {
>   return NULL;
> - else if (size < align)
> - size = align;
> - else if ((size % align) != 0) {
> - size += align + 1;
> - size &= ~(align - 1);
>   }
>  
> + if (size == 0)
> + return NULL;

The brackets in the first if/else are not required, and you could combine the 
two statements:

if (align == 0)
align = 1;
else if (align & (align - 1) || size == 0)
return NULL;
> +
> + if ((size % align) != 0)
> + size = ALIGN(size, align);
> +
>   if (allocation == 0) {
>   if (PAGE_SIZE < size)
>   allocation = 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/


[PATCH 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread Matthew Wilcox
Check that 'align' is a power of two, like the API specifies.
Align 'size' to 'align' correctly -- the current code has an off-by-one.
The ALIGN macro in kernel.h doesn't.

Signed-off-by: Matthew Wilcox <[EMAIL PROTECTED]>
---
 mm/dmapool.c |   15 ---
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index a359b5e..f5d12a7 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -107,17 +107,18 @@ struct dma_pool *dma_pool_create(const char *name, struct 
device *dev,
 {
struct dma_pool *retval;
 
-   if (align == 0)
+   if (align == 0) {
align = 1;
-   if (size == 0)
+   } else if (align & (align - 1)) {
return NULL;
-   else if (size < align)
-   size = align;
-   else if ((size % align) != 0) {
-   size += align + 1;
-   size &= ~(align - 1);
}
 
+   if (size == 0)
+   return NULL;
+
+   if ((size % align) != 0)
+   size = ALIGN(size, align);
+
if (allocation == 0) {
if (PAGE_SIZE < size)
allocation = size;
-- 
1.5.3.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 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread Matthew Wilcox
Check that 'align' is a power of two, like the API specifies.
Align 'size' to 'align' correctly -- the current code has an off-by-one.
The ALIGN macro in kernel.h doesn't.

Signed-off-by: Matthew Wilcox [EMAIL PROTECTED]
---
 mm/dmapool.c |   15 ---
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index a359b5e..f5d12a7 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -107,17 +107,18 @@ struct dma_pool *dma_pool_create(const char *name, struct 
device *dev,
 {
struct dma_pool *retval;
 
-   if (align == 0)
+   if (align == 0) {
align = 1;
-   if (size == 0)
+   } else if (align  (align - 1)) {
return NULL;
-   else if (size  align)
-   size = align;
-   else if ((size % align) != 0) {
-   size += align + 1;
-   size = ~(align - 1);
}
 
+   if (size == 0)
+   return NULL;
+
+   if ((size % align) != 0)
+   size = ALIGN(size, align);
+
if (allocation == 0) {
if (PAGE_SIZE  size)
allocation = size;
-- 
1.5.3.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 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread roel
Matthew Wilcox wrote:
 Check that 'align' is a power of two, like the API specifies.
 Align 'size' to 'align' correctly -- the current code has an off-by-one.
 The ALIGN macro in kernel.h doesn't.
 
 Signed-off-by: Matthew Wilcox [EMAIL PROTECTED]
 ---
  mm/dmapool.c |   15 ---
  1 files changed, 8 insertions(+), 7 deletions(-)
 
 diff --git a/mm/dmapool.c b/mm/dmapool.c
 index a359b5e..f5d12a7 100644
 --- a/mm/dmapool.c
 +++ b/mm/dmapool.c
 @@ -107,17 +107,18 @@ struct dma_pool *dma_pool_create(const char *name, 
 struct device *dev,
  {
   struct dma_pool *retval;
  
 - if (align == 0)
 + if (align == 0) {
   align = 1;
 - if (size == 0)
 + } else if (align  (align - 1)) {
   return NULL;
 - else if (size  align)
 - size = align;
 - else if ((size % align) != 0) {
 - size += align + 1;
 - size = ~(align - 1);
   }
  
 + if (size == 0)
 + return NULL;

The brackets in the first if/else are not required, and you could combine the 
two statements:

if (align == 0)
align = 1;
else if (align  (align - 1) || size == 0)
return NULL;
 +
 + if ((size % align) != 0)
 + size = ALIGN(size, align);
 +
   if (allocation == 0) {
   if (PAGE_SIZE  size)
   allocation = 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/


Re: [PATCH 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread roel
Matthew Wilcox wrote:
 On Wed, Sep 26, 2007 at 09:47:41PM +0200, roel wrote:
 The brackets in the first if/else are not required, and you could combine 
 the two statements:
 
 You mean braces, not brackets.  And I find this little fetish of yours
 highly disturbing.  I prefer to use braces, and will continue to do so,
 regardless of your nitpicking.

Well as you say it, you like the braces, so it appears to be your fetish. Of 
course you don't 
have to make any changes, I am just reporting them cause they aren't needed. No 
need for the
offensive tone either.

Roel
-
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 2/4] dmapool: Validate parameters to dma_pool_create

2007-09-26 Thread David Miller
From: Matthew Wilcox [EMAIL PROTECTED]
Date: Wed, 26 Sep 2007 15:01:17 -0400

 Check that 'align' is a power of two, like the API specifies.
 Align 'size' to 'align' correctly -- the current code has an off-by-one.
 The ALIGN macro in kernel.h doesn't.
 
 Signed-off-by: Matthew Wilcox [EMAIL PROTECTED]

Acked-by: David S. Miller [EMAIL PROTECTED]
-
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/