Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751184AbdFFGjG (ORCPT ); Tue, 6 Jun 2017 02:39:06 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35958 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750755AbdFFGjF (ORCPT ); Tue, 6 Jun 2017 02:39:05 -0400 Date: Tue, 6 Jun 2017 08:38:59 +0200 From: Corentin Labbe To: Jessica Yu Cc: rusty@rustcorp.com.au, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel/module.c: fix warning about unused nowarn variable Message-ID: <20170606063859.GB23763@Red> References: <20170602120511.23112-1-clabbe.montjoie@gmail.com> <20170606050923.jnbqr6c53b4wjrpe@jeyu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170606050923.jnbqr6c53b4wjrpe@jeyu> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1494 Lines: 43 On Mon, Jun 05, 2017 at 10:09:24PM -0700, Jessica Yu wrote: > +++ Corentin Labbe [02/06/17 14:05 +0200]: > >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] > > int nowarn; > > > >Signed-off-by: Corentin Labbe > >--- > > kernel/module.c | 13 +++++++++---- > > 1 file changed, 9 insertions(+), 4 deletions(-) > > > >diff --git a/kernel/module.c b/kernel/module.c > >index e3e9dbba6a5b..aed902bcb4aa 100644 > >--- a/kernel/module.c > >+++ b/kernel/module.c > >@@ -1663,19 +1663,20 @@ static inline void remove_notes_attrs(struct module *mod) > > } > > #endif /* CONFIG_KALLSYMS */ > > > >-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, > >+ ret = sysfs_create_link(use->target->holders_dir, > > &mod->mkobj.kobj, mod->name); > > ret will get overwritten with each iteration of the loop; we should return > ret as soon as we hit an error (while making sure we unlock > module_mutex). > Thanks, I will fix all reported errors. I just found also that in case of error, I need to "del_usage_links" Regards