From patchwork Fri Oct 18 20:22:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Moyer X-Patchwork-Id: 11199563 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F12919A1 for ; Fri, 18 Oct 2019 20:23:16 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57972222C2 for ; Fri, 18 Oct 2019 20:23:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57972222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from new-ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5879B10FCB90A; Fri, 18 Oct 2019 13:25:19 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=jmoyer@redhat.com; receiver= Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9DAA610FCB903 for ; Fri, 18 Oct 2019 13:25:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1F3430833CB for ; Fri, 18 Oct 2019 20:23:08 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C5C2D600C1; Fri, 18 Oct 2019 20:23:08 +0000 (UTC) Received: by segfault.boston.devel.redhat.com (Postfix, from userid 3734) id C6BDA21C9AD0; Fri, 18 Oct 2019 16:23:07 -0400 (EDT) From: Jeff Moyer To: linux-nvdimm@lists.01.org Cc: Jeff Moyer Subject: [ndctl patch 1/4] util/abspath: cleanup prefix_filename Date: Fri, 18 Oct 2019 16:22:59 -0400 Message-Id: <20191018202302.8122-2-jmoyer@redhat.com> In-Reply-To: <20191018202302.8122-1-jmoyer@redhat.com> References: <20191018202302.8122-1-jmoyer@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 18 Oct 2019 20:23:08 +0000 (UTC) Message-ID-Hash: N46UR2VWPVFJEYZ6UUJU3ECP672X6XBN X-Message-ID-Hash: N46UR2VWPVFJEYZ6UUJU3ECP672X6XBN X-MailFrom: jmoyer@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Static checkers complain about the unused assignment to pfx_len. The code can obviously be simplified. Signed-off-by: Jeff Moyer Reviewed-by: Ira Weiny --- util/abspath.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/util/abspath.c b/util/abspath.c index 09bbd27..e44236f 100644 --- a/util/abspath.c +++ b/util/abspath.c @@ -9,11 +9,7 @@ char *prefix_filename(const char *pfx, const char *arg) struct strbuf path = STRBUF_INIT; size_t pfx_len = pfx ? strlen(pfx) : 0; - if (!pfx_len) - ; - else if (is_absolute_path(arg)) - pfx_len = 0; - else + if (pfx_len && !is_absolute_path(arg)) strbuf_add(&path, pfx, pfx_len); strbuf_addstr(&path, arg);