Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2358861pxb; Mon, 23 Aug 2021 19:24:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwne6vABS1DR2uT3sC8/X9g9155j7chBTbJOwAzOMpUWgyaKK1/cJsx97Vmka2STESpJ3n+ X-Received: by 2002:a17:906:49d5:: with SMTP id w21mr38113446ejv.30.1629771896501; Mon, 23 Aug 2021 19:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629771896; cv=none; d=google.com; s=arc-20160816; b=Trf4Vd7B7ojqjkqjwXy26ATK3srAKjMgB8LPmkLAUm+E6uyMNFH4XIzSigfoq4vlgv Rr6Do5yDF33AupghOhZsjJ3V8nlgYLXqp0crDrMziJEfpOqizQ8m3X6NLxcCjpoZFyTA ZvZLUsHk01Dy7JeCXwhbUw3pQg6TvVNSxdROZ/M6AWz2sdXDcSFR1ir2z7JKCeo3GK7l v1FYMdZzoxzh39W/i4DPn1IuZUIIO4lVgyT9QOEp+HPPtPer/UB9QDcuXKnZr0IWnvSu L5b2dhAdIFUm4MoMnW0piidVpSB0PUK7+bOw6X0rbXXwfnGUpdT71oBgOPT+NYj6fsbm MvjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=Buf9yDmqv76HtLamO3Pbrt8As98ijZEWdR2Z19Om0L8=; b=bNiqBrJQ3K0uXzJ0+P5QMOO3aPk4OOzHjNuh/l5kxixafyNcxPV3QFaLOk7RduZvqJ OMTyAqImG1UMJU5+G/ghFnr134MRt0RdTZlP/EtsKjX/3HcHz3n9ugwxj/mNsXpqej1A dKUVMSwikNRo3HQqV8B408sTYPPZSsFWI1C+AtwLyNkaQWL+XD3dA+1LnAkBMgEn+uca YsUie7nLeiKH9xscLuavj/5qH8ZPCzqvJUQsUCQz5ZUrKkA5V6GDZsmNPqCs2uIJWc/g pCRohxivtJ7tzqNww3ZeEVPCmwUV+6rtnTZq4PeHqXlKX0pnt/+w8OQtCQKtzq3RICl/ Hp1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nmy2uJXJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qk14si11593236ejc.479.2021.08.23.19.24.33; Mon, 23 Aug 2021 19:24:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nmy2uJXJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233758AbhHXCXl (ORCPT + 99 others); Mon, 23 Aug 2021 22:23:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232779AbhHXCXg (ORCPT ); Mon, 23 Aug 2021 22:23:36 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD384C061575; Mon, 23 Aug 2021 19:22:52 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id j187so17004144pfg.4; Mon, 23 Aug 2021 19:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=Buf9yDmqv76HtLamO3Pbrt8As98ijZEWdR2Z19Om0L8=; b=nmy2uJXJkuAuXMLrPpKLxa2/fZttM4IE5G0/V9m2ZsTA+VL46/Rg1VOR8KrLjUZCV5 2Uo8tul4r9XfTLn/guv28Kk9divchUz/Dq68aKyrAj4m9UTYhMpInlqVgQRZlKJyYUX4 s7axl6V3szcbLsmLKFKAZsDYSIYFH4a/ylaJeQSfn1BNsV7pY4wiKVwGjF7yQMInXfTE IfgEojx0oxs9nsYjHtsET+svSBZjPPK60wmNQGXH55WZJOC0KWvOEv2mcXcWVfzCc9Vt L+K7VUEjS6IccgrPHkE3tnP4Kmppm8ZhRjECQtovKdpQH/476HSfvCTjWPuDr3hP50Zz A33Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=Buf9yDmqv76HtLamO3Pbrt8As98ijZEWdR2Z19Om0L8=; b=fpxEogCMcnYnzab5e3EcI2nE/P55exL6f0VwBqoXxWYOHyBGKfgG7IyWJTM56sVCWX SwCTFlOPP2xMHXErUWVS2XxdjRDK9+ecQkZe4tZSg5PzcnjJwb/1zmPHpCWtuq6CEini gq9tj+nmQbrDExOeJQTiYf3yiFLxcgM/RisJurD7Cjhd6iwXFPWjtZRxbZ7yusEPKT/7 NlfIrGl8UlUmgllM0juqc4LmGNq825G6fpTxsAzcv/0KOvhQxDkp8d1lD0DvTm732G+2 wjeDCnpYSiU1gElD5ExtgT+c3sf7W9Oa3UU8zFH2OtxHliTwyyQieg7x2T5rct9Xn00t +xPw== X-Gm-Message-State: AOAM533oK4M+JNCBncG+VH+kYd8aUK6+VoeBrefvYH/bFWcR3ozep01f Rc1MzDyBOUSgKAQAjZUJgSUxtSRByCOCNtv1 X-Received: by 2002:a63:65c5:: with SMTP id z188mr35229033pgb.35.1629771772418; Mon, 23 Aug 2021 19:22:52 -0700 (PDT) Received: from raspberrypi ([210.183.35.240]) by smtp.gmail.com with ESMTPSA id l10sm503260pjg.11.2021.08.23.19.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 19:22:52 -0700 (PDT) Date: Tue, 24 Aug 2021 03:22:47 +0100 From: Austin Kim To: paul@paul-moore.com, stephen.smalley.work@gmail.com, eparis@parisplace.org Cc: selinux@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, austin.kim@lge.com Subject: [PATCH] selinux: remove duplicated initialization of 'i' for clean-up Message-ID: <20210824022247.GA22908@raspberrypi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Austin Kim The local variable 'i' is used to be incremented inside while loop within sidtab_convert_tree(). Before while loop, 'i' is set to 0 inside if/else statement. Since there is no 'goto' statement within sidtab_convert_tree(), it had better initialize 'i' as 0 once before if/else statement. Signed-off-by: Austin Kim --- security/selinux/ss/sidtab.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index 656d50b09f76..301620de63d3 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -374,7 +374,7 @@ static int sidtab_convert_tree(union sidtab_entry_inner *edst, struct sidtab_convert_params *convert) { int rc; - u32 i; + u32 i = 0; if (level != 0) { if (!edst->ptr_inner) { @@ -383,7 +383,6 @@ static int sidtab_convert_tree(union sidtab_entry_inner *edst, if (!edst->ptr_inner) return -ENOMEM; } - i = 0; while (i < SIDTAB_INNER_ENTRIES && *pos < count) { rc = sidtab_convert_tree(&edst->ptr_inner->entries[i], &esrc->ptr_inner->entries[i], @@ -400,7 +399,6 @@ static int sidtab_convert_tree(union sidtab_entry_inner *edst, if (!edst->ptr_leaf) return -ENOMEM; } - i = 0; while (i < SIDTAB_LEAF_ENTRIES && *pos < count) { rc = convert->func(&esrc->ptr_leaf->entries[i].context, &edst->ptr_leaf->entries[i].context, -- 2.20.1