netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] reduce stack usage for arlan
@ 2005-03-08 15:34 Jörn Engel
  2005-05-16  3:22 ` Jeff Garzik
  0 siblings, 1 reply; 3+ messages in thread
From: Jörn Engel @ 2005-03-08 15:34 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

Jean Tourrilhes indicated that this driver is currently unmaintained.
Jeff, do you want this patch?

Jörn

-- 
Fancy algorithms are slow when n is small, and n is usually small.
Fancy algorithms have big constants. Until you know that n is
frequently going to be big, don't get fancy.
-- Rob Pike

SARLSTR is never called with nn bigger than 48.  This patch should be
safe and severly reduces stack consumption.

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
---

 drivers/net/wireless/arlan-proc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.10cow/drivers/net/wireless/arlan-proc.c~arlan_stack	2004-09-04 22:59:04.000000000 +0200
+++ linux-2.6.10cow/drivers/net/wireless/arlan-proc.c	2005-02-03 21:29:33.000000000 +0100
@@ -28,9 +28,9 @@
 	}
 
 #define SARLSTR(var,nn) {\
-	char tmpStr[400];\
+	char tmpStr[50];\
 	int  tmpLn = nn;\
-	if (nn > 399 ) tmpLn = 399; \
+	BUG_ON(tmpLn > 49);\
 	memcpy(tmpStr,(char *) priva->conf->var,tmpLn);\
 	tmpStr[tmpLn] = 0; \
 	pos += sprintf(arlan_drive_info+pos, "%s\t=\t%s \n",#var,priva->conf->var);\

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] reduce stack usage for arlan
  2005-03-08 15:34 [PATCH] reduce stack usage for arlan Jörn Engel
@ 2005-05-16  3:22 ` Jeff Garzik
  2005-05-18 12:20   ` Jörn Engel
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2005-05-16  3:22 UTC (permalink / raw)
  To: Jörn Engel; +Cc: netdev

Jörn Engel wrote:
> Jean Tourrilhes indicated that this driver is currently unmaintained.
> Jeff, do you want this patch?

>  #define SARLSTR(var,nn) {\
> -	char tmpStr[400];\
> +	char tmpStr[50];\
>  	int  tmpLn = nn;\
> -	if (nn > 399 ) tmpLn = 399; \
> +	BUG_ON(tmpLn > 49);\


I'm uncomfortable with arbitrarily lowering the string size, even if it 
does include a BUG_ON()...

	Jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] reduce stack usage for arlan
  2005-05-16  3:22 ` Jeff Garzik
@ 2005-05-18 12:20   ` Jörn Engel
  0 siblings, 0 replies; 3+ messages in thread
From: Jörn Engel @ 2005-05-18 12:20 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

On Sun, 15 May 2005 23:22:35 -0400, Jeff Garzik wrote:
> Jörn Engel wrote:
> >Jean Tourrilhes indicated that this driver is currently unmaintained.
> >Jeff, do you want this patch?
> 
> > #define SARLSTR(var,nn) {\
> >-	char tmpStr[400];\
> >+	char tmpStr[50];\
> > 	int  tmpLn = nn;\
> >-	if (nn > 399 ) tmpLn = 399; \
> >+	BUG_ON(tmpLn > 49);\
> 
> I'm uncomfortable with arbitrarily lowering the string size, even if it 
> does include a BUG_ON()...

Here are all invocations of the macro in question:
        SARLSTR(textRegion, 48);
        SARLSTR(name, 16);

Still uncomfortable?

Jörn

-- 
Those who come seeking peace without a treaty are plotting.
-- Sun Tzu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-05-18 12:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-08 15:34 [PATCH] reduce stack usage for arlan Jörn Engel
2005-05-16  3:22 ` Jeff Garzik
2005-05-18 12:20   ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).