From patchwork Fri Mar 22 14:36:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10865925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 598AE6C2 for ; Fri, 22 Mar 2019 14:36:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4184C2A852 for ; Fri, 22 Mar 2019 14:36:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34B172A853; Fri, 22 Mar 2019 14:36:55 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 CD3F32A850 for ; Fri, 22 Mar 2019 14:36:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728889AbfCVOgy (ORCPT ); Fri, 22 Mar 2019 10:36:54 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:42633 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728733AbfCVOgy (ORCPT ); Fri, 22 Mar 2019 10:36:54 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MLyvH-1hP9Fl3xpJ-00Ht2v; Fri, 22 Mar 2019 15:36:45 +0100 From: Arnd Bergmann To: Ilya Dryomov , Sage Weil , Alex Elder , Jens Axboe Cc: clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , Jason Dillaman , ceph-devel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rbd: avoid clang -Wuninitialized warning Date: Fri, 22 Mar 2019 15:36:37 +0100 Message-Id: <20190322143643.1317312-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:ArQEfk+AU79dMEw+t+/M/Vy4omm9JFXr12vfJvDOE8w0LvZdo1t DiayFQqJhMH6lbFTQ6qj3HUL0ViAwLKpYjSOZ1oRxcKkN2VaYuTzPwLKTyR3def4VVNAEqu 3/nPfrm63xzhvFWN1Md44ffnDt1W5Yokm7PTdaZPdaN8mi2H7uPI3JNCbcDBpYI+btRwFax P9nJikkgSy/GZq6ExMi6A== X-UI-Out-Filterresults: notjunk:1;V03:K0:N1+yyUeQGSk=:SJCif1SFlh0KUIRvSOKUG4 P5gV4xbx/jE770iWRHakj2NmYBfZWM3fGpmh2nKMwVHZkTbfp8qEFQlKtw5CSLxMO+p+C0bnO EJohRr4ts39JWR/pfQFGKKxBT35MrsNYjIOzZT0ma29ACWD8Q8wfb9sporv8NgxCkeB6gnYV/ tswxyhSMK8uIV4Lm5V1TIMXbY53bRmQ4/DGIyuU9MxXcdrodoMrGbLxIU6ap9l5CLkoGLJxBE At+T6i5aFRDx2km2ssRhqqh1V+usJ6r+ILdwqgTDqwHO6Di7iKnhOaRUwq89aTsbOGj+4JKaq g3YIQYtHrKuRN3HbsmRLZ+yd0x9OL/YCj9/R5iUuf3SfIAlMsmoPiofmGMCtDmqMVrHqBvZH9 N00HJOJDrceZpbreVkpt749IaOi/LJoV30ICgSszH+7S2ychmUKRPHPGTpm6zB9NggGI1Oys6 6T9Fdja2dQbjQ/1kYDFsl29JJLMMc6IkhLa21yZmRIve0QVLfS1ZpMVxBAUkAjN+QrPvyZxLu S0dDVDLXCeJk7kgbU4bTxjYoO7rold1OiNus3Nna+ofSfB7nOaiGTW9QqFM09v9BEX1/4q5Oj 77FgVbCFssn9w9dauR3HnZUSRxHXEFm+hbeN5etuOmne3rhYC4Y5hmRgENxH9qolh4oDEps/K SQV3fu5nuPD14d0i21K+4tK0BpKm5C/pJmSJUn7MhJiTsAokJ1tbvOqG3UJG18QRNNVdankSU 5/5J6m+hN0eXjYiKxjiLbOE+E2yhOXLyA/OPGw== Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clang fails to see that rbd_assert(0) ends in an unreachable code path and warns about a subsequent use of an uninitialized variable when CONFIG_PROFILE_ANNOTATED_BRANCHES is set: drivers/block/rbd.c:2402:4: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] rbd_assert(0); ^~~~~~~~~~~~~ drivers/block/rbd.c:563:7: note: expanded from macro 'rbd_assert' if (unlikely(!(expr))) { \ ^~~~~~~~~~~~~~~~~ include/linux/compiler.h:48:23: note: expanded from macro 'unlikely' # define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/block/rbd.c:2410:6: note: uninitialized use occurs here if (ret) { ^~~ drivers/block/rbd.c:2402:4: note: remove the 'if' if its condition is always true rbd_assert(0); ^ drivers/block/rbd.c:563:3: note: expanded from macro 'rbd_assert' if (unlikely(!(expr))) { \ ^ drivers/block/rbd.c:2376:9: note: initialize the variable 'ret' to silence this warning int ret; ^ = 0 1 error generated. This seems to be a bug in clang, but is easy to work around by using an unconditional BUG(). Signed-off-by: Arnd Bergmann --- drivers/block/rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 4ba967d65cf9..cbcc3baf3807 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2399,7 +2399,7 @@ static int rbd_obj_read_from_parent(struct rbd_obj_request *obj_req) &obj_req->bvec_pos); break; default: - rbd_assert(0); + BUG(); } } else { ret = rbd_img_fill_from_bvecs(child_img_req,