Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2082618pxm; Sun, 27 Feb 2022 10:46:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCkhP3VpKITQmgAace8vsgg6otGZOBvkS0YvBfK79o2gM2uYZUMEcW4+qEY3aOb/zbWs28 X-Received: by 2002:a17:90a:ac14:b0:1bc:2b81:4f5d with SMTP id o20-20020a17090aac1400b001bc2b814f5dmr13056982pjq.207.1645987585085; Sun, 27 Feb 2022 10:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645987585; cv=none; d=google.com; s=arc-20160816; b=J0lihWn/JROH9uCfItoekX+x7mEaqakJEYaFixiCnF8+aX1pI2OMGCrXVdZn6XZiH9 imQ6j23XGgZb+r2754tOS2Oav71eTrjgiSHlml2FvvVCHK336UN1Q+BEOGdTrR2Y25Qm AabRiGPyx7bHOodYvH7WYbIHgSRQBTJkt7gTOr514VjcIrUeOafpfftUlr81rYrCZ9JE 7BKuFb6Am3gaJeiynD4eaOP3OAbOBHcVnWW6D1t7Tq+EZzhn2T7OIntrADNcHc0FkaRX H7hlQkNv6RG2pJB+8Bh+FwE130P/qK4CWOskN4PyQW3LA7GHiobkHFqcPpOGWH8XovZb fKzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=3/xrl8Nz45mTBcWYKPvNGpjZlUJaW6DDuwGEb1fCJiM=; b=XsTwrUz7aHyeBNBHonMHHlzVBxZg3tt8pAbEUNwiy91OkX+pLmwMPWdfRJHqypJsfg 6I/qTsQI2nDFs30Cpg+9UxjJ4SLcmL1SX9E06I4xKuxTVp4Egb8ulSEclgqJ+zD0Zvvu SStvldd5FupCO+VDowEDhWCUKcnLmJxc72FkIMeSyQGn9J+mcWUmjGNER5Za7RbygNBx cQ1VaA7YSj3y9jHchXro/77xhZH5QLYWzVI2+XaYVvcMUUDcWuG0M6xP/lMdKWK3167i bhGbG6LJFm9gGa5+QGH4R8bwp+LOKv1hVgwEBS+2DshRNV1QnqcSMuWhBxGB3ta8X+8V oopA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BnRFAFvG; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t16-20020a17090ae51000b001bc46cb08a8si12688710pjy.104.2022.02.27.10.46.09; Sun, 27 Feb 2022 10:46:25 -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=@kernel.org header.s=k20201202 header.b=BnRFAFvG; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229831AbiB0Rjs (ORCPT + 99 others); Sun, 27 Feb 2022 12:39:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbiB0Rjr (ORCPT ); Sun, 27 Feb 2022 12:39:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF95B3983D; Sun, 27 Feb 2022 09:39:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3B9B1B80884; Sun, 27 Feb 2022 17:39:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3DE8C340EF; Sun, 27 Feb 2022 17:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645983547; bh=RlxsNBxWP23xW/4RVjjxHZDE4BG21qefYTNvuOdpYrc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BnRFAFvGMoca9d7oCUM2P30xUW2DQtTIu5s6WxGi5BJSKv92sBM2pOLtt0bONJw84 PUssBow1aejad+JoryXbY3lumR1oHPOLjEcFlL0DiD1q4agnWJEZVCOgMLyufa7eee h4mpGQwP2xqEuWDvaitMcuoQqtqLe9ELsecnOm/GCzFyDWh1LSYTnIe4kFc+Ni9Zsz AB0gEOOZTM06m5PWFjgq+wnTLJEqiPm3hsYdQBwoan6dTP6d10opDdvM+NVkOm4N3/ ZTjPCoQhbXInL81vfEM4s/WKlRL9HaLxwQwxflIFugFLA75hhu5x1O8oDxil9Pebcc GlYYk4SMQDklw== Date: Sun, 27 Feb 2022 17:46:10 +0000 From: Jonathan Cameron To: trix@redhat.com Cc: vilhelm.gray@gmail.com, 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: <20220227174610.0e0e73e4@jic23-huawei> In-Reply-To: <20220227161746.82776-1-trix@redhat.com> References: <20220227161746.82776-1-trix@redhat.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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, 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 > --- > 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;