Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2824327pxb; Mon, 19 Apr 2021 15:12:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuRPgnbB/YUUqqoxfWNkMYFZBYE9v5TrLAyFeKXkfwN70vNZhHxxSVbptT3+GO7Nqd1GQ+ X-Received: by 2002:a63:d04b:: with SMTP id s11mr12245281pgi.92.1618870338088; Mon, 19 Apr 2021 15:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618870338; cv=none; d=google.com; s=arc-20160816; b=n11cifGtmJOo9Wagzg6B6l4Chw/qSch3uSHpSrZvwBsdImIyMIVri6aiFxWXGvxnF3 /BWBSKb5NJV+zd/KDdOoh4SCNlnZAAYgERzC2ew8OeZSnWVBI4FSlutKa4LPg+VYLShO DDC7WC+6SR5/TRZTpCaXIjuIkHdJvzRU4VClBN8oPQUmyvVi2jt5kqi70PNyRnOhFFXU Jj/bNREEA9n+qTJU6kREnSRZEwzr5fNozXeMYabwXd6F7O6ihN+YxDtjQsVrP7IpmALn nwb6tRUT/igEuq+1OpooOMp3T62CVIRfitomHQbvrZmKwY1TvFCHF20Shxq9HYQbU5xH iIiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:reply-to:message-id :subject:cc:to:from:date; bh=4byEDL3lfqp7otxF9yZgcKinmdJUw6DW6pJDe2B675Y=; b=CUPfOZ7xKReuR6nkGctbh5pKWoYQpVW63+DquPUSrbP7bV2pZwLi3bHIwz6Jy+P6lv w2C0tp5ujEES6kERLeQ3lMv/qs/jwsBNR/BYFiLgv1TJ832MO51nk/+x1NwUVkQ6WEVG 43FFZPST+ZalEPSqn41EGxTmTkJ+WdmxNIu/uG446/g1pCxFW6ZPqzoYtX1EvkVHmXYn xoRGaNjJLMK/OdwT/pMeuZFeIYMMPiqCFq2bb913oXDZuGjPNqyJpvE//mBwfCt6beDx LyFPirGEZXOVXiNeUdiWAF7lXztk7QGJjuDAPTUZbjAescg9ilYf9ZSA1zoJU9maFlVk 3Eqg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si867646pjs.116.2021.04.19.15.12.06; Mon, 19 Apr 2021 15:12:18 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240031AbhDSRfQ (ORCPT + 99 others); Mon, 19 Apr 2021 13:35:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:49906 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239976AbhDSRfO (ORCPT ); Mon, 19 Apr 2021 13:35:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CDB61B30A; Mon, 19 Apr 2021 17:34:43 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 83FB0DA732; Mon, 19 Apr 2021 19:32:25 +0200 (CEST) Date: Mon, 19 Apr 2021 19:32:25 +0200 From: David Sterba To: Khaled ROMDHANI Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH v2] fs/btrfs: Fix uninitialized variable Message-ID: <20210419173225.GT7604@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Khaled ROMDHANI , clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <20210417153616.25056-1-khaledromdhani216@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210417153616.25056-1-khaledromdhani216@gmail.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 17, 2021 at 04:36:16PM +0100, Khaled ROMDHANI wrote: > As reported by the Coverity static analysis. > The variable zone is not initialized which > may causes a failed assertion. > > Addresses-Coverity: ("Uninitialized variables") > Signed-off-by: Khaled ROMDHANI > --- > v2: add a default case as proposed by David Sterba > --- > fs/btrfs/zoned.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c > index eeb3ebe11d7a..82527308d165 100644 > --- a/fs/btrfs/zoned.c > +++ b/fs/btrfs/zoned.c > @@ -143,6 +143,9 @@ static inline u32 sb_zone_number(int shift, int mirror) > case 0: zone = 0; break; > case 1: zone = 1ULL << (BTRFS_SB_LOG_FIRST_SHIFT - shift); break; > case 2: zone = 1ULL << (BTRFS_SB_LOG_SECOND_SHIFT - shift); break; > + default: > + zone = 0; Well yeah but this is not a valid case at all, we'd rather catch that as an assertion failure than letting is silently continue.