mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "André Goddard Rosa" <andre.goddard@gmail.com>
To: Greg Kroah-Hartman <gregkh@suse.de>, Alex Chiang <achiang@hp.com>,
	Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
	Serge Hallyn <serue@us.ibm.com>, Tejun Heo <tj@kernel.org>,
	linux-kernel@vger.kernel.org
Cc: "André Goddard Rosa" <andre.goddard@gmail.com>
Subject: [PATCH] sysfs/file: move NULL checks to where they make sense and can occur
Date: Fri,  5 Mar 2010 07:46:00 -0300	[thread overview]
Message-ID: <2fcd155e7b67ba2d41de0a5a0751b3091bf849d8.1267785770.git.andre.goddard@gmail.com> (raw)

... avoiding checking for NULL 2 times in a row when we already have a page.

It decreases code size:
text    data     bss     dec     hex filename
4246      48    4136    8430    20ee fs/sysfs/file-BEFORE.o
4214      48    4136    8398    20ce fs/sysfs/file-AFTER.o

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
---
 fs/sysfs/file.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index dc30d9e..962b190 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -79,10 +79,11 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
 	int ret = 0;
 	ssize_t count;
 
-	if (!buffer->page)
-		buffer->page = (char *) get_zeroed_page(GFP_KERNEL);
-	if (!buffer->page)
-		return -ENOMEM;
+	if (!buffer->page) {
+		buffer->page = (char *)get_zeroed_page(GFP_KERNEL);
+		if (!buffer->page)
+			return -ENOMEM;
+	}
 
 	/* need attr_sd for attr and ops, its parent for kobj */
 	if (!sysfs_get_active_two(attr_sd))
@@ -167,10 +168,11 @@ fill_write_buffer(struct sysfs_buffer * buffer, const char __user * buf, size_t
 {
 	int error;
 
-	if (!buffer->page)
+	if (!buffer->page) {
 		buffer->page = (char *)get_zeroed_page(GFP_KERNEL);
-	if (!buffer->page)
-		return -ENOMEM;
+		if (!buffer->page)
+			return -ENOMEM;
+	}
 
 	if (count >= PAGE_SIZE)
 		count = PAGE_SIZE - 1;
-- 
1.7.0.1.164.gbe2f


             reply	other threads:[~2010-03-06 10:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-05 10:46 André Goddard Rosa [this message]
2010-03-09  7:38 ` Tejun Heo
2010-03-09 11:58   ` André Goddard Rosa

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=2fcd155e7b67ba2d41de0a5a0751b3091bf849d8.1267785770.git.andre.goddard@gmail.com \
    --to=andre.goddard@gmail.com \
    --cc=achiang@hp.com \
    --cc=gregkh@suse.de \
    --cc=kaneshige.kenji@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serue@us.ibm.com \
    --cc=tj@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

all inboxes | Powered by JetHome®