public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Davidlohr Bueso <dave@gnu.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kay.sievers@vrfy.org, gregkh@suse.de
Subject: Re: [PATCH] kernel/ksysfs: use snprintf for sysfs show
Date: Wed, 11 Aug 2010 15:05:15 +0100	[thread overview]
Message-ID: <20100811140515.GH31363@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1281534250.2067.14.camel@cowboy>

On Wed, Aug 11, 2010 at 09:44:10AM -0400, Davidlohr Bueso wrote:
> Use snprintf(buf, PAGE_SIZE, ...) instead of sprintf for sysfs show
> methods.  This is suggested in Documentation/filesystems/sysfs.txt

... therefore it must be done, the common sense be damned.

> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
> ---

>  static ssize_t uevent_seqnum_show(struct kobject *kobj,
>  				  struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%llu\n", (unsigned long long)uevent_seqnum);
> +	return snprintf(buf, PAGE_SIZE, "%llu\n", 
> +			(unsigned long long)uevent_seqnum); 

A-yup - that's an improvement, all right, on them evil boxen that got
long long so huge that its decimal representation won't fit into a page.

NAK.  Cargo-cult programming is bad.

  reply	other threads:[~2010-08-11 14:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-11 13:44 [PATCH] kernel/ksysfs: use snprintf for sysfs show Davidlohr Bueso
2010-08-11 14:05 ` Al Viro [this message]
2010-08-11 15:21 ` Greg KH

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=20100811140515.GH31363@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=dave@gnu.org \
    --cc=gregkh@suse.de \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@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