Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1170477pxb; Sat, 17 Apr 2021 08:41:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIkJPHnwsbHBT7Cv9rUt/W3LDIUQ5MDd3rqhq+yHsK5h7VUKeKRxmy2crSSFMLhCl40ACk X-Received: by 2002:a17:906:7f0e:: with SMTP id d14mr13212089ejr.487.1618674094585; Sat, 17 Apr 2021 08:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618674094; cv=none; d=google.com; s=arc-20160816; b=Xddy8HMQXFZKz/GAPgIPJdozMf5pb4F0nkFTKd5lGpoWkIdaoutUpCozfwt8rH8hTG G6swBmigiSwodmn/y3r+glefdaMAypKIyQ6guN4NsIDBGZhJeCpv5y6euhADLo0CiqEh 4zXhEizHxBrvQCbWLXAG+iP7Nvx+GBl9nsFi0uoojy550z/+fPn+IVCC/2RW7yjOH7tg QK1+zwpkKGEBW2dBV7734hoBlM35SKso1iKSufXGWMaaJnY0944UoscqhkbVfAMYdt1z 7wtGWlA0ctbmJ/79OoK+0LkkWI8ieihJA0elcAKgUehOba4PDHV+g19PHb18utwXOHyh I1tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=c+F4d/dEml33345nfDC4G3PoJm5Qmt0bDGgusF3hVAA=; b=KrTzA0ErHOOdFa5tersEuDyDoayMR7PCGyDJyU4EtpaSH/bA6WuX85Q7KXtSefmyH1 qpSBYyPpiy7IsfuI8YoKXz/7ua9WflnhbdB1ACl4yo5rWeSxTM4Ve7AFHhoHDFo9nYxj GkMYdmYPmEz79lWKcBwCDFiUwkteeKq3J+boqy4K5vY3+NxoEhiVIYQbap6Lzlp9AEIu Ydn1CF23j20wNOJo9XUmADLjZqmVgnM0ae2c5a0M9gpNd6f39o3DH7eDAy2gsVUQKWVi ykt5VRDOPxSIyqBoK28jX2N2jSod4hUBGkdn3auv2LX4AnUiV4KQ/23OeKP1oF9E/wgt 2qng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pg3G1wez; 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 p25si7193911edr.266.2021.04.17.08.41.11; Sat, 17 Apr 2021 08:41:34 -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=pg3G1wez; 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 S236612AbhDQPhF (ORCPT + 99 others); Sat, 17 Apr 2021 11:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236287AbhDQPhE (ORCPT ); Sat, 17 Apr 2021 11:37:04 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3838AC061574; Sat, 17 Apr 2021 08:36:38 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id e5so842350wrg.7; Sat, 17 Apr 2021 08:36:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=c+F4d/dEml33345nfDC4G3PoJm5Qmt0bDGgusF3hVAA=; b=pg3G1wezwp+QSAiQWTByKGg8AxHR1ktpMxQFkRs8iKwJ8Y86bRwAnhU0dHuiTjAEpQ TyDYn+vxSWyq/HQIU5CfpRHGoWQIZgAbLt3lVI+6zNCCiNJsb1d1wowfC9dcz2PY1XnT 5vutlOnMLEMS1Xuh06PY3Y/XMjIlvlJyGq1+komGHJII8ZyNNI2HSkLZZ49pBcjUUx5j G3kLNVPGvLduOUeYY/00R+yb9XBmO5yKbzgvvcE79xH+UTooUK4BRnPYmXmAqlamiuR9 DIphQNl7Q0/vgHpqmFMWUWscqhNwFNxArnmFdEsdB0Py89Ju2wR6yY0A75x7o+XDBg4Y Znvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c+F4d/dEml33345nfDC4G3PoJm5Qmt0bDGgusF3hVAA=; b=pjkuZAq7I25ado+3XuqAm54pqK4OFjFUIlyOUY592BwjsuXJ5Hrdq4thrVJ95m1B3S Yn845VysOmV74QPr5emXbbXSqLGG8gK+bxBCR62Sfb+if7iPdq/RHNdWG3Tq0yz+Om5m QQePkw1ok1NEfgGV9ZS8jvpK4llBAC8EdDaRlRPYNjBYOYzWRBxRVnwPqnDA//yMZVeV +uMotZ8Ungt/9MhaQdpSDGXCmUECMgtnaMuCRLBAJ7WhgZBoZXdS7BUsHvhIaRwIgtGh 4SuABiP1HbnXHVa4ChqhhN0cDnUccMmpi0B3vJZMEW5ybdmB+lmRzpQZ1WEhOsNOXRIZ ElMw== X-Gm-Message-State: AOAM531+eGZruhe+M6QDhdak2QycK576Ku0mAwZR64oKXndJOZ0Hb2H9 2lOiic3Lqo/BBOkQe94GNmY= X-Received: by 2002:adf:e650:: with SMTP id b16mr4760567wrn.273.1618673796958; Sat, 17 Apr 2021 08:36:36 -0700 (PDT) Received: from localhost.localdomain ([41.62.188.221]) by smtp.gmail.com with ESMTPSA id a15sm14773926wrr.53.2021.04.17.08.36.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Apr 2021 08:36:36 -0700 (PDT) From: Khaled ROMDHANI To: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: Khaled ROMDHANI , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH v2] fs/btrfs: Fix uninitialized variable Date: Sat, 17 Apr 2021 16:36:16 +0100 Message-Id: <20210417153616.25056-1-khaledromdhani216@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + break; } ASSERT(zone <= U32_MAX); -- 2.17.1