mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Dunlap <randy.dunlap@oracle.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Adrian Bunk <bunk@stusta.de>,
	jgarzik@pobox.com, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, linux-wireless@vger.kernel.org
Subject: Re: 2.6.21-rc2-mm2: drivers/net/wireless/libertas/debugfs.c addr bogosity
Date: Fri, 9 Mar 2007 09:14:29 -0800	[thread overview]
Message-ID: <20070309091429.a84aee9b.randy.dunlap@oracle.com> (raw)
In-Reply-To: <20070309141906.GA3296@tuxdriver.com>

On Fri, 9 Mar 2007 09:19:07 -0500 John W. Linville wrote:

> Probably should copy me and linux-wireless@vger.kernel.org.  Other than
> that, this looks fine to me.  I'll queue it up shortly.
> 
> John
> 
> On Fri, Mar 09, 2007 at 01:11:46PM +1100, Tony Breeds wrote:
> > On Wed, Mar 07, 2007 at 03:00:57PM -0800, Andrew Morton wrote:
> > > On Wed, 7 Mar 2007 23:41:16 +0100
> > > Adrian Bunk <bunk@stusta.de> wrote:
> > > 
> > > > On Tue, Mar 06, 2007 at 12:44:08AM -0800, Andrew Morton wrote:
> > > > >...
> > > > > Changes since 2.6.20-rc2-mm1:
> > > > >...
> > > > >  git-netdev-all.patch
> > > > >...
> > > > >  git trees
> > > > >...
> > > > 
> > > > drivers/net/wireless/libertas/debugfs.c contains:
> > > >   #define item_addr(n) ((u32) &((wlan_adapter *)0)->n)
> > > > 
> > > > This is wrong on 64bit architectures.
> > > 
> > > Is OK - it is simply yet another reimplementation of offsetof().  Hint.
> > 
> > Perhaps something like?
> > 
> > Against 2.6.21-rc3-mm2
> > 
> > From: Tony Breeds <tony@bakeyournoodle.com>
> > 
> > Cleanup drivers/net/wireless/libertas/debugfs.c to use standard kernel macros and functions.
> > 
> > Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
> > 
> > ---
> > only compile tested on x86
> > 
> >  debugfs.c |   41 ++++-------------------------------------
> >  1 file changed, 4 insertions(+), 37 deletions(-)
> > 
> > diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
> > index 3ad1e03..51dfd20 100644
> > --- a/drivers/net/wireless/libertas/debugfs.c
> > +++ b/drivers/net/wireless/libertas/debugfs.c
> > @@ -1772,8 +1772,8 @@ void libertas_debugfs_remove_one(wlan_private *priv)
> >  
> >  /* debug entry */
> >  
> > -#define item_size(n) (sizeof ((wlan_adapter *)0)->n)
> > -#define item_addr(n) ((u32) &((wlan_adapter *)0)->n)
> > +#define item_size(n)	(FIELD_SIZEOF(wlan_adapter, n))

Good to use FIELD_SIZEOF(), but in general, we prefer to use it
directly, not in yet another wrapper.

> > +#define item_addr(n)	(offsetof(wlan_adapter, n))
> >  
> >  struct debug_data {
> >  	char name[32];
> > @@ -1789,40 +1789,7 @@ static struct debug_data items[] = {
> >  	{"psstate", item_size(psstate), item_addr(psstate)},
> >  };
> >  
> > -static int num_of_items = sizeof(items) / sizeof(items[0]);
> > -
> > -/**
> > - *  @brief convert string to number
> > - *
> > - *  @param s   	   pointer to numbered string
> > - *  @return 	   converted number from string s
> > - */
> > -static int string_to_number(char *s)
> > -{
> > -	int r = 0;
> > -	int base = 0;
> > -
> > -	if ((strncmp(s, "0x", 2) == 0) || (strncmp(s, "0X", 2) == 0))
> > -		base = 16;
> > -	else
> > -		base = 10;
> > -
> > -	if (base == 16)
> > -		s += 2;
> > -
> > -	for (s = s; *s != 0; s++) {
> > -		if ((*s >= 48) && (*s <= 57))
> > -			r = (r * base) + (*s - 48);
> > -		else if ((*s >= 65) && (*s <= 70))
> > -			r = (r * base) + (*s - 55);
> > -		else if ((*s >= 97) && (*s <= 102))
> > -			r = (r * base) + (*s - 87);
> > -		else
> > -			break;
> > -	}
> > -
> > -	return r;
> > -}
> > +static int num_of_items = ARRAY_SIZE(items);
> >  
> >  /**
> >   *  @brief proc read function
> > @@ -1912,7 +1879,7 @@ static int wlan_debugfs_write(struct file *f, const char __user *buf,
> >  			if (!p2)
> >  				break;
> >  			p2++;
> > -			r = string_to_number(p2);
> > +			r = simple_strtoul(p2, NULL, 0);
> >  			if (d[i].size == 1)
> >  				*((u8 *) d[i].addr) = (u8) r;
> >  			else if (d[i].size == 2)



---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

  reply	other threads:[~2007-03-09 17:20 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-06  8:44 2.6.21-rc2-mm2 Andrew Morton
2007-03-06  9:06 ` 2.6.21-rc2-mm2 J.A. Magallón
2007-03-06  9:15   ` 2.6.21-rc2-mm2 Andrew Morton
2007-03-06  9:38     ` 2.6.21-rc2-mm2 J.A. Magallón
2007-03-06  9:42       ` 2.6.21-rc2-mm2 Andrew Morton
2007-03-06  9:44         ` 2.6.21-rc2-mm2 J.A. Magallón
2007-03-06 11:14   ` 2.6.21-rc2-mm2 Jens Axboe
2007-03-06 10:27 ` 2.6.21-rc2-mm2 KAMEZAWA Hiroyuki
2007-03-06 11:09   ` 2.6.21-rc2-mm2 Andrew Morton
2007-03-06 11:35     ` 2.6.21-rc2-mm2 KAMEZAWA Hiroyuki
2007-03-07  6:23       ` [BUGFIX][PATCH] fix NULL pointer in ia64/irq_chip-mask/unmask function KAMEZAWA Hiroyuki
2007-03-07  6:57         ` Andrew Morton
2007-03-07  7:32           ` KAMEZAWA Hiroyuki
2007-03-08  8:41   ` 2.6.21-rc2-mm2 Magnus Damm
2007-03-06 11:58 ` 2.6.21-rc2-mm2 Con Kolivas
2007-03-06 12:52   ` 2.6.21-rc2-mm2 Thomas Gleixner
2007-03-06 13:24     ` 2.6.21-rc2-mm2 Con Kolivas
2007-03-06 14:47       ` 2.6.21-rc2-mm2 Thomas Gleixner
2007-03-06 20:19         ` 2.6.21-rc2-mm2 Con Kolivas
2007-03-06 15:46 ` 2.6.21-rc2-mm2 J.A. Magallón
2007-03-07  6:24   ` 2.6.21-rc2-mm2 Jean Delvare
2007-03-07  8:39 ` 2.6.21-rc2-mm2 Sébastien Dugué
2007-03-07  8:49   ` 2.6.21-rc2-mm2 Andrew Morton
2007-03-07  9:30     ` 2.6.21-rc2-mm2 Sébastien Dugué
2007-03-07 19:46 ` 2.6.21-rc2-mm2 Luiz Fernando N. Capitulino
2007-03-07 19:52   ` 2.6.21-rc2-mm2 Andrew Morton
2007-03-08  7:20     ` 2.6.21-rc2-mm2 Mike Galbraith
2007-03-07 22:12 ` 2.6.21-rc2-mm2 hang Dave Hansen
2007-03-07 22:46   ` Andrew Morton
     [not found]   ` <20070307221628.GD26473@linux-os.sc.intel.com>
2007-03-07 23:07     ` Dave Hansen
2007-03-07 23:16       ` Andrew Morton
2007-03-08 15:07         ` Michal Piotrowski
2007-03-08  1:07   ` Siddha, Suresh B
2007-03-07 22:41 ` [RFC: -mm patch] #if 0 mmc_deselect_cards() Adrian Bunk
2007-03-08  5:47   ` Pierre Ossman
2007-03-19  9:21     ` [-mm patch] remove mmc_deselect_cards() Adrian Bunk
2007-03-08  6:31   ` MMC: Fix typo in mmc highspeed Kyungmin Park
2007-03-07 22:41 ` 2.6.21-rc2-mm2: drivers/net/wireless/libertas/debugfs.c addr bogosity Adrian Bunk
2007-03-07 23:00   ` Andrew Morton
2007-03-08  8:02     ` Adrian Bunk
2007-03-09  2:11     ` Tony Breeds
2007-03-09 14:19       ` John W. Linville
2007-03-09 17:14         ` Randy Dunlap [this message]
2007-03-12  3:43           ` Tony Breeds
2007-03-08  0:03 ` e1000 oops on boot [Re: 2.6.21-rc2-mm2] J.A. Magallón
2007-03-08  0:23   ` Andrew Morton
2007-03-08  0:28     ` Randy Dunlap
2007-03-08  0:35       ` Kok, Auke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070309091429.a84aee9b.randy.dunlap@oracle.com \
    --to=randy.dunlap@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=bunk@stusta.de \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome