* [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX removal
@ 2004-02-07 15:35 Michael Veeck
2004-02-07 17:41 ` [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX Domen Puncer
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael Veeck @ 2004-02-07 15:35 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 148 bytes --]
Hi!
Patch (against 2.6.3-rc1) removes unnecessary min/max macros and changes
calls to use kernel.h macros instead.
Feedback always welcome
Michael
[-- Attachment #2: minmax_drivers_net_wireless.patch --]
[-- Type: text/plain, Size: 1463 bytes --]
diff -Naur linux-2.6.2.org/drivers/net/wireless/strip.c linux-2.6.2.new/drivers/net/wireless/strip.c
--- linux-2.6.2.org/drivers/net/wireless/strip.c 2004-02-07 15:25:57.000000000 +0100
+++ linux-2.6.2.new/drivers/net/wireless/strip.c 2004-02-07 15:33:24.305031008 +0100
@@ -88,7 +88,7 @@
#include <asm/uaccess.h>
#include <asm/bitops.h>
-# include <linux/ctype.h>
+#include <linux/ctype.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
@@ -454,8 +454,6 @@
#define READDEC(X) ((X)>='0' && (X)<='9' ? (X)-'0' : 0)
-#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
-#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
#define ELEMENTS_OF(X) (sizeof(X) / sizeof((X)[0]))
#define ARRAY_END(X) (&((X)[ELEMENTS_OF(X)]))
@@ -847,7 +845,7 @@
static int allocate_buffers(struct strip *strip_info, int mtu)
{
struct net_device *dev = strip_info->dev;
- int sx_size = MAX(STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
+ int sx_size = max((int)STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
int tx_size = STRIP_ENCAP_SIZE(mtu) + MaxCommandStringLength;
__u8 *r = kmalloc(MAX_RECV_MTU, GFP_ATOMIC);
__u8 *s = kmalloc(sx_size, GFP_ATOMIC);
@@ -1709,7 +1707,7 @@
p++;
len = value_end - value_begin;
- len = MIN(len, sizeof(FirmwareVersion) - 1);
+ len = min(len, (int) sizeof(FirmwareVersion) - 1);
if (strip_info->firmware_version.c[0] == 0)
printk(KERN_INFO "%s: Radio Firmware: %.*s\n",
strip_info->dev->name, len, value_begin);
[-- Attachment #3: Type: text/plain, Size: 163 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX
2004-02-07 15:35 [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX removal Michael Veeck
@ 2004-02-07 17:41 ` Domen Puncer
2004-02-07 20:24 ` Michael Veeck
2004-02-07 21:31 ` Domen Puncer
2 siblings, 0 replies; 4+ messages in thread
From: Domen Puncer @ 2004-02-07 17:41 UTC (permalink / raw)
To: kernel-janitors
On Saturday 07 of February 2004 16:35, Michael Veeck wrote:
> Hi!
> Patch (against 2.6.3-rc1) removes unnecessary min/max macros and changes
> calls to use kernel.h macros instead.
> Feedback always welcome
> Michael
Just some suggestions...
> @@ -454,8 +454,6 @@
>
> #define READDEC(X) ((X)>='0' && (X)<='9' ? (X)-'0' : 0)
>
> -#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
> -#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
> #define ELEMENTS_OF(X) (sizeof(X) / sizeof((X)[0]))
Remove this define and s/ELEMENTS_OF/ARRAY_SIZE/g
> @@ -847,7 +845,7 @@
> static int allocate_buffers(struct strip *strip_info, int mtu)
> {
> struct net_device *dev = strip_info->dev;
> - int sx_size = MAX(STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
> + int sx_size = max((int)STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
max_t?
Domen
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX
2004-02-07 15:35 [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX removal Michael Veeck
2004-02-07 17:41 ` [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX Domen Puncer
@ 2004-02-07 20:24 ` Michael Veeck
2004-02-07 21:31 ` Domen Puncer
2 siblings, 0 replies; 4+ messages in thread
From: Michael Veeck @ 2004-02-07 20:24 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 698 bytes --]
Domen Puncer schrieb:
>
> Just some suggestions...
>
>> #define ELEMENTS_OF(X) (sizeof(X) / sizeof((X)[0]))
>
> Remove this define and s/ELEMENTS_OF/ARRAY_SIZE/g
>
There are more occurances of redundant ARRAY_SIZEs in the kernel. I will
keep that in mind!
>
>
>>@@ -847,7 +845,7 @@
>> static int allocate_buffers(struct strip *strip_info, int mtu)
>> {
>> struct net_device *dev = strip_info->dev;
>>- int sx_size = MAX(STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
>>+ int sx_size = max((int)STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
>
>
> max_t?
Changed that to max_t and min_t. A newbie queston: What should when be
preferred and why?
Attached is the new patch.
Veeck
[-- Attachment #2: minmax_drivers_net_wireless.patch --]
[-- Type: text/plain, Size: 1749 bytes --]
--- linux-2.6.2.org/drivers/net/wireless/strip.c 2004-02-07 15:25:57.000000000 +0100
+++ linux-2.6.2.new/drivers/net/wireless/strip.c 2004-02-07 19:38:12.217658552 +0100
@@ -82,6 +82,7 @@
/* Header files */
#include <linux/config.h>
+#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <asm/system.h>
@@ -454,10 +455,7 @@
#define READDEC(X) ((X)>='0' && (X)<='9' ? (X)-'0' : 0)
-#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
-#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
-#define ELEMENTS_OF(X) (sizeof(X) / sizeof((X)[0]))
-#define ARRAY_END(X) (&((X)[ELEMENTS_OF(X)]))
+#define ARRAY_END(X) (&((X)[ARRAY_SIZE(X)]))
#define JIFFIE_TO_SEC(X) ((X) / HZ)
@@ -847,7 +845,7 @@
static int allocate_buffers(struct strip *strip_info, int mtu)
{
struct net_device *dev = strip_info->dev;
- int sx_size = MAX(STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
+ int sx_size = max_t(int, STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
int tx_size = STRIP_ENCAP_SIZE(mtu) + MaxCommandStringLength;
__u8 *r = kmalloc(MAX_RECV_MTU, GFP_ATOMIC);
__u8 *s = kmalloc(sx_size, GFP_ATOMIC);
@@ -1465,7 +1463,7 @@
/* Cycle to next periodic command? */
if (strip_info->firmware_level >= StructuredMessages)
if (++strip_info->next_command >=
- ELEMENTS_OF(CommandString))
+ ARRAY_SIZE(CommandString))
strip_info->next_command = 0;
#ifdef EXT_COUNTERS
strip_info->tx_ebytes += ts.length;
@@ -1709,7 +1707,7 @@
p++;
len = value_end - value_begin;
- len = MIN(len, sizeof(FirmwareVersion) - 1);
+ len = min_t(int, len, sizeof(FirmwareVersion) - 1);
if (strip_info->firmware_version.c[0] == 0)
printk(KERN_INFO "%s: Radio Firmware: %.*s\n",
strip_info->dev->name, len, value_begin);
[-- Attachment #3: Type: text/plain, Size: 163 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX
2004-02-07 15:35 [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX removal Michael Veeck
2004-02-07 17:41 ` [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX Domen Puncer
2004-02-07 20:24 ` Michael Veeck
@ 2004-02-07 21:31 ` Domen Puncer
2 siblings, 0 replies; 4+ messages in thread
From: Domen Puncer @ 2004-02-07 21:31 UTC (permalink / raw)
To: kernel-janitors
On Saturday 07 of February 2004 21:24, Michael Veeck wrote:
<snip>
> >>- int sx_size = MAX(STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
> >>+ int sx_size = max((int)STRIP_ENCAP_SIZE(MAX_RECV_MTU), 4096);
> >
> > max_t?
>
> Changed that to max_t and min_t. A newbie queston: What should when be
> preferred and why?
min_t/max_t when there are different type arguments.
Because it looks nicer? :-)
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-07 21:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-07 15:35 [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX removal Michael Veeck
2004-02-07 17:41 ` [Kernel-janitors] [PATCH] drivers/net/wireless/strip.c MIN/MAX Domen Puncer
2004-02-07 20:24 ` Michael Veeck
2004-02-07 21:31 ` Domen Puncer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.