From patchwork Thu May 18 13:33:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9734399 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 29F55600CC for ; Thu, 18 May 2017 13:34:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1712A286AE for ; Thu, 18 May 2017 13:34:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BBBD28731; Thu, 18 May 2017 13:34:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A820B286AE for ; Thu, 18 May 2017 13:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755791AbdERNe3 (ORCPT ); Thu, 18 May 2017 09:34:29 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:64427 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755475AbdERNe0 (ORCPT ); Thu, 18 May 2017 09:34:26 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lodul-1de6g40eOh-00gmMl; Thu, 18 May 2017 15:33:55 +0200 From: Arnd Bergmann To: Chris Mason , Josef Bacik , David Sterba Cc: Arnd Bergmann , Nikolay Borisov , Liu Bo , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Btrfs: work around maybe-uninitialized warning Date: Thu, 18 May 2017 15:33:29 +0200 Message-Id: <20170518133351.1867577-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:+uBn2kf2VYQjQCl0IDxBM2vheC0XdRRS7mlDzJDFXYN3n7cKjYl AZ709AHcGvXtVAtCCJJvAlvnXJ0b1bFzGGlxxJz3O5Hp3JNswXFuDBw1Gy7Ayp1+A0S96WC Ud4ENHtvjLDbjC8/4ZbfMvyHDJkgdT3beAzgT1zjM7oQFdXq4brc84Yvg73Lcu0dDsXIxKK TSu7RRQhRWTSzEjEvWhqA== X-UI-Out-Filterresults: notjunk:1; V01:K0:OwrpiMQ0XsA=:5VNURLwpKWYSiLQeKuhKWV UOoF58p2H1ln4Yw95eEqnYnT4JbSbkOZsursoTRTq69KCnKIBEDEawEkUsI65HxKMWKjY/x6w gMctB+MtaR34s5ftlqULy/4O8sH0+bVljYDzTYYtAZ+U1xy6tol7q1QOVq6IGJm+aViaxvei2 wkm/HZEiRnI5N7K6qDlJ2bPT6QqcIWrG/G8D9sBVk4GQy0GSgg4mkyCMtYTiA1bIwWPM7JLTq i/GEb4fNFjo9R+FVjjkOr05RoQvvz3oViLW5ZWog5YNfxdLfhErzzT43UO3o/2XADaP9AWDgf Y1vPwtSxThyTbGcu5B5dSFhsXIbG1RqIDFY48BLPpDI7AvusOBaV+b/v0Yheu1S05aFtpDhpq T7pMMzl8sJaA+fLLS4hqdbqvseTTmwhgJ5E8IvGDllBJNCEHp4hBmoRFu14JCmXVAy6JE0hAk AM2s7CmlgvsFftS/kwPsg+dWZKVJC2m+nUd1i2k9Sm7R9ZBdEK0WqSY8727aQFQlgJs0N/gJi XW3KmOucKqBCs8AEbs8TQj9c1EA9gvU3GGVVy1eQ1U3+NypcspyBz0yPo0VEz0Pc6hWOKzbzy 4Lfr0SpfNyn1o/U+ps86KH2RydA01T9VgyQuCzcV5MN/oa7s5EMtPiJuxsAuq3DqtwcuanBRw KpZ1hsm8VE+TnD+1YU++uubgB0/M9mwHKLxUACZDhmZIqAK2wvNST/kh8wwgd0SjmUvg= Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A rewrite of btrfs_submit_direct_hook appears to have introduced a warning: fs/btrfs/inode.c: In function 'btrfs_submit_direct_hook': fs/btrfs/inode.c:8467:14: error: 'bio' may be used uninitialized in this function [-Werror=maybe-uninitialized] Where the 'bio' variable was previously initialized unconditionally, it is now set in the "while (submit_len > 0)" loop that would never execute if submit_len is zero. Assuming this cannot happen in practice, we can avoid the warning by simply replacing the while{} loop with a do{}while() loop so the compiler knows that it will always be entered at least once. Fixes: 0fd27e06c61b ("Btrfs: use bio_clone_bioset_partial to simplify DIO submit") Signed-off-by: Arnd Bergmann --- --- fs/btrfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8c37b4fa4cbb..c62cf9593cb3 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8497,7 +8497,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip, /* bio split */ ASSERT(map_length <= INT_MAX); atomic_inc(&dip->pending_bios); - while (submit_len > 0) { + do { clone_len = min_t(int, submit_len, map_length); /* @@ -8540,7 +8540,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip, start_sector << 9, &map_length, NULL, 0); if (ret) goto out_err; - } + } while (submit_len > 0); submit: ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,