linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org,
	"John W. Linville" <linville@tuxdriver.com>
Subject: Re: [PATCH] d80211: fix sparse warnings
Date: Mon, 26 Feb 2007 20:18:29 -0500	[thread overview]
Message-ID: <1172539109.5835.28.camel@dv> (raw)
In-Reply-To: <1172530759.3870.205.camel@johannes.berg>

On Mon, 2007-02-26 at 23:59 +0100, Johannes Berg wrote:
> This fixes some sparse warnings in d80211.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> 
> ---
> A few warnings remain:
> 
> net/d80211/ieee80211.c:820:37: warning: potentially expensive pointer subtraction

That's subtraction of pointers to types with sizes that are not power of
two.  This could lead to expensive division operations.  In may cases,
this warning indicates that using array indices instead of pointers
would be more effective (and probably safer).

> net/d80211/ieee80211_ioctl.c:779:4: warning: incorrect type in argument 6 (different signedness)
> net/d80211/ieee80211_ioctl.c:779:4:    expected int *err
> net/d80211/ieee80211_ioctl.c:779:4:    got unsigned int *<noident>

ieee80211_set_encryption() expects a pointer to (signed) integer, be the
code is giving it a pointer to u32.  Please decide what type "err"
should have, and change the function accordingly.

I think "u32" would be better, since it's a part of the hostapd
compatibility code and we don't want to touch the userspace now.  This
code is going to be obsoleted with the rest of hostapd interface.  For
now, it's better to do exactly what the userspace expects.

> net/d80211/sta_info.c:232:3: warning: context imbalance in 'sta_info_free' - unexpected unlock
> 
> The last of these is bogus, the code is perfectly fine. The other two I
> don't understand.

Great catch!  I have reduced this to a simple test case where sparse
behaves unreasonably, and I'm going to send it to sparse developers as a
bug report.

In case you are wondering, the test case is:

void my_lock(void) __attribute__ ((context(lock, 0, 1)));
void my_unlock(void) __attribute__ ((context(lock, 1, 0)));
void foo(void);
static void sta_info_free(int locked)
{
	if (locked)
		my_lock();
	foo();
	if (locked)
		my_unlock();
}

-- 
Regards,
Pavel Roskin


  reply	other threads:[~2007-02-27  1:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-26 22:59 [PATCH] d80211: fix sparse warnings Johannes Berg
2007-02-27  1:18 ` Pavel Roskin [this message]
2007-02-27  7:16   ` Pavel Roskin
2007-02-27  8:28   ` Johannes Berg
2007-02-27 15:40   ` Michael Buesch
2007-02-27 15:45     ` Michael Wu

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=1172539109.5835.28.camel@dv \
    --to=proski@gnu.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /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;
as well as URLs for NNTP newsgroup(s).