From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 303B6ECE58C for ; Fri, 11 Oct 2019 14:24:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 07AA621A4A for ; Fri, 11 Oct 2019 14:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570803874; bh=QAb4bxoTz2iQy8IO0iLYwBX2ij2Bqz40OXibaGp0LAE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=KtuHL22eMed2bkNgAZnN07n2FYw9vJvkFgt3x0IDKOp5kkBTNNAFkdWoPrwA4111C 9ngd9YK+Ivh9/oYqBDknMtxlHPCAI5vlrTSMWOjWnKYKLvZ3ddcH5hp95vALLI8baQ 5iPplKisWFc1zapelVwsA1RYQ4B2p/RwY2Z73rjw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728179AbfJKOYd (ORCPT ); Fri, 11 Oct 2019 10:24:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:36378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728068AbfJKOYd (ORCPT ); Fri, 11 Oct 2019 10:24:33 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 97B4F206A1; Fri, 11 Oct 2019 14:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570803872; bh=QAb4bxoTz2iQy8IO0iLYwBX2ij2Bqz40OXibaGp0LAE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uiM7sMCFSjxUZ8NgAbCBCUdtgurhfH0Ka5EmsYcs/zeD7OGnInylw6oUN60nffJ1n 0FqG46kIjiBOagecYOUMvejBlvompnZuw6xAu4X+92OWzdCnyhWPNa29+nFj5+MbeD 2AaDOlzJArudhaSe7jQZKduYIke8HXwRBQrp4ET8= Date: Fri, 11 Oct 2019 15:24:27 +0100 From: Will Deacon To: Matthias Maennich Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, Jessica Yu , Masahiro Yamada , Martijn Coenen , Lucas De Marchi , Shaun Ruffell , Greg Kroah-Hartman , linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org Subject: Re: [PATCH 1/4] modpost: delegate updating namespaces to separate function Message-ID: <20191011142426.vwfhw4dtyy4nfzkv@willie-the-truck> References: <20191010151443.7399-1-maennich@google.com> <20191010151443.7399-2-maennich@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191010151443.7399-2-maennich@google.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: On Thu, Oct 10, 2019 at 04:14:40PM +0100, Matthias Maennich wrote: > Let the function 'sym_update_namespace' take care of updating the > namespace for a symbol. While this currently only replaces one single > location where namespaces are updated, in a following patch, this > function will get more call sites. > > The function signature is intentionally close to sym_update_crc and > taking the name by char* seems like unnecessary work as the symbol has > to be looked up again. In a later patch of this series, this concern > will be addressed. > > This function ensures that symbol::namespace is either NULL or has a > valid non-empty value. Previously, the empty string was considered 'no > namespace' as well and this lead to confusion. > > Signed-off-by: Matthias Maennich > --- > scripts/mod/modpost.c | 21 ++++++++++++++++++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index 4d2cdb4d71e3..9f5dcdff4d2f 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -362,6 +362,22 @@ static char *sym_extract_namespace(const char **symname) > return namespace; > } > > +static void sym_update_namespace(const char *symname, const char *namespace) > +{ > + struct symbol *s = find_symbol(symname); > + /* That symbol should have been created earlier and thus this is > + * actually an assertion. */ > + if (!s) { > + merror("Could not update namespace(%s) for symbol %s\n", > + namespace, symname); > + return; > + } > + > + free(s->namespace); > + s->namespace = > + namespace && namespace[0] ? NOFAIL(strdup(namespace)) : NULL; > +} You made me look up C operator precedence again, but it's fine so: Acked-by: Will Deacon Will