Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5097750imu; Tue, 29 Jan 2019 12:44:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN5o2IG7tn+IL6ut3MHtmf0LGK1Tha6JHV1hnAs9oIA+sjcZetMvfCwxyMqQdPdyn5C1UlbH X-Received: by 2002:a17:902:a5ca:: with SMTP id t10mr27425539plq.139.1548794673827; Tue, 29 Jan 2019 12:44:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548794673; cv=none; d=google.com; s=arc-20160816; b=UJYduHgC81/7OpNfOM3aGcYP6O/FFXqO3jFmXn3MdVeHKROJCgkVka6uob1wA1uyR/ wJAb/n9CWthiBXE7j3LUPaM1Uz20iFX0y4/QGT64YfTFCUQTCReoQ77tf121pAEeG66W L6HG7NNrxaDRTCL7s/lu1sE5EBKYVP8aIa+txOAijwW/L0pm7/UqcLW26k9K69UbT6h7 lHYyFvVKPIgCBSI9qwVxe4oERI/0dB2dvAi4yvQJsV09RCoicWoojgU28HOHyKZsVyd7 HO779Gwjsb0aVIj5946gvBYwPrqBWq9Z4C/3zlH6TlgJ/43MiFgHMafYhV/AVk6WciES EBTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=jy9fX9SViyQbDhikabvZ+j8G5aoJaRQ8b+JqX5TqWXU=; b=w66UQ1zWYlLPorAXrvVxqUthSP069/Xw+W321vj1oBwnad7GSS+Dzc9/QCe0nuoF5X BkCixIDORbpsCzaAlFRJis9PWEXnKDGE5dC83TETLt27E2xIyu6UIKhuF0HM/vaHGIlQ wiAArWqysSXEjV654oHb2fttaEBRfpUzXif/EsbJk0hG6UahKOL3Nmvk2sffndvOZU1T hzhQlYO1buWIIgqhJYpTTJC9ts/YN7Ga3msHeVCHg78ixcaEyAIHNrTIIvZtJEubg1Jw HikglbdbMkabUc6i9pdYuzyVqHT6hAQN0GTki+XP11fMr2NQrh1YBaHeXkQhlahC9WLc 68GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32si17058009plg.29.2019.01.29.12.44.18; Tue, 29 Jan 2019 12:44:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729419AbfA2Un2 (ORCPT + 99 others); Tue, 29 Jan 2019 15:43:28 -0500 Received: from mga03.intel.com ([134.134.136.65]:36936 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbfA2Un2 (ORCPT ); Tue, 29 Jan 2019 15:43:28 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jan 2019 12:43:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,538,1539673200"; d="scan'208";a="129558974" Received: from jekeller-desk.amr.corp.intel.com ([10.166.244.182]) by FMSMGA003.fm.intel.com with ESMTP; 29 Jan 2019 12:43:26 -0800 From: Jacob Keller To: linux-kernel@vger.kernel.org Cc: Intel Wired LAN , Jacob Keller Subject: [PATCH] namespace: fix namespace.pl script to support relative paths Date: Tue, 29 Jan 2019 12:43:19 -0800 Message-Id: <20190129204319.15238-1-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.18.0.219.gaf81d287a9da Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The namespace.pl script does not work properly if objtree is not set to an absolute path. The do_nm function is run from within the find function, which changes directories. Because of this, appending objtree, $File::Find::dir, and $source, will return a path which is not valid from the current directory. This used to work when objtree was set to an absolute path when using "make namespacecheck". It appears to have not worked when calling ./scripts/namespace.pl directly. This behavior was changed in 7e1c04779efd ("kbuild: Use relative path for $(objtree)", 2014-05-14) Rather than fixing the Makefile to set objtree to an absolute path, just fix namespace.pl to work when srctree and objtree are relative. Also fix the script to use an absolute path for these by default. Use the File::Spec module for this purpose. It's been part of perl 5 since 5.005. The curdir() function is used to get the current directory when the objtree and srctree aren't set in the environment. rel2abs() is used to convert possibly relative objtree and srctree environment variables to absolute paths. Finally, the catfile() function is used instead of string appending paths together, since this is more robust when joining paths together. Signed-off-by: Jacob Keller --- scripts/namespace.pl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/namespace.pl b/scripts/namespace.pl index 6135574a6f39..1da7bca201a4 100755 --- a/scripts/namespace.pl +++ b/scripts/namespace.pl @@ -65,13 +65,14 @@ use warnings; use strict; use File::Find; +use File::Spec; my $nm = ($ENV{'NM'} || "nm") . " -p"; my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment"; -my $srctree = ""; -my $objtree = ""; -$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'})); -$objtree = "$ENV{'objtree'}/" if (exists($ENV{'objtree'})); +my $srctree = File::Spec->curdir(); +my $objtree = File::Spec->curdir(); +$srctree = File::Spec->rel2abs($ENV{'srctree'}) if (exists($ENV{'srctree'})); +$objtree = File::Spec->rel2abs($ENV{'objtree'}) if (exists($ENV{'objtree'})); if ($#ARGV != -1) { print STDERR "usage: $0 takes no parameters\n"; @@ -231,9 +232,9 @@ sub do_nm } ($source = $basename) =~ s/\.o$//; if (-e "$source.c" || -e "$source.S") { - $source = "$objtree$File::Find::dir/$source"; + $source = File::Spec->catfile($objtree, $File::Find::dir, $source) } else { - $source = "$srctree$File::Find::dir/$source"; + $source = File::Spec->catfile($srctree, $File::Find::dir, $source) } if (! -e "$source.c" && ! -e "$source.S") { # No obvious source, exclude the object if it is conglomerate -- 2.18.0.219.gaf81d287a9da