From patchwork Tue Mar 15 19:38:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 12781794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 419EDC433EF for ; Tue, 15 Mar 2022 19:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351440AbiCOTke (ORCPT ); Tue, 15 Mar 2022 15:40:34 -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-Google-Smtp-Source: ABdhPJw3c0Gc+qsu1VcCFc5QY6piefkAaumx9XPYdozaQ4sDIixhK9+tK9nKpu6duS8AbGUkbfknFQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@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 Acked-by: Syed Nayyar Waris --- 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;