From patchwork Thu Oct 15 21:05:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 7409881 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 364A29F1D5 for ; Thu, 15 Oct 2015 21:11:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DE942069F for ; Thu, 15 Oct 2015 21:11:34 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 97E0D2069D for ; Thu, 15 Oct 2015 21:11:33 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8BD8C605A5; Thu, 15 Oct 2015 14:11:33 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id D8947605A5 for ; Thu, 15 Oct 2015 14:11:31 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 15 Oct 2015 14:11:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,687,1437462000"; d="scan'208";a="827734915" Received: from dwillia2-desk3.jf.intel.com ([10.54.39.39]) by orsmga002.jf.intel.com with ESMTP; 15 Oct 2015 14:11:31 -0700 Subject: [PATCH 01/11] ndctl: fix ndctl_{namespace|btt}_foreach_safe From: Dan Williams To: linux-nvdimm@lists.01.org Date: Thu, 15 Oct 2015 17:05:49 -0400 Message-ID: <20151015210549.22046.32346.stgit@dwillia2-desk3.jf.intel.com> In-Reply-To: <20151015210544.22046.31483.stgit@dwillia2-desk3.jf.intel.com> References: <20151015210544.22046.31483.stgit@dwillia2-desk3.jf.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Static analysis points out that we are potentially passing NULL to ndctl_{namespace|btt}_get_next() in these macros. Signed-off-by: Dan Williams --- lib/ndctl/libndctl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ndctl/libndctl.h b/lib/ndctl/libndctl.h index d36a86afa1a6..3ccffa9093b9 100644 --- a/lib/ndctl/libndctl.h +++ b/lib/ndctl/libndctl.h @@ -269,7 +269,7 @@ struct ndctl_namespace *ndctl_namespace_get_next(struct ndctl_namespace *ndns); ndns = ndctl_namespace_get_next(ndns)) #define ndctl_namespace_foreach_safe(region, ndns, _ndns) \ for (ndns = ndctl_namespace_get_first(region), \ - _ndns = ndctl_namespace_get_next(ndns); \ + _ndns = ndns ? ndctl_namespace_get_next(ndns) : NULL; \ ndns != NULL; \ ndns = _ndns, \ _ndns = _ndns ? ndctl_namespace_get_next(_ndns) : NULL) @@ -315,7 +315,7 @@ struct ndctl_btt *ndctl_btt_get_next(struct ndctl_btt *btt); btt = ndctl_btt_get_next(btt)) #define ndctl_btt_foreach_safe(region, btt, _btt) \ for (btt = ndctl_btt_get_first(region), \ - _btt = ndctl_btt_get_next(btt); \ + _btt = btt ? ndctl_btt_get_next(btt) : NULL; \ btt != NULL; \ btt = _btt, \ _btt = _btt ? ndctl_btt_get_next(_btt) : NULL)