Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750981AbbFLBoM (ORCPT ); Thu, 11 Jun 2015 21:44:12 -0400 Received: from ozlabs.org ([103.22.144.67]:37385 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750891AbbFLBoF (ORCPT ); Thu, 11 Jun 2015 21:44:05 -0400 From: Rusty Russell To: Linus Torvalds , Tejun Heo Cc: Louis Langholtz , Linux Kernel Mailing List , trivial@kernel.org, Andrew Morton Subject: Re: [PATCH] kernel/params.c: make use of unused but set variable In-Reply-To: References: <1433721270-9182-1-git-send-email-lou_langholtz@me.com> <20150608000007.GA3543@mtj.duckdns.org> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.4.1 (x86_64-pc-linux-gnu) Date: Fri, 12 Jun 2015 10:57:24 +0930 Message-ID: <87zj45g1hf.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1510 Lines: 40 Linus Torvalds writes: > On Sun, Jun 7, 2015 at 5:00 PM, Tejun Heo wrote: > At most, it could be a "WARN_ON_ONCE()". Maybe even just silently > ignore the error. But BUG_ON()? Hell no. Yeah, in practice it's already (1) paniced if we ran out of memory, or (2) warned if we somehow tried to create two entries with the same name. So the WARN_ON_ONCE() is a bit... meh. How's this, too snarky? Thanks, Rusty. Subject: params: suppress unused variable error, warn once just in case code changes. Reported-by: Louis Langholtz Signed-off-by: Rusty Russell diff --git a/kernel/params.c b/kernel/params.c index 7edf31f2ce96..0b9bbdf830cb 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -884,6 +884,12 @@ static void __init version_sysfs_builtin(void) mk = locate_module_kobject(vattr->module_name); if (mk) { err = sysfs_create_file(&mk->kobj, &vattr->mattr.attr); + /* + * That should not fail at boot due to OOM, and it'll + * already warn if we somehow get two identical names, + * but this one line should quiet both gcc and lkml. + */ + WARN_ON_ONCE(err); kobject_uevent(&mk->kobj, KOBJ_ADD); kobject_put(&mk->kobj); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/