Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751117AbdFFFJ1 (ORCPT ); Tue, 6 Jun 2017 01:09:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53170 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750734AbdFFFJ0 (ORCPT ); Tue, 6 Jun 2017 01:09:26 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ABA3885540 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jeyu@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ABA3885540 Date: Mon, 5 Jun 2017 22:09:24 -0700 From: Jessica Yu To: Corentin Labbe Cc: rusty@rustcorp.com.au, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel/module.c: fix warning about unused nowarn variable Message-ID: <20170606050923.jnbqr6c53b4wjrpe@jeyu> References: <20170602120511.23112-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20170602120511.23112-1-clabbe.montjoie@gmail.com> X-OS: Linux jeyu 4.8.0+ x86_64 User-Agent: NeoMutt/20161126 (1.7.1) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 06 Jun 2017 05:09:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1994 Lines: 74 +++ 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). > } > mutex_unlock(&module_mutex); > #endif >+ return ret; > } > > static void del_usage_links(struct module *mod) >@@ -1798,13 +1799,17 @@ 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_usage_links; Small nitpick: could you add an extra newline here? > add_sect_attrs(mod, info); > add_notes_attrs(mod, info); > > kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD); > return 0; > >+out_unreg_usage_links: Can you rename this to `out_unreg_modinfo_attrs` (to better reflect what's being done)? >+ module_remove_modinfo_attrs(mod); > out_unreg_param: > module_param_sysfs_remove(mod); > out_unreg_holders: Thanks, Jessica