linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] suppress warning about unused nowarn variable
@ 2017-06-06 12:17 Corentin Labbe
  2017-06-06 12:17 ` [PATCH v2 1/2] kernel/module.c: Invert add_usage_link and del_usage_link functions Corentin Labbe
  2017-06-06 12:17 ` [PATCH v2 2/2] kernel/module.c: suppress warning about unused nowarn variable Corentin Labbe
  0 siblings, 2 replies; 6+ messages in thread
From: Corentin Labbe @ 2017-06-06 12:17 UTC (permalink / raw)
  To: jeyu, rusty; +Cc: linux-kernel, Corentin Labbe

Hello                                                                           
                                                                                
This patch serie suppress the following warning:                                
kernel/module.c: In function 'add_usage_links':                                 
kernel/module.c:1653:6: warning: variable 'nowarn' set but not used [-Wunused-but-set-variable]
                                                                                
Changes since v1:                                                               
- renamed out_unreg_usage_links to out_unreg_modinfo_attrs                      
- added extra newline
- added missing call to del_usage_link() in case of add_usage_link() error      
- added patch #1

Corentin Labbe (2):
  kernel/module.c: Invert add_usage_link and del_usage_link functions
  kernel/module.c: suppress warning about unused nowarn variable

 kernel/module.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

-- 
2.13.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] kernel/module.c: Invert add_usage_link and del_usage_link functions
  2017-06-06 12:17 [PATCH v2 0/2] suppress warning about unused nowarn variable Corentin Labbe
@ 2017-06-06 12:17 ` Corentin Labbe
  2017-06-19 16:26   ` Jessica Yu
  2017-06-06 12:17 ` [PATCH v2 2/2] kernel/module.c: suppress warning about unused nowarn variable Corentin Labbe
  1 sibling, 1 reply; 6+ messages in thread
From: Corentin Labbe @ 2017-06-06 12:17 UTC (permalink / raw)
  To: jeyu, rusty; +Cc: linux-kernel, Corentin Labbe

This patch just swap del_usage_link() before add_usage_link().

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 kernel/module.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index e3e9dbba6a5b..983b81f6d4ba 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1663,29 +1663,29 @@ static inline void remove_notes_attrs(struct module *mod)
 }
 #endif /* CONFIG_KALLSYMS */
 
-static void add_usage_links(struct module *mod)
+static void del_usage_links(struct module *mod)
 {
 #ifdef CONFIG_MODULE_UNLOAD
 	struct module_use *use;
-	int nowarn;
 
 	mutex_lock(&module_mutex);
-	list_for_each_entry(use, &mod->target_list, target_list) {
-		nowarn = sysfs_create_link(use->target->holders_dir,
-					   &mod->mkobj.kobj, mod->name);
-	}
+	list_for_each_entry(use, &mod->target_list, target_list)
+		sysfs_remove_link(use->target->holders_dir, mod->name);
 	mutex_unlock(&module_mutex);
 #endif
 }
 
-static void del_usage_links(struct module *mod)
+static void add_usage_links(struct module *mod)
 {
 #ifdef CONFIG_MODULE_UNLOAD
 	struct module_use *use;
+	int nowarn;
 
 	mutex_lock(&module_mutex);
-	list_for_each_entry(use, &mod->target_list, target_list)
-		sysfs_remove_link(use->target->holders_dir, mod->name);
+	list_for_each_entry(use, &mod->target_list, target_list) {
+		nowarn = sysfs_create_link(use->target->holders_dir,
+					   &mod->mkobj.kobj, mod->name);
+	}
 	mutex_unlock(&module_mutex);
 #endif
 }
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] kernel/module.c: suppress warning about unused nowarn variable
  2017-06-06 12:17 [PATCH v2 0/2] suppress warning about unused nowarn variable Corentin Labbe
  2017-06-06 12:17 ` [PATCH v2 1/2] kernel/module.c: Invert add_usage_link and del_usage_link functions Corentin Labbe
@ 2017-06-06 12:17 ` Corentin Labbe
  1 sibling, 0 replies; 6+ messages in thread
From: Corentin Labbe @ 2017-06-06 12:17 UTC (permalink / raw)
  To: jeyu, rusty; +Cc: linux-kernel, Corentin Labbe

This patch fix the following warning:
kernel/module.c: In function 'add_usage_links':
kernel/module.c:1653:6: warning: variable 'nowarn' set but not used [-Wunused-but-set-variable]

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 kernel/module.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 983b81f6d4ba..6b2592193730 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1675,19 +1675,24 @@ static void del_usage_links(struct module *mod)
 #endif
 }
 
-static void add_usage_links(struct module *mod)
+static int add_usage_links(struct module *mod)
 {
+	int ret = 0;
 #ifdef CONFIG_MODULE_UNLOAD
 	struct module_use *use;
-	int nowarn;
 
 	mutex_lock(&module_mutex);
 	list_for_each_entry(use, &mod->target_list, target_list) {
-		nowarn = sysfs_create_link(use->target->holders_dir,
-					   &mod->mkobj.kobj, mod->name);
+		ret = sysfs_create_link(use->target->holders_dir,
+					&mod->mkobj.kobj, mod->name);
+		if (ret)
+			break;
 	}
 	mutex_unlock(&module_mutex);
+	if (ret)
+		del_usage_links(mod);
 #endif
+	return ret;
 }
 
 static int module_add_modinfo_attrs(struct module *mod)
@@ -1798,13 +1803,18 @@ static int mod_sysfs_setup(struct module *mod,
 	if (err)
 		goto out_unreg_param;
 
-	add_usage_links(mod);
+	err = add_usage_links(mod);
+	if (err)
+		goto out_unreg_modinfo_attrs;
+
 	add_sect_attrs(mod, info);
 	add_notes_attrs(mod, info);
 
 	kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD);
 	return 0;
 
+out_unreg_modinfo_attrs:
+	module_remove_modinfo_attrs(mod);
 out_unreg_param:
 	module_param_sysfs_remove(mod);
 out_unreg_holders:
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] kernel/module.c: Invert add_usage_link and del_usage_link functions
  2017-06-06 12:17 ` [PATCH v2 1/2] kernel/module.c: Invert add_usage_link and del_usage_link functions Corentin Labbe
@ 2017-06-19 16:26   ` Jessica Yu
  2017-06-20  6:45     ` Corentin Labbe
  0 siblings, 1 reply; 6+ messages in thread
From: Jessica Yu @ 2017-06-19 16:26 UTC (permalink / raw)
  To: Corentin Labbe; +Cc: rusty, linux-kernel

+++ Corentin Labbe [06/06/17 14:17 +0200]:
>This patch just swap del_usage_link() before add_usage_link().
>
>Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>

Could you combine this with the 2nd patch? By itself this patch
doesn't tell us much. Additionally, could you explain in the changelog
(of the 2nd patch) why they needed to be swapped (i.e., so
del_usage_links() can be called from add_usage_links()).

Thanks!

Jessica

> kernel/module.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
>diff --git a/kernel/module.c b/kernel/module.c
>index e3e9dbba6a5b..983b81f6d4ba 100644
>--- a/kernel/module.c
>+++ b/kernel/module.c
>@@ -1663,29 +1663,29 @@ static inline void remove_notes_attrs(struct module *mod)
> }
> #endif /* CONFIG_KALLSYMS */
>
>-static void add_usage_links(struct module *mod)
>+static void del_usage_links(struct module *mod)
> {
> #ifdef CONFIG_MODULE_UNLOAD
> 	struct module_use *use;
>-	int nowarn;
>
> 	mutex_lock(&module_mutex);
>-	list_for_each_entry(use, &mod->target_list, target_list) {
>-		nowarn = sysfs_create_link(use->target->holders_dir,
>-					   &mod->mkobj.kobj, mod->name);
>-	}
>+	list_for_each_entry(use, &mod->target_list, target_list)
>+		sysfs_remove_link(use->target->holders_dir, mod->name);
> 	mutex_unlock(&module_mutex);
> #endif
> }
>
>-static void del_usage_links(struct module *mod)
>+static void add_usage_links(struct module *mod)
> {
> #ifdef CONFIG_MODULE_UNLOAD
> 	struct module_use *use;
>+	int nowarn;
>
> 	mutex_lock(&module_mutex);
>-	list_for_each_entry(use, &mod->target_list, target_list)
>-		sysfs_remove_link(use->target->holders_dir, mod->name);
>+	list_for_each_entry(use, &mod->target_list, target_list) {
>+		nowarn = sysfs_create_link(use->target->holders_dir,
>+					   &mod->mkobj.kobj, mod->name);
>+	}
> 	mutex_unlock(&module_mutex);
> #endif
> }
>-- 
>2.13.0
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] kernel/module.c: Invert add_usage_link and del_usage_link functions
  2017-06-19 16:26   ` Jessica Yu
@ 2017-06-20  6:45     ` Corentin Labbe
  2017-06-26 13:37       ` Jessica Yu
  0 siblings, 1 reply; 6+ messages in thread
From: Corentin Labbe @ 2017-06-20  6:45 UTC (permalink / raw)
  To: Jessica Yu; +Cc: rusty, linux-kernel

On Mon, Jun 19, 2017 at 06:26:23PM +0200, Jessica Yu wrote:
> +++ Corentin Labbe [06/06/17 14:17 +0200]:
> >This patch just swap del_usage_link() before add_usage_link().
> >
> >Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> 
> Could you combine this with the 2nd patch? By itself this patch
> doesn't tell us much. Additionally, could you explain in the changelog
> (of the 2nd patch) why they needed to be swapped (i.e., so
> del_usage_links() can be called from add_usage_links()).
> 
> Thanks!
> 
> Jessica
> 

I think that its against the rule of atomic/simple patch.
Perhaps, the first patch miss some "why I do it"

Anyway I will send a new version as you requested
Regards

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] kernel/module.c: Invert add_usage_link and del_usage_link functions
  2017-06-20  6:45     ` Corentin Labbe
@ 2017-06-26 13:37       ` Jessica Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Jessica Yu @ 2017-06-26 13:37 UTC (permalink / raw)
  To: Corentin Labbe; +Cc: rusty, linux-kernel

+++ Corentin Labbe [20/06/17 08:45 +0200]:
>On Mon, Jun 19, 2017 at 06:26:23PM +0200, Jessica Yu wrote:
>> +++ Corentin Labbe [06/06/17 14:17 +0200]:
>> >This patch just swap del_usage_link() before add_usage_link().
>> >
>> >Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
>>
>> Could you combine this with the 2nd patch? By itself this patch
>> doesn't tell us much. Additionally, could you explain in the changelog
>> (of the 2nd patch) why they needed to be swapped (i.e., so
>> del_usage_links() can be called from add_usage_links()).
>>
>> Thanks!
>>
>> Jessica
>>
>
>I think that its against the rule of atomic/simple patch.
>Perhaps, the first patch miss some "why I do it"
>
>Anyway I will send a new version as you requested

Hi Corentin,

I've folded the first patch with the second and applied them to
modules-next, no need to resend the patchset :)

Thanks!

Jessica

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-06-26 13:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-06 12:17 [PATCH v2 0/2] suppress warning about unused nowarn variable Corentin Labbe
2017-06-06 12:17 ` [PATCH v2 1/2] kernel/module.c: Invert add_usage_link and del_usage_link functions Corentin Labbe
2017-06-19 16:26   ` Jessica Yu
2017-06-20  6:45     ` Corentin Labbe
2017-06-26 13:37       ` Jessica Yu
2017-06-06 12:17 ` [PATCH v2 2/2] kernel/module.c: suppress warning about unused nowarn variable Corentin Labbe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).