Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2823561pxm; Mon, 28 Feb 2022 06:49:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrhpuUP0+3vs7QNbH+pNKsnVpKGUeKLvirRZRxG10QqRQLyQGHwL4XsihvgZJqlHgNgBlx X-Received: by 2002:a05:6402:1e8c:b0:411:7180:7dfc with SMTP id f12-20020a0564021e8c00b0041171807dfcmr19805687edf.74.1646059756462; Mon, 28 Feb 2022 06:49:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646059756; cv=none; d=google.com; s=arc-20160816; b=f0dMWHwZpOwcHE3OCRIc8b+6XYDdivn1HJ6pOVyeDhMJTJI41vkNXJXfcAF7ff63II RiJXuQnfIAJx6NdlHyka5hZT4z68xc8MwmV0ohKqvM3ytrkeLy8zoj/SzYCuK9hr3FAU NyPnDEVjfDq8qzqYejx66xdQtRSG6uJWUuRfDl6nca+FKOFWJUWD1Lr47BY6Hag8ffKk pOBBrffuMP82xrtKC3w5ngwTdv3W0/T9NE9LOmXEFt1eMzBAP2w5LfhzdvkX5sZjJn5b eMz27214WsGXrVsSMwt8bD/JEntNEII0WrCXSpSGmOiR6FBmHQa1oHk7Ep1pUH8n9Mui X3Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BTl/pAfD1lZ0h4IgEDgvVGkksy8JHT3RGVdO1p5rBwQ=; b=Ff8Dbd8ZvfjbxNPIE8BUd2K1JF1JZMSN1VPv5i+vg8sgM7oqY7tOum7ioV1irnyCSs 4ZWaERo5H5AAahM16u9tUEdYAj56y8NEZMKuuiu71aVXTJKWT/2Zjtv5/aBxv+3xiZx8 fzn4AjalaztOt5XuVdgIeULOY4aFW8d1euHZvuf5ze9wuQNHOiEgmr2nX1daIV/MkbOu VlARNQfBuZY7LVOuGS664Lt7zVGHK65Rv94uyWTX+E18SCfWI4cev9GZRqmm+auI8app 6F8lWUU6/EfGpBWPpNuLTYz0fT3x/DhsF53AGhAO25MsA1AGNlFUVGm07ggCOWv7B2WP f7DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ldlxx9hD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a508758000000b00413b3fbad35si2722351edv.8.2022.02.28.06.48.53; Mon, 28 Feb 2022 06:49:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ldlxx9hD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232709AbiB1NEE (ORCPT + 99 others); Mon, 28 Feb 2022 08:04:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233910AbiB1NEC (ORCPT ); Mon, 28 Feb 2022 08:04:02 -0500 Received: from mail-vk1-xa41.google.com (mail-vk1-xa41.google.com [IPv6:2607:f8b0:4864:20::a41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1467E42486; Mon, 28 Feb 2022 05:03:22 -0800 (PST) Received: by mail-vk1-xa41.google.com with SMTP id j9so5102956vkj.1; Mon, 28 Feb 2022 05:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=BTl/pAfD1lZ0h4IgEDgvVGkksy8JHT3RGVdO1p5rBwQ=; b=Ldlxx9hDrW/D5mRexfK07vpqUm5TKE1VpzQKjQkvjhcAorAkHxxa7tI7JSaN+VYHl2 6a6uEMH9oYAUOYiRQ5xkzVa8jS9+O0DhVRfm5d/jiLroorICFA2Ff/w5AtFCtdwI6pdN /A0fGyTwiWs7/iQuqK/tlooufyT6Txb+CXQOc7ej4befc/04Zg6+v3U0XIwiHc99+XBj 2A2ajw15zY6/xRky38XIiREnuty1P6+Yq29yomZsZakkcytIVfer+PMhYP/sP4wy6hC5 y71faSoQcslmZRT8Tg3qJel1E4QqIoFAzu6ke6t2rsRKwHaTvYwzmQ/7bLtPDKQj8ij3 tqbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BTl/pAfD1lZ0h4IgEDgvVGkksy8JHT3RGVdO1p5rBwQ=; b=TTQ60V367HaUxt/xZ/eJXU0Evy5CgBXBy/0nzXJvrMyEk8Srwp9uZ4R8jjxXi6UW/1 yYZQIUkhMqDo7KL17hw9YA0/qXDWitw8Z7xyctFHSjfrikDJ+NrFG9qtVbbg9VDVh6/R 8kFSUy/wpfFXnTofv8ZdCVmfH0GjEy6wXAwA9cbKm33izvYPls4uJAVlMnWPYX5I/n5a k1GVuuR6Fze343WS0QWzlhqTeqGGnRZJmFm+134HI0TwfegRgC1gkg5t3IoH/0m70FT+ SC+05o/VssXVQOfMqo3m2uebsDTO/6MjpL3fdsERD5w4Sbt6jNFu8XV5/45WKkU951Hm aBIA== X-Gm-Message-State: AOAM5304obN5rJ9/EmE56IMVVitjJ+Ulw4zERD9otnyyaA7zeU72xpJO zZhT352UMKpM7TupTBIk0y6/W8UBUFPfKFvIXpo= X-Received: by 2002:a1f:ac04:0:b0:32d:710:5930 with SMTP id v4-20020a1fac04000000b0032d07105930mr7901130vke.6.1646053401150; Mon, 28 Feb 2022 05:03:21 -0800 (PST) Received: from ishi (072-189-064-222.res.spectrum.com. [72.189.64.222]) by smtp.gmail.com with ESMTPSA id e20-20020ab02b14000000b00345f0381ddcsm1886237uar.0.2022.02.28.05.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 05:03:20 -0800 (PST) Date: Mon, 28 Feb 2022 08:03:18 -0500 From: William Breathitt Gray To: Jonathan Cameron , trix@redhat.com Cc: nathan@kernel.org, ndesaulniers@google.com, Jonathan.Cameron@huawei.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] counter: add defaults to switch-statements Message-ID: References: <20220227161746.82776-1-trix@redhat.com> <20220227174610.0e0e73e4@jic23-huawei> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220227174610.0e0e73e4@jic23-huawei> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 27, 2022 at 05:46:10PM +0000, Jonathan Cameron wrote: > On Sun, 27 Feb 2022 08:17:46 -0800 > trix@redhat.com wrote: > > > From: Tom Rix > > > > Clang static analysis reports this representative problem > > counter-chrdev.c:482:3: warning: Undefined or garbage value > > returned to caller > > return ret; > > ^~~~~~~~~~ > > > > counter_get_data() has a multilevel switches, some without > > defaults, so ret is sometimes not set. > > Add returning -EINVAL similar to other defaults. > > > > Fixes: b6c50affda59 ("counter: Add character device interface") > > Signed-off-by: Tom Rix > I'm fairly sure this one is warning supression rather than a fix as > that type u8 being used in the switch is storing an enum which is > set only by kernel code and all values of the enum are covered. > > However, that's not locally visible so to me the addition looks good, I'd > just be tempted to drop the fixes tag as backporting this looks like noise > to me. > > Reviewed-by: Jonathan Cameron Yes, this isn't really a bug because the only values available are those from the enum, but I see how this is not immediately obvious at first. If Tom has no objections, I'll pick this up and drop the fixes tag so that we have it along with the other counter changes for the 5.18 merge. Thanks, William Breathitt Gray > > --- > > drivers/counter/counter-chrdev.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter-chrdev.c > > index b7c62f957a6a8..69d340be9c93f 100644 > > --- a/drivers/counter/counter-chrdev.c > > +++ b/drivers/counter/counter-chrdev.c > > @@ -477,6 +477,8 @@ static int counter_get_data(struct counter_device *const counter, > > case COUNTER_SCOPE_COUNT: > > ret = comp->count_u8_read(counter, parent, &value_u8); > > break; > > + default: > > + return -EINVAL; > > } > > *value = value_u8; > > return ret; > > @@ -496,6 +498,8 @@ static int counter_get_data(struct counter_device *const counter, > > case COUNTER_SCOPE_COUNT: > > ret = comp->count_u32_read(counter, parent, &value_u32); > > break; > > + default: > > + return -EINVAL; > > } > > *value = value_u32; > > return ret; >