From: Andrew Morton <akpm@osdl.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
LHMS <lhms-devel@lists.sourceforge.net>
Subject: Re: [PATHC] [2.6.19-rc4-mm2] driver/base/memory.c :: remove warnings of sysfs_create_file()
Date: Wed, 8 Nov 2006 13:38:59 -0800 [thread overview]
Message-ID: <20061108133859.cdaa8127.akpm@osdl.org> (raw)
In-Reply-To: <20061108155921.62f9a68f.kamezawa.hiroyu@jp.fujitsu.com>
On Wed, 8 Nov 2006 15:59:21 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> I got following messages at compile time.
> ==
> drivers/base/memory.c: In function `memory_dev_init':
> drivers/base/memory.c:293: warning: ignoring return value of `sysfs_create_file'
> , declared with attribute warn_unused_result
> ==
>
> This patch adds tests for returned value from sysfs_create_file().
> This patch just prints warning if failed.
>
> Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> Index: linux-2.6.19-rc4-mm2/drivers/base/memory.c
> ===================================================================
> --- linux-2.6.19-rc4-mm2.orig/drivers/base/memory.c 2006-11-08 15:15:59.000000000 +0900
> +++ linux-2.6.19-rc4-mm2/drivers/base/memory.c 2006-11-08 15:26:52.000000000 +0900
> @@ -290,8 +290,14 @@
>
> static int block_size_init(void)
> {
> - sysfs_create_file(&memory_sysdev_class.kset.kobj,
> - &class_attr_block_size_bytes.attr);
> + int ret;
> + ret = sysfs_create_file(&memory_sysdev_class.kset.kobj,
> + &class_attr_block_size_bytes.attr);
> + if (ret < 0) {
> + /* We failed to init memory-hotplug infrastructure.
> + But don't panic here */
> + printk(KERN_WARNING "cannot create memory hotplug interface\n");
> + }
> return 0;
> }
>
> @@ -323,8 +329,14 @@
>
> static int memory_probe_init(void)
> {
> - sysfs_create_file(&memory_sysdev_class.kset.kobj,
> + int ret;
> + ret = sysfs_create_file(&memory_sysdev_class.kset.kobj,
> &class_attr_probe.attr);
> + if (ret < 0) {
> + /* we failed to init memory hotplug infrastructure.
> + But don't panic here */
> + printk(KERN_WARNING "cannot create memory hotplug interface\n");
> + }
> return 0;
> }
> #else
I think the below is better?
From: Andrew Morton <akpm@osdl.org>
Do proper error-checking and propagation in drivers/base/memory.c, hence fix
__must_check warnings.
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---
drivers/base/memory.c | 34 +++++++++++++++++++++++-----------
1 files changed, 23 insertions(+), 11 deletions(-)
diff -puN drivers/base/memory.c~driver-base-memoryc-remove-warnings-of drivers/base/memory.c
--- a/drivers/base/memory.c~driver-base-memoryc-remove-warnings-of
+++ a/drivers/base/memory.c
@@ -290,9 +290,8 @@ static CLASS_ATTR(block_size_bytes, 0444
static int block_size_init(void)
{
- sysfs_create_file(&memory_sysdev_class.kset.kobj,
- &class_attr_block_size_bytes.attr);
- return 0;
+ return sysfs_create_file(&memory_sysdev_class.kset.kobj,
+ &class_attr_block_size_bytes.attr);
}
/*
@@ -323,12 +322,14 @@ static CLASS_ATTR(probe, 0700, NULL, mem
static int memory_probe_init(void)
{
- sysfs_create_file(&memory_sysdev_class.kset.kobj,
- &class_attr_probe.attr);
- return 0;
+ return sysfs_create_file(&memory_sysdev_class.kset.kobj,
+ &class_attr_probe.attr);
}
#else
-#define memory_probe_init(...) do {} while (0)
+static inline int memory_probe_init(void)
+{
+ return 0;
+}
#endif
/*
@@ -431,9 +432,12 @@ int __init memory_dev_init(void)
{
unsigned int i;
int ret;
+ int err;
memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops;
ret = sysdev_class_register(&memory_sysdev_class);
+ if (ret)
+ goto out;
/*
* Create entries for memory sections that were found
@@ -442,11 +446,19 @@ int __init memory_dev_init(void)
for (i = 0; i < NR_MEM_SECTIONS; i++) {
if (!valid_section_nr(i))
continue;
- add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0);
+ err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0);
+ if (!ret)
+ ret = err;
}
- memory_probe_init();
- block_size_init();
-
+ err = memory_probe_init();
+ if (!ret)
+ ret = err;
+ err = block_size_init();
+ if (!ret)
+ ret = err;
+out:
+ if (ret)
+ printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret);
return ret;
}
_
next prev parent reply other threads:[~2006-11-08 21:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-08 6:59 KAMEZAWA Hiroyuki
2006-11-08 21:38 ` Andrew Morton [this message]
2006-11-09 13:18 ` KAMEZAWA Hiroyuki
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=20061108133859.cdaa8127.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=lhms-devel@lists.sourceforge.net \
--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
all inboxes | Powered by JetHome®