linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Bruno Randolf <bruno@thinktube.com>
Cc: ath5k-devel@lists.ath5k.org, mcgrof@gmail.com,
	mickflemm@gmail.com, linux-wireless@vger.kernel.org,
	linville@tuxdriver.com
Subject: Re: [PATCH] ath5k: debug level improvements
Date: Sat, 19 Jan 2008 11:21:31 +0100	[thread overview]
Message-ID: <4791CF2B.7090604@gmail.com> (raw)
In-Reply-To: <20080119024926.12055.9695.stgit@one>

On 01/19/2008 03:49 AM, Bruno Randolf wrote:
> * use only one debug level for beacon debugging: unify ATH5K_DEBUG_BEACON and
> ATH5K_DEBUG_BEACON_PROC
> 
> * remove debug level ATH5K_DEBUG_FATAL. doesn't make sense as a debug level -
> if it's fatal it should be logged as an error.
> 
> * fancier printing of debug levels. cat /debugfs/ath5k/phy0/debug
> 
> * allow debug levels to be changed by echoing their name into
> /debugfs/ath5k/phy0/debug. this will toggle the state, when it was off it will
> be turned on and vice versa.
> 
> drivers/net/wireless/ath5k/base.c:      Changes-licensed-under: 3-Clause-BSD
> drivers/net/wireless/ath5k/debug.c:     Changes-licensed-under: GPL
> drivers/net/wireless/ath5k/debug.h:     Changes-licensed-under: GPL
> 
> Signed-off-by: Bruno Randolf <bruno@thinktube.com>
> Acked-by: Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
> ---
> 
>  drivers/net/wireless/ath5k/base.c  |   10 ++--
>  drivers/net/wireless/ath5k/debug.c |   95 +++++++++++++++++++++++++++++++-----
>  drivers/net/wireless/ath5k/debug.h |   18 +++----
>  3 files changed, 93 insertions(+), 30 deletions(-)
> 
> 
[...]
> diff --git a/drivers/net/wireless/ath5k/debug.c b/drivers/net/wireless/ath5k/debug.c
> index 4ba649e..63e39f9 100644
> --- a/drivers/net/wireless/ath5k/debug.c
> +++ b/drivers/net/wireless/ath5k/debug.c
> @@ -314,6 +314,76 @@ static const struct file_operations fops_reset = {
[...]
> +static ssize_t write_file_debug(struct file *file,
> +				 const char __user *userbuf,
> +				 size_t count, loff_t *ppos)
> +{
> +	struct ath5k_softc *sc = file->private_data;
> +	int i;

BTW. unsigned int generates better code on most platforms.

> +
> +	for (i = 0; i < ARRAY_SIZE(dbg_info); i++) {
> +		if (strncmp(userbuf, dbg_info[i].name,
> +					strlen(dbg_info[i].name)) == 0)

Ah, we have bugs in debug write methods. You can't pass user buffer to strcmp. 
You must copy_from_user() it first. Otherwise kernel won't be happy from 
userspace code such as:
fd = open("path_to_the_debug_file", O_RDWR);
write(fd, 1234 or NULL or whatever meaningless, 1);

Also you don't need to call strncmp, strcmp is OK (you can rely on dbg_info.name 
being null terminated and also the static strings such as "disable" are...) and 
shorter.

Microoptimisation is to put "break" right after it:

 > +			sc->debug.level ^= dbg_info[i].level; /* toggle bit */

but it's not mandatory at all.

thanks,
--js

  reply	other threads:[~2008-01-19 10:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-18 12:50 [PATCH 1/4] ath5k: debug level improvements Bruno Randolf
2008-01-18 12:50 ` [PATCH 2/4] ath5k: always extend rx timestamp with tsf Bruno Randolf
2008-01-19 22:20   ` Luis R. Rodriguez
2008-01-20  2:12     ` [ath5k-devel] " Derek Smithies
2008-01-18 12:51 ` [PATCH 3/4] ath5k: use 3 instead of 0x00000003 Bruno Randolf
2008-01-19 22:24   ` Luis R. Rodriguez
2008-01-22  1:36   ` Nick Kossifidis
2008-01-18 12:51 ` [PATCH 4/4] ath5k: beacon interval is in TU Bruno Randolf
2008-01-19 22:42   ` Luis R. Rodriguez
2008-01-22  1:29   ` Nick Kossifidis
2008-01-18 12:55 ` [PATCH 1/4] ath5k: debug level improvements Jiri Slaby
2008-01-19  2:43   ` bruno randolf
2008-01-18 23:26 ` Luis R. Rodriguez
2008-01-19  2:47   ` bruno randolf
2008-01-19  2:49     ` [PATCH] " Bruno Randolf
2008-01-19 10:21       ` Jiri Slaby [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-01-23  1:27 Bruno Randolf

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=4791CF2B.7090604@gmail.com \
    --to=jirislaby@gmail.com \
    --cc=ath5k-devel@lists.ath5k.org \
    --cc=bruno@thinktube.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=mcgrof@gmail.com \
    --cc=mickflemm@gmail.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).