Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2403024lqp; Sun, 24 Mar 2024 18:03:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUqe+Cfe5nBat9BdEGnevThO4onHcAkyTZ3WLU5v9kjL+jJHnkf7Sl7mlMEWng/D30b/LNqvczl8+Ur2zEcAw0bLi5HvQTCaOK0P9YwNw== X-Google-Smtp-Source: AGHT+IHrhW00U/Lq/1xE1FC1cnnfaJXvff2JBPouq9FpiDnZsVb29XKFI/+GgBcFI/5/aaOYdnsY X-Received: by 2002:a05:6a00:b84:b0:6ea:8e84:d806 with SMTP id g4-20020a056a000b8400b006ea8e84d806mr7088576pfj.16.1711328598077; Sun, 24 Mar 2024 18:03:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711328598; cv=pass; d=google.com; s=arc-20160816; b=kNwNQ+7bVKiRV1mEtj415GQP5vlpHffUd069wGzff2mbLN6mhiK0tAEEsjuXdYy176 WvEBCqbRfb+usYH45aTiCObpXvprTpdD6ta+vkpIdQMMHX8ErtwNsUjfrdV3eOIsN9ec GGUQBjEFJ2tJxTV+IAXpPhXpcwn3+tnvVhaLqAqI7m0yglJw2X/GvjKhLy5iyhkjPvS7 CcGtaUBeH/7vDMDg2xVPjUwBNMbCnHzE9w3IjoVFtRZxSj3HHRh6zaiNJfrWBLyDIgF1 kkv0dwgF3wp54piOZVDRhUxTmVpTaAL1/oRFUUkovdvle/4sBhQustOm4bmORynqf20G JjVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qqGW/+41BuLGyB5ISJutw0TnPQXREjOk/qOrvJenw3o=; fh=FtlDdmN+ONsvI3WuV6ZM+mOS+M9gdsQYTxH555msMDY=; b=uR3JMi76lSzH/N3C0jNKf4e/ecUad8mwG9VUKFam69/jfsT+DzJDVKQ3h1iePEswg8 AxifmM6p695MzZ8OkD4G1uFIfhJXaJ1fKJlhdqn5fmIRXTxZQA4crmYiUmJH40r2tXd5 Ih7dNSydrLco3GnaAMp3btTIE7EC0rOJXK2obI9xKEo8p1AA4xKq2NCnDwOf1wUAKgQU mGzowWmRA4HKqF7wktYHSY2eNRcghTyR8/tJxI6+20khD+nP3PVgeAdGfqaMORGqYcis Vbgr+FG88uAtb38xQtCnfG3EUFndodF/MD5NV0NzRiaeiwdR8/rp8JfwAKQCBZS0rN0x oGcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q3VII3py; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113459-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113459-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z187-20020a6265c4000000b006e72e3bbe3dsi4189864pfb.102.2024.03.24.18.03.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 18:03:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113459-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q3VII3py; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113459-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113459-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7CA51B24E97 for ; Mon, 25 Mar 2024 00:42:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A427071743; Sun, 24 Mar 2024 22:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q3VII3py" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A642C1B0DDB; Sun, 24 Mar 2024 22:44:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320260; cv=none; b=nmbIaq+e+GK7uy1wvhilYObQWSk58D3N5X+gdnfGTEPeaNqIHmAt40mBz9E66jgVM/6PKXlCMYVq9xBnKCFJ45hmKeBHmu3ETqsgcpnkssb6C/0bxY0Y8GDzoUkjbGCM97tsoKaWkFxy8p+qFjZ21wm0nxLb3WMeehT9fNdnVeM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320260; c=relaxed/simple; bh=AS+JGYpUDsPlHwpiNSjJhMQhjdqKCPCQtDNBzfmKuyQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MVPIyXrsUl9am2NJkiLXByYfLGK2wPCnBB21a3Pyh71pNflEyW3DmB6JgcVa6cQK+s55nwb/VHL+XRo5qv0zm5LBU93DX113fpsFPad59BtxvleRwcEhkfcC1WszxsI14qjj2qTJCtMp78NT8xY3YPhTzQPpvaSV1v+OUWEhHcw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q3VII3py; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7B69C433F1; Sun, 24 Mar 2024 22:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320260; bh=AS+JGYpUDsPlHwpiNSjJhMQhjdqKCPCQtDNBzfmKuyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q3VII3pyYuoh3xHCnraeLGAcjYSSfv1chbdMjahqujGUK+7s5kq4AzpnhNPMVj1vd mH8ex6cMAlsdl7o52i1KahmrkY/HmsxFBoN1gehm5Z6fYSyZ8/kQHbJTn+5/oScsvT uYeQN+1KW4OeWGMUXCHKXy8siJ5eHKNvz117iwICDymobYddNVroOce86mTj6SQam2 Dg5M1+lsIDLqGmQvzDwppGc94XIRyywkwmfH648KFh3+xrPmieoDUxgeLmDrFZbm9c /pRd71V4t+L09TGZYELhN6LEjOvs30CN3yXeXMghinO0XzJTapSDMGG359mIdqKH8N 3tbsx+N50mY/g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , "Martin K . Petersen" , Sasha Levin Subject: [PATCH 6.8 568/715] scsi: csiostor: Avoid function pointer casts Date: Sun, 24 Mar 2024 18:32:27 -0400 Message-ID: <20240324223455.1342824-569-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Arnd Bergmann [ Upstream commit 9f3dbcb5632d6876226031d552ef6163bb3ad215 ] csiostor uses function pointer casts to keep the csio_ln_ev state machine hidden, but this causes warnings about control flow integrity (KCFI) violations in clang-16 and higher: drivers/scsi/csiostor/csio_lnode.c:1098:33: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] 1098 | return (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/scsi/csiostor/csio_lnode.c:1369:29: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] 1369 | if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_uninit)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/scsi/csiostor/csio_lnode.c:1373:29: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] 1373 | if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/scsi/csiostor/csio_lnode.c:1377:29: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] 1377 | if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_offline)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Move the enum into a shared header so the correct types can be used without the need for casts. Fixes: a3667aaed569 ("[SCSI] csiostor: Chelsio FCoE offload driver") Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20240213100518.457623-1-arnd@kernel.org Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/csiostor/csio_defs.h | 18 ++++++++++++++++-- drivers/scsi/csiostor/csio_lnode.c | 8 ++++---- drivers/scsi/csiostor/csio_lnode.h | 13 ------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/csiostor/csio_defs.h b/drivers/scsi/csiostor/csio_defs.h index c38017b4af982..e50e93e7fe5a1 100644 --- a/drivers/scsi/csiostor/csio_defs.h +++ b/drivers/scsi/csiostor/csio_defs.h @@ -73,7 +73,21 @@ csio_list_deleted(struct list_head *list) #define csio_list_prev(elem) (((struct list_head *)(elem))->prev) /* State machine */ -typedef void (*csio_sm_state_t)(void *, uint32_t); +struct csio_lnode; + +/* State machine evets */ +enum csio_ln_ev { + CSIO_LNE_NONE = (uint32_t)0, + CSIO_LNE_LINKUP, + CSIO_LNE_FAB_INIT_DONE, + CSIO_LNE_LINK_DOWN, + CSIO_LNE_DOWN_LINK, + CSIO_LNE_LOGO, + CSIO_LNE_CLOSE, + CSIO_LNE_MAX_EVENT, +}; + +typedef void (*csio_sm_state_t)(struct csio_lnode *ln, enum csio_ln_ev evt); struct csio_sm { struct list_head sm_list; @@ -83,7 +97,7 @@ struct csio_sm { static inline void csio_set_state(void *smp, void *state) { - ((struct csio_sm *)smp)->sm_state = (csio_sm_state_t)state; + ((struct csio_sm *)smp)->sm_state = state; } static inline void diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c index d5ac938970232..5b3ffefae476d 100644 --- a/drivers/scsi/csiostor/csio_lnode.c +++ b/drivers/scsi/csiostor/csio_lnode.c @@ -1095,7 +1095,7 @@ csio_handle_link_down(struct csio_hw *hw, uint8_t portid, uint32_t fcfi, int csio_is_lnode_ready(struct csio_lnode *ln) { - return (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)); + return (csio_get_state(ln) == csio_lns_ready); } /*****************************************************************************/ @@ -1366,15 +1366,15 @@ csio_free_fcfinfo(struct kref *kref) void csio_lnode_state_to_str(struct csio_lnode *ln, int8_t *str) { - if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_uninit)) { + if (csio_get_state(ln) == csio_lns_uninit) { strcpy(str, "UNINIT"); return; } - if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)) { + if (csio_get_state(ln) == csio_lns_ready) { strcpy(str, "READY"); return; } - if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_offline)) { + if (csio_get_state(ln) == csio_lns_offline) { strcpy(str, "OFFLINE"); return; } diff --git a/drivers/scsi/csiostor/csio_lnode.h b/drivers/scsi/csiostor/csio_lnode.h index 372a67d122d38..607698a0f0631 100644 --- a/drivers/scsi/csiostor/csio_lnode.h +++ b/drivers/scsi/csiostor/csio_lnode.h @@ -53,19 +53,6 @@ extern int csio_fcoe_rnodes; extern int csio_fdmi_enable; -/* State machine evets */ -enum csio_ln_ev { - CSIO_LNE_NONE = (uint32_t)0, - CSIO_LNE_LINKUP, - CSIO_LNE_FAB_INIT_DONE, - CSIO_LNE_LINK_DOWN, - CSIO_LNE_DOWN_LINK, - CSIO_LNE_LOGO, - CSIO_LNE_CLOSE, - CSIO_LNE_MAX_EVENT, -}; - - struct csio_fcf_info { struct list_head list; uint8_t priority; -- 2.43.0