Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp742521img; Fri, 22 Mar 2019 07:39:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKhHKE+XqehlnFzpASOg4PSQ847KUpRji7IptkAycBIr16iDvzbwWoqX04layM6I6+TysZ X-Received: by 2002:a63:5458:: with SMTP id e24mr5673935pgm.132.1553265587479; Fri, 22 Mar 2019 07:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553265587; cv=none; d=google.com; s=arc-20160816; b=SPfKRTU9VtMVQLENE6uxiaYdqXugq8kRJ+ZtcT2Z13SF2wwqTrfUIVUCZRbtkTO9pt hsYR9ezClJT+t1bll9h8dQ23+9834kWB9YYDrPW9CXHWmblUWzbE0tBttnL6Juyu4iyh Lm+5INDN7YvT1Ko1Q2/+gxc/h8cPTghWf3sW8U5x2KK4+Jw0Eh4MIJVJtYB9xUd4rg6H LqLR5ya3ClTusJFcvwL9xpkRVBroKdiJ0g+E64naGIaQaHqgFpw1bxWVRD0viqJ2Qz6x EkDbIBb67oP8BNjEIy45on6/ZBj+jJ4LaR0jtjuQXmyzaSSKmm929NZfFLl4h7Z/RcWd W3ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=YM3HZgNlBMcpeHu1GBOX4fcsE+IzKgFpDayLH36U/jo=; b=lYxO6ygkf5WcXr8SGx9PMny2+b9u3FC34GeMDnzm/86HCU7hyZlJA1Te7uL+q1ubzK iDsyJZE6PT8SIKzVYAmOUfXC0/hHbYvgRbJH5Bwc1J1B+UqOGqcHr+j9Rip6FgHJrPFC 9lFKKZovkHJwZsI9yrvICNC3fiT5OU5wKRGAPlVZ6eJzz7Fi/SPVUJU+cbc7i61tWzps hKT0B+JtK6q2+MFMdC5A2aYFy6hb3OlnvcCqcr/eh5P9D1PzptyRbqzda2fbQXCb9odn JITRxNIvsD/Za4LWJOu6McWc3FdCLFM+p0xZUWB1oPnGgUsPkpxvH22yMUWYkLxvGcEo 8I7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o61si7650488pld.280.2019.03.22.07.39.32; Fri, 22 Mar 2019 07:39:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729258AbfCVOgy (ORCPT + 99 others); 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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0eXjYiKxjiLbOE+E2yhOXLyA/OPGw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- 2.20.0