Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp837338img; Fri, 22 Mar 2019 09:34:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwcj5ELedMJijTeLzEbBaRWhE10OVhOXoZHq5eFS/N/3N+ca1OSSc4LdMZHTs5PuFkLjzZ X-Received: by 2002:a62:445a:: with SMTP id r87mr9930286pfa.13.1553272466952; Fri, 22 Mar 2019 09:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553272466; cv=none; d=google.com; s=arc-20160816; b=Bnmhpxn3mg6XGYi5/X1xi+IIfsHi7iuPAd87K4gplvfruHNqd//+Yr3DKwamM2CELC 8Xt9fRXJEiYAMAQQR/ntX8P4xLBa2sZnC0wG8xuuwA3fq9im0pkAOKNpp5yVJkj6EcMS 0a5qQsk/mUxVwyQ377d8sv+9Ekje8Rka9xagNf8tp5jOKk7Qkf51efka3Z6UbEyjKkul 7pa1tkAODQlqkAVbLL89tumLO2o3xuFnhC0osP5QsICEm2DrMF4s6Z4Y6i4sh+ur9PCf LjcWIbmQFUdEQtS/g3wqz4CrEZB0ILNN1ayyDYuhMYzXQP4ostvQaJvD2Y12rnMdqDtO EMrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=uFdh5su4BD4vPggq8QdolC54ZdktUMxSqZocHhZqF9A=; b=OAGcAKSKK4eQZsyHKT7R9K0UeQecg+ClbCNez9gWtKO74t9CcUIVfiljRqW1TtN//o uo6dYr7u8Ao+F3GjnIncFUqogzAcX6Cbqj2WICXtqzHBnASQ2wd4/giGekq+iiCB6sW9 WJ/QDhv3eEOrnFcnNkmZLpPXkxRnxz8bEce3+l08Zql4dQV6ni6kUcGEFaKQhrU+N4dM YDS9fTPy/yNdgIPaZlQpfDwfir/aH6X5GajIiYt931OhE1UWNNnwL7Xdf3FKx/ycv7k+ /7Nw8FElM1kTnHQJ+YXRtfgbXaBAc3cvE3J8cpB6TQ2HXpWa4eMJlTeLEkGYBhGjM830 PCtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sGqrfmWm; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a61si1482067pla.178.2019.03.22.09.34.11; Fri, 22 Mar 2019 09:34:26 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sGqrfmWm; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727420AbfCVQdN (ORCPT + 99 others); Fri, 22 Mar 2019 12:33:13 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:37492 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726603AbfCVQdM (ORCPT ); Fri, 22 Mar 2019 12:33:12 -0400 Received: by mail-it1-f193.google.com with SMTP id z124so4235378itc.2; Fri, 22 Mar 2019 09:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uFdh5su4BD4vPggq8QdolC54ZdktUMxSqZocHhZqF9A=; b=sGqrfmWmQyF5KNClIkWxbumhmE4nXo8YEbmHn9le4vfkhpmCu/gaZ4Z9yO5KQ4NJlF t9KhdgfwDsh5pouXJdaPaoXpOw4dNKnEEgDQNfuusRGN+CqvctfzWNCmRKRrJ++7EZZa YfjVC1nK3ICGeKr4wcWAM033O4qGGw2zaQ4YmKzyt8i6MGhJ/MKlZLhsN0WGGH74wrLO qbf5Ft55vUHdqdbP++u9ZwA8QSey8wWR9GzFef7NjxRBxXqZLkyd5TLlMz+Cs+caXU5Q XOtE9PyxZsdbxmphhb23DC4+tfegZ6OhPoW/lDOgss5kDs7XG0qTH7tH9F59PyVLlhlN WJ3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uFdh5su4BD4vPggq8QdolC54ZdktUMxSqZocHhZqF9A=; b=EBnIHmlXCc/YntYpuRWD0jTBRt8AkMqVID3Lz7L6lR6ONIOs1OxupWUf0S9p4ZggKK 7hxLHmtHJjKUggAU4J1ti2iB9ZDmZZssGCowTrNhfDAl7IrUKB0avDPGEnu4YSCLGAk0 pz+GWFoRlCdOY0eWuVp/uI4p5gY90FCO0TSoFlIeiQ6eUuxqaWzSBWqkw96Mz2R2I7d+ ZVmKV03VR0QnECG6uvzi42LWQf7CuJOQ4uRe7px6ojyN4fqrueZFCO8PCH7hgxgncfOk 7SZI3JI0B0vZn+t99USrvweVwAST7zVz+q2V+FH7vpPBY7aOcLLmGn+H25aSiQiWBNKY PMcQ== X-Gm-Message-State: APjAAAXkdYxpTsYC7Hm92WgDhHAFfiGVS/GyoR44ItUJNCTZfBvyH4dq H2FBnM5uEYhmicQqwceCnI9+cHIzm2VC4M9PU2mKOKAN X-Received: by 2002:a02:3b6f:: with SMTP id i47mr7841684jaf.39.1553272391734; Fri, 22 Mar 2019 09:33:11 -0700 (PDT) MIME-Version: 1.0 References: <20190322143643.1317312-1-arnd@arndb.de> In-Reply-To: <20190322143643.1317312-1-arnd@arndb.de> From: Ilya Dryomov Date: Fri, 22 Mar 2019 17:34:26 +0100 Message-ID: Subject: Re: [PATCH] rbd: avoid clang -Wuninitialized warning To: Arnd Bergmann Cc: Sage Weil , Alex Elder , Jens Axboe , clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Jason Dillaman , Ceph Development , linux-block , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 22, 2019 at 3:36 PM Arnd Bergmann wrote: > > 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, Hi Arnd, You did a couple of these last year in commit c6244b3b2377 ("rbd: avoid Wreturn-type warnings"). Let's change all of those default cases to BUG in one go. Do you want to do that or should I? Thanks, Ilya