All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kalle Valo <kalle.valo@nokia.com>
To: bruno randolf <bruno@thinktube.com>
Cc: ath5k-devel@lists.ath5k.org, mcgrof@gmail.com,
	jirislaby@gmail.com, mickflemm@gmail.com,
	linux-wireless@vger.kernel.org, linville@tuxdriver.com
Subject: Re: [PATCH 1/2] ath5k: debug level improvements
Date: Mon, 21 Jan 2008 09:20:36 +0200	[thread overview]
Message-ID: <87fxwrfxvf.fsf@nokia.com> (raw)
In-Reply-To: <200801211607.25360.bruno@thinktube.com> (ext bruno randolf's message of "Mon\, 21 Jan 2008 16\:07\:25 +0900")

bruno randolf <bruno@thinktube.com> writes:

> On Monday 21 January 2008 15:44:46 Kalle Valo wrote:
>> > +	char buf[20];
>> > +
>> > +	if (copy_from_user(buf, userbuf, min_t(size_t, count, 20)))
>> > +		return -EFAULT;
>>
>> How about let the compiler count the size of buf? Like this:
>>
>> if (copy_from_user(buf, userbuf, min_t(size_t, count, sizeof(buf))))
>>
>> That way the size of buf is only in one place, and we might avoid a
>> bug whenever someone changes the size of buf.
>
> good idea. that way i can also get rid of min_t(size_t,...) and use min().

Even better.

>> > +static ssize_t read_file_debug(struct file *file, char __user *user_buf,
>> > +				   size_t count, loff_t *ppos)
>> > +{
>> > +	struct ath5k_softc *sc = file->private_data;
>> > +	char buf[1000];
>>
>> To my eyes allocating 1000 bytes from stack is too large.
>
> what about 700? ;) 
> the output currently is 626 byte.

Hehe :) I have no idea what's the preferred limit here, so I cannot
you give a definitive answer. But I would guess that 700 byte
allocation is still sensible with 4k stacks.

But this is for a debug interface so most likely this doesn't matter
that much.

-- 
Kalle Valo

      reply	other threads:[~2008-01-21  7:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-21  2:09 [PATCH 1/2] ath5k: debug level improvements Bruno Randolf
2008-01-21  2:09 ` [PATCH 2/2] ath5k: always extend rx timestamp with tsf Bruno Randolf
2008-01-21  2:16   ` Luis R. Rodriguez
2008-01-22  1:35   ` Nick Kossifidis
2008-01-21  6:44 ` [PATCH 1/2] ath5k: debug level improvements Kalle Valo
2008-01-21  7:07   ` bruno randolf
2008-01-21  7:20     ` Kalle Valo [this message]

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=87fxwrfxvf.fsf@nokia.com \
    --to=kalle.valo@nokia.com \
    --cc=ath5k-devel@lists.ath5k.org \
    --cc=bruno@thinktube.com \
    --cc=jirislaby@gmail.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 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.