Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp988411pxp; Wed, 16 Mar 2022 23:37:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwOBtstuO/wAX/UtZrgxC+e0kwY/qz6k+8rzJe4kuoX2jZrs2ijHACNOO7brR/zErRcDPt X-Received: by 2002:a63:1913:0:b0:381:ede3:9adc with SMTP id z19-20020a631913000000b00381ede39adcmr2499871pgl.141.1647499029369; Wed, 16 Mar 2022 23:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647499029; cv=none; d=google.com; s=arc-20160816; b=dUo3bIKzKCHOLP52ovOc0M1aehDnWchnXKb9eRe3IllL3CXvx8i8x+RBDr4uQOtqJ5 TFS5i1/jbrCZT/UFMpBdsK21WNx9Oq69bFnwXyytrOhYn1dDBmk3qJl7+4GcDG0GC6wW va85YdhOJLWTpnW5UTZmh+LmUE74UTra4k8iZTJ2fQo8g3XWeuoJ2HSNSNs1S0SHFaZB uAofglvfcqR1onsHfJlbfwsRTO9qekCdJKmNoWPOJB4ubjYG1YHZuYpmlkzXp93kJBEt qu91Oygn1Ki7NDZUEm+JHwi3FyrY3A6wL1JgifO7WIf0lKmyJTmU8GKE+haR+7hnKLHU dfmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oyzqBAUobH5AqCttvDPX2yRj0zkubG2JVL8MLhBhiis=; b=Ac7Sz0kANj+x9nCkL4bcap3iy0oCXImrCXbu7GqDtA2oVE8XMFmrQmwTDwsdlK1UZf DT1kRYDemOSusgbhBGRwIbgJcKK2cXlFSFrB5IXQC1wDbhOk60qu5QZv4HnMnAjwOxZl AyygJEaH8VltyFJzsoVfshD0p91R7JjLCl73J0bIIhJu4S9ZrGqKwWJPFGDOkWlXOrR2 4Xi4BYUaWXIyeKO8Rla+uf/PiUsVaUeE1nOgyoTw2rV2QCqueDfh70KCWzpjoS5QDeU1 8MJd4TY3nNonrmow0jBHbAkE++VzBbwxZYotAFBLzaP9s6Jnj1dEGdO8fGPZwCwP4XLy v1YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EFiEGOXH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c127-20020a624e85000000b004f6d695c355si3690685pfb.295.2022.03.16.23.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 23:37:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EFiEGOXH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B6926223BF8; Wed, 16 Mar 2022 22:23:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353191AbiCPHj0 (ORCPT + 99 others); Wed, 16 Mar 2022 03:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344568AbiCPHjX (ORCPT ); Wed, 16 Mar 2022 03:39:23 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C23E333E0B; Wed, 16 Mar 2022 00:38:09 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-2e58e59d101so12967287b3.13; Wed, 16 Mar 2022 00:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oyzqBAUobH5AqCttvDPX2yRj0zkubG2JVL8MLhBhiis=; b=EFiEGOXHpw1QHkLoq6Zb5G8me9dDVX44GNt10gqtJ5bY6VThYCn7lfZgBzWcUbgWnS yx0rIeqJhinNle2GAvAKGDJ+2jqTrEVIoCRGGyEyLex4u4YvkaI4/7YAYRZidJ5Zzh87 p5vAJs3mMDJv5tiE7T1877sgTtU0Vowz/dvElKPINAzhW4cHgWXbM/+0UE6ZSCuVqtrP PLNqN40OhKT5rSxg6uVc7SvghC1aANFFeg9bBrJr2ieGn+IqyWx7jxXGoic3idCVo8ce 1unmjTjSYwj8UCqKpVh6+AHEkfhEExWNdQpLSTT/jd8SBWUEJ/j02+wyb//R8W+LYqcm 22LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oyzqBAUobH5AqCttvDPX2yRj0zkubG2JVL8MLhBhiis=; b=BT0LI7GUvbB25Vx+DDqVqdl1CjbCxuPwT6U5WtnMh9wy5auQdACRl2TO4ZakekNSKF Gs04C8r4c4lIKSR5tS1jy6/sU3Zr4djXDm0g7tUUkq1qIHUDGfLXbJziW3jCesKmiyZ3 bYZK688hYtjhXkWBfGrMBJDRQNPvjzcQJ9U6jSmIaSPovXE9ycAx0HMVro9/C4npCWvH F61keUDI98CefNhJ9VeKCi8QtHyjHXuzQ+gflWLZMup2YABKBRA9kFFurFpvc8aGyv+K +wi/zdu2LMgKts6d5L73gNM2pKI9F6zo3tmotG/bT0Og89l/ILVrHPvmRgaPYTlL9/GJ G+vg== X-Gm-Message-State: AOAM530oS8QrtPZi71ugJrNYr3acVSeZiUEOdvOZvX0g589hEAjG0Ugn ttj/2ey0hPK3KjmRCKimK1jda6opecS8tnTHsrI= X-Received: by 2002:a81:1cc6:0:b0:2d5:427c:a23e with SMTP id c189-20020a811cc6000000b002d5427ca23emr28475198ywc.496.1647416289010; Wed, 16 Mar 2022 00:38:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Syed Nayyar Waris Date: Wed, 16 Mar 2022 13:07:57 +0530 Message-ID: Subject: Re: [RESEND PATCH 6/6] counter: add defaults to switch-statements To: William Breathitt Gray Cc: gregkh@linuxfoundation.org, Linux Kernel Mailing List , linux-iio@vger.kernel.org, Tom Rix , Jonathan Cameron Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, Mar 16, 2022 at 12:43 PM William Breathitt Gray 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. > > Signed-off-by: Tom Rix > Reviewed-by: Jonathan Cameron > Link: https://lore.kernel.org/r/20220227161746.82776-1-trix@redhat.com > Signed-off-by: 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 b7c62f957a6a..69d340be9c93 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; > -- > 2.35.1 > Acked-by: Syed Nayyar Waris Thanks