mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: domen@coderock.org
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org,
	Jan Veldeman <Jan.Veldeman@advalvas.be>,
	domen@coderock.org
Subject: [patch 3/5] Driver core: Documentation: use snprintf and strnlen
Date: Sun, 31 Jul 2005 13:12:08 +0200	[thread overview]
Message-ID: <20050731111213.636613000@homer> (raw)

[-- Attachment #1: fixup-Documentation_filesystems_sysfs.txt --]
[-- Type: text/plain, Size: 1109 bytes --]

From: Jan Veldeman <jan@mind.be>



Documentation should give the good example of using snprintf and
strnlen in stead of sprintf and strlen.

PAGE_SIZE is used as the maximal length to reflect the behaviour of
show/store.


Signed-off-by: Jan Veldeman <Jan.Veldeman@advalvas.be>
Signed-off-by: Domen Puncer <domen@coderock.org>


---
 sysfs.txt |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Index: quilt/Documentation/filesystems/sysfs.txt
===================================================================
--- quilt.orig/Documentation/filesystems/sysfs.txt
+++ quilt/Documentation/filesystems/sysfs.txt
@@ -216,13 +216,13 @@ A very simple (and naive) implementation
 
 static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
 {
-        return sprintf(buf,"%s\n",dev->name);
+        return snprintf(buf,PAGE_SIZE,"%s\n",dev->name);
 }
 
 static ssize_t store_name(struct device * dev, const char * buf)
 {
 	sscanf(buf,"%20s",dev->name);
-	return strlen(buf);
+	return strnlen(buf,PAGE_SIZE);
 }
 
 static DEVICE_ATTR(name,S_IRUGO,show_name,store_name);

--

             reply	other threads:[~2005-07-31 11:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-31 11:12 domen [this message]
2005-07-31 18:25 ` Ingo Oeser
2005-08-01  8:50   ` Jan Veldeman

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=20050731111213.636613000@homer \
    --to=domen@coderock.org \
    --cc=Jan.Veldeman@advalvas.be \
    --cc=akpm@osdl.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

Powered by JetHome