Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp908121pxp; Wed, 16 Mar 2022 20:55:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhEKYu4fctuVxFpSE7+HfxoS1KR7RcxBORUbnrDtL5HkWVmR4+dY2bboj9k8McUwsFQRpt X-Received: by 2002:a05:6a00:17a5:b0:4f6:f3fb:b6d8 with SMTP id s37-20020a056a0017a500b004f6f3fbb6d8mr2950314pfg.75.1647489338674; Wed, 16 Mar 2022 20:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647489338; cv=none; d=google.com; s=arc-20160816; b=r/nQ8K/4Wn5PAa8W33sjKeQsiYBsFpqVqU0Dtne8Nd2Zub7hFWsM4eOJakmDOsxZg3 xHxEYPdHbxfYidi7yuiIoGY7FJDn0zMRqMt/ECaCRrJT4OjalsTKefFXiScG/E9VxJKA KF6yDsOHUaMwHsDhFaGYpHJN2OLjuKUaFcAsPnZCCvot7M4XxX0RbqLO8hI8F471XNrG 0j3FWKYEyx5i4MdSrNQ5ob9z2NOfWRKm8clNBAOedwZbq4mC4s6p10F7lu1W6CvcpjSa QM4YPDk5Ur7pVzvEWDXvI73Z23J8BOf3SOx4spGn/xFNmRjS113fUhqnY2ZBKUmEyA+i 5jZw== 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:date:subject:cc:to:from :dkim-signature; bh=vtpi8KqEblfOcUZ0Pw5p0t2W/KlA+6v+4V+RQUI8IgQ=; b=e941GOrT8KHJXZzZ18cTaNb+kPOG52cqc1NC+j5m7d6vknL78tVCHrgmw4K4UUu5JQ 05OSLquZH/tTB7P5ygShGywtyA0yK0w7wH8ZvlOVOtfOdz5BFEjarRTrpjXgzwUwGNSg zyxgJ2cfGKsydo3+L+X1hBjarbS6uDs+IZRrwdmLBPcabN9BDh37XOZ1GdlmJ142TBkD dAYIhDM/P16/ijfdDKClH3cjoX2ahOaaoDHGcvWWZaCYefSGhFIZ4SXeD8pk8KLjJaxx /jyQ0KEIBL/y9kZyXOcLQf2MHvy5LRbokX8ECbm9QvrJQFS8hnqU/lTRoIcRSXbZDA55 qMtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ANAUT6Dc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id o2-20020a170902d4c200b00152fd5078f1si3952480plg.223.2022.03.16.20.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 20:55:38 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ANAUT6Dc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 AFA6B85BF6; Wed, 16 Mar 2022 20:42:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351462AbiCOTkm (ORCPT + 99 others); Tue, 15 Mar 2022 15:40:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351443AbiCOTka (ORCPT ); Tue, 15 Mar 2022 15:40:30 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43F6A2B1AD; Tue, 15 Mar 2022 12:39:12 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id 13so299637qvq.8; Tue, 15 Mar 2022 12:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vtpi8KqEblfOcUZ0Pw5p0t2W/KlA+6v+4V+RQUI8IgQ=; b=ANAUT6DcYlkHmQleHKtW+nR4/iCBpy7Rfe7yv/ZfiacbzPp9P1eGNXLYpYzX2rA0tc V7FwAuUBRLttYV4TTs33laSYXdtzLtzAFBejd755ZYZVbGH75mIVidrx+VCIm3XZq1qk T9Gu58gVqDWjtcAuZgIHsqtPrYsBck4P5ENUf75dxOXMuGbuDWh2wpeZtlYEJlWM7aVp 4F1Bju+Dke/itdxE07b/GiW1v4EIVZrHkqqdlThItvpMD9TzkgU/6VOnLt0+/A5wol16 X7QqKH3kop0RiHxN5abv3o7NTVqk0HmCFPey0vIXCXjKr9XLvDTcYyF8dRyRVGZ5Cczr cMHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vtpi8KqEblfOcUZ0Pw5p0t2W/KlA+6v+4V+RQUI8IgQ=; b=w3dNkNqiHq4bE7jMprtjng1dRCPJwabYPuRLFy+fjVEWegjPi7PGPCQe3xakkTRIQg t2wO0aCwVtN2LN735gu5L+bpLZTZNeqJYRyKNxT7untI2/JG1ueb4OWyC2WS9Qw8x3OL 5IEYobikBSRIVDkQlDE/mgcM/tiO74sOmkhSlAIdl29e48NVBeRylIVRjrxAfWdLx38S wut3VE8UVyOOF/5ZSMif9JTVm3HRZo4Wz/SeFY+6m638n6hU/R3rE+bideEc1J3MzmP9 M1ygNQgbVfDwga2TaHnBxxiQOqmy99KDL09JzG9fjN+ItTmPiD4KNQFQpXQOOnDJqPvd y/uw== X-Gm-Message-State: AOAM533dHF6TX6vHjgeWWRve7yGOLH1t8DU0ao25lK7Q0H/d4CijuPe8 4GhES3rGtb7JtFASEGXXJLo= X-Received: by 2002:ad4:5d4c:0:b0:435:41df:faa2 with SMTP id jk12-20020ad45d4c000000b0043541dffaa2mr22679848qvb.73.1647373151431; Tue, 15 Mar 2022 12:39:11 -0700 (PDT) Received: from ishi.. (072-189-064-222.res.spectrum.com. [72.189.64.222]) by smtp.gmail.com with ESMTPSA id o4-20020a05620a22c400b0067e02a697e0sm1440798qki.33.2022.03.15.12.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 12:39:11 -0700 (PDT) From: William Breathitt Gray To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Tom Rix , Jonathan Cameron , William Breathitt Gray Subject: [RESEND PATCH 6/6] counter: add defaults to switch-statements Date: Tue, 15 Mar 2022 15:38:57 -0400 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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