Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2184234iof; Tue, 7 Jun 2022 22:29:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA//elBdSQNgjLshur/k0ulPTaqYHM3PNlfMDaM7NEJz1VmKYWgpwKDZ1AYDM0+MA7w82r X-Received: by 2002:a17:902:f64c:b0:156:4349:7e9b with SMTP id m12-20020a170902f64c00b0015643497e9bmr32987729plg.139.1654666194053; Tue, 07 Jun 2022 22:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666194; cv=none; d=google.com; s=arc-20160816; b=DZXGu8+Bw+wHB2FbdeByxzKBeD6ht/+Q59EpkI9decS+qh/XAQIPdcdoqkCoOn6Le0 JfRYnB+0mFeKGPq2HPqNKhnuDhxrXGqxySKx1sRtJHi505cR5MNhLnkIRr4vIHp+7e9b RjO8B9Dlhfan3juwW4wv73Ido84P+ycVTEWpaKJ3bdxYhQkd+hpBDEQvMWN+szxPhHrb dThmE34Y+aYs+2dThF4Hpr4s23le1o23AFSvNlO11rhWM/+IXD548cLYWDa5Dv12CuTN cFORpvY1ltuliCGxb5R4/CjuAJ01Rw72257p7RJo1sdLAwc1V20nTc/y4gCBqXj6V3hx 4sDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=MfDmQCm4f6pHwXB7F34rvZzsnk1dV2UMp3pRthm7Jis=; b=Np9mh/YwBFdkGZi8thx6uTnMBtKt+afd2Tk+7cWKhjQTXeEzTLy7cqG3V2znBsVQVl 7VOPcmqV+rv76vILTejaSdR0og9v9o53mYe0tTDOCeGMKAm2N99KmuA3LqByNfIzERyJ aUuT2IUGykG8+DazTKbE8sz6pPA0cKbUw4itOmjGkqTFUbD5IFpneH0QWq6D0QV2GWP+ 1vHbvKdS5NnBvUE0my5XUUzfa6bkQvWttgVVYogZ8Z61tyxv9PhPOXcoBNPhgjiKI9HG BdPrpqKTp7GLxs28CnUdRpBEeUE/RzR4yXyYK77hkTMbRmho3jwc37JJA1RfLp6pTzbr SoFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bG0Mygdr; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k7-20020a63f007000000b003fc5ec6377asi27171868pgh.385.2022.06.07.22.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:29:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bG0Mygdr; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 86E3C48CBB9; Tue, 7 Jun 2022 21:58:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344514AbiFGP5C (ORCPT + 99 others); Tue, 7 Jun 2022 11:57:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344453AbiFGPyy (ORCPT ); Tue, 7 Jun 2022 11:54:54 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86A5413D72 for ; Tue, 7 Jun 2022 08:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654617293; x=1686153293; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Zq4qMj7BmV5+vvcmcNdpEc9+svzoU+Bzr9zO/b/QpeA=; b=bG0MygdrRkaVbjdnOMF65xf7lU/3UuP0CZQ45P/wbplfz/aA8o6Ljz+X baAxarfMTictLzOnul6/XKC6qtxPoAjJPYJyIFoKH6KjM9dZowvAiYQom o9kjqAlUpEedG8/sceU3tl+V24fRMdPEITHUtDkYQ8d9gIbbFLqqllo2/ z4efOz13UJAuXRcPorIcNMmQm2hZkDWWhP+bIlXJZKDphoGeoYPnewbJa HUC+J+otQKl2rurFVtkOpCgOQ8FpEX5IDvWEax1oqNhhMu4rjtpWMTgc+ tr4ULoQwsdVLPIiQxBS77DWkihX0fHCR7aIfLqH0tPMdu37hFtlzmVUFL g==; X-IronPort-AV: E=McAfee;i="6400,9594,10371"; a="277581317" X-IronPort-AV: E=Sophos;i="5.91,284,1647327600"; d="scan'208";a="277581317" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 08:37:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,284,1647327600"; d="scan'208";a="579645368" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 07 Jun 2022 08:37:49 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 83A36109; Tue, 7 Jun 2022 18:37:52 +0300 (EEST) From: Andy Shevchenko To: Dan Williams , nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Vishal Verma , Dave Jiang , Ira Weiny , Andy Shevchenko Subject: [PATCH v1 1/1] nvdimm/namespace: drop unneeded temporary variable in size_store() Date: Tue, 7 Jun 2022 18:37:50 +0300 Message-Id: <20220607153750.33639-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor size_store() in order to remove temporary variable on stack by joining conditionals. Signed-off-by: Andy Shevchenko --- drivers/nvdimm/namespace_devs.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index 3dae17c90e8c..0f863fda56e6 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -836,7 +836,6 @@ static ssize_t size_store(struct device *dev, { struct nd_region *nd_region = to_nd_region(dev->parent); unsigned long long val; - uuid_t **uuid = NULL; int rc; rc = kstrtoull(buf, 0, &val); @@ -850,16 +849,12 @@ static ssize_t size_store(struct device *dev, if (rc >= 0) rc = nd_namespace_label_update(nd_region, dev); - if (is_namespace_pmem(dev)) { + /* setting size zero == 'delete namespace' */ + if (rc == 0 && val == 0 && is_namespace_pmem(dev)) { struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev); - uuid = &nspm->uuid; - } - - if (rc == 0 && val == 0 && uuid) { - /* setting size zero == 'delete namespace' */ - kfree(*uuid); - *uuid = NULL; + kfree(nspm->uuid); + nspm->uuid = NULL; } dev_dbg(dev, "%llx %s (%d)\n", val, rc < 0 ? "fail" : "success", rc); -- 2.35.1