Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2619014lqp; Mon, 25 Mar 2024 04:46:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBqEezLx9jYTotAW/zmIgkBiyWryr/3I7mtLOBw+R3PLhAM60bhz6vgcxNef74RuYXnBLCsUqHDV+YsTv1m3KaVsLG11dsLPSzamhDKA== X-Google-Smtp-Source: AGHT+IH1s8PXiv5GOcQlTrPsTwLU53wxOTmXcMS6YCI24P3dTZkzOfIGagIhzutFHQSw2nv4oxAY X-Received: by 2002:a0d:cc93:0:b0:611:9d5b:5ece with SMTP id o141-20020a0dcc93000000b006119d5b5ecemr788644ywd.11.1711367172597; Mon, 25 Mar 2024 04:46:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711367172; cv=pass; d=google.com; s=arc-20160816; b=C7GHq5yw+bnqe02zYzRpjdV5mX9gTvGUJl9FnfRjr/w5Js7ykhgAvnZNHc4l9bJYxl VWItvitMMKEW314YTPciUenpcWG9+JazNnhQZGpQY9U2NRv1/mhTDHsAyV+Q95PuIGAS t28VOPZrARwFnEXiFzgXWPKIsuiklCfAroGUrM28zNvhCZ0tO2Jb1UClr+NZq0wQoa3d nVwbc87MvSoMWNCaaSG32GopyGsHvaHHyrPKaZQTQGcXuPOnYlfrPyDwgDPMjzqEqpqJ 5T7VwA7iW6MT+A0koKTkx6h7IonXFwjij6QO9e+cTWYpJP2Ts984Cq5tvdsiihEl7MoL JMNA== 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=Oya+TPLtqR+OOi3sjv8JUYgqVkftuI/ySDnm7pUvUBsAS37YltwURSge8sespJN4o2 T9ELAwVIwNASm7YEY8s0WYwPEVf0cQ49Vmm2UK9WEpYg5Bgl58XnNXXF7w9bvExLWRE/ IIXYP5HCScaT8IpbcnPZL0SVeat2NNzpkNEWMJsHyuztYjh82k/9xORgjsOExJ6U5Nzx 2yvdIh7AeBx0I8GbX8Qt4oTi1tXRUqD1Ou1KXWpPHVrog4RBEqg62YQOdXTXYe6R1TZ6 8Mt6ke4njdj/aLHPhDvQdt6n3cPUMBPH4xpu55R2tlfqSlXYL80EPAYWsUeAuCkqPUOy ZuQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M8nnCtUY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116204-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gi13-20020a056214248d00b00690db7656eesi7658602qvb.57.2024.03.25.04.46.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:46:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M8nnCtUY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116204-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 465A51C35307 for ; Mon, 25 Mar 2024 11:46:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A40A285278; Mon, 25 Mar 2024 03:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M8nnCtUY" 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 8F5FF5C613; Sun, 24 Mar 2024 23:43:36 +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=1711323816; cv=none; b=f3LDhp5keTl6pouM+criV631Qe4hBQrMe06zK78CKVmm47fuMPSFmPcZ/NisLYQ61OvqbQxusQWrPhc4v53Uv+bYet9L8bBnH8ziiD2Fbgnln9f5T3AgRsNZ2DQuM53KAqcKFgu/NYEP2brFLR+BzOBVm6ryWeSvYXU9r8PqXiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323816; c=relaxed/simple; bh=AS+JGYpUDsPlHwpiNSjJhMQhjdqKCPCQtDNBzfmKuyQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dqDN+lb6h5KvC4pKigWRQ7ndoOoavASX3DSF40pXyFXUABB4bqejJi/UP5d49qMPMcpVkI9aoYisQRl543U4abEfk0HEzRrj1wGbPNBJaCJmD11bpXsWye19sN0tqZPzcNVRj0Voi6UXE4d6PyMFenwxEfo75i+aK1rbE/yR0Gg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M8nnCtUY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDF0FC433C7; Sun, 24 Mar 2024 23:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323816; bh=AS+JGYpUDsPlHwpiNSjJhMQhjdqKCPCQtDNBzfmKuyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M8nnCtUYd5xs/Nn04yOvfCF4yWNHWl0O8ipKHsSNzafBCBMMSQwEIlHZ55HOgyl6N LlDmWbIBrHbDwm5oi3O/8+W8x9ppf45m8a6x6WkRO0MbUEPOSuzcf3NypGGtrAb1J3 5sC1R52tMtQB6FEdcasmETa4pqUuqInUW5FO/EGPiinbEFPZdvtoiiLCA05pYOBCxF pbNqlNeshY7NTOg7kfPd+bqQ18D3qbAd8lGqqvFcVpQJ2LjM96TTcJM2b7f3SY37Ge Ifkeymhi2iCsvfYRmYnv7QHowZyftMx/9+fn62G3JIJiOmZBoAAzY9RJmEkCVZvAzA HmD0bOmiQpcYg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , "Martin K . Petersen" , Sasha Levin Subject: [PATCH 5.10 195/238] scsi: csiostor: Avoid function pointer casts Date: Sun, 24 Mar 2024 19:39:43 -0400 Message-ID: <20240324234027.1354210-196-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-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