Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2527389lqp; Mon, 25 Mar 2024 01:12:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVkbYqO8xAhtDM6JjA26LJ/V6CKQLB8Rm1q667CJ//eg1a+hKpyOgvigNGgtwRYcpoGBfMsCgsmwm6wJ9Kb/q2Z4J9tN/e6ZYdsTbZ0VQ== X-Google-Smtp-Source: AGHT+IFX7d+3iAweXSk445tuhySi3exPjuTLJwzkIWp9DmI4Pp764gF/dT1N2vbZrYuknitXrzi+ X-Received: by 2002:ac8:7dcf:0:b0:431:40c1:1446 with SMTP id c15-20020ac87dcf000000b0043140c11446mr6827140qte.58.1711354337999; Mon, 25 Mar 2024 01:12:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711354337; cv=pass; d=google.com; s=arc-20160816; b=DJnJhnUQwfZ9siZ/Aw6UE7bDLu+usQzwjQ8hW90KFDy/WL59fOVr56s2Ec8G2pp1D/ lqBMWP/9ysSuWBJ2ualVTI4yYrToE5EJtmNDdwKb1XBaHeioM1mBftBqPAFqNANqDzn4 P3FQS2+gc5BeUUGYweE5L/HQA/XJ/bNx4elNIFSJ4+Qch6WIJNt7qV1+vgDs7si6EeCz 9Q3fyQUHGq8pMpRVMy7FEA1SxBrzpZxfnPVJCR26Z19MhWXyGeN9KaG+YanMMIjdHeNG lCETgvVENOkYkhyGaozcIlH7eVJGI7u7N8FkVP5g+OsWCkbyBgWEFS2ExBLcrGTAzDsI 4q8w== 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=PEflrvKx8W+RfEeGRDNteMlc9SlnJiauhltU7LK25Np6XpMvye3S4gfuZ5/9RXfWAA evy/ZPMM8PWXcy90zAVEUOv0fNixHOhAehXULCEu79WfkHWd6+9jqHMdZyIecgxta0Wd u6R22vvfWe4/1iEkLAN8jOc2CEFnrdKl+cWlAXwT3GhkRzb23wZciwwdfCMAhkiq5ya+ 5Qv0gZXdVos3/o6NC+19+HjaLCtA4ctyokSOpj3G0JdDb7MUu5PAFGKriU+zqIr0l3XV 8zpPbNMdSvWq1cz5X2MTDTlwWaw+daGuVrZUAQczVyC5O1Bfuna9S2AkdyyGOTuDjyU4 4SnA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mt2lZwhl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115977-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115977-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. [147.75.199.223]) by mx.google.com with ESMTPS id bp33-20020a05622a1ba100b004312d201fefsi4889541qtb.77.2024.03.25.01.12.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 01:12:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115977-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mt2lZwhl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115977-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115977-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 610D31C2E43A for ; Mon, 25 Mar 2024 08:12:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EC1D2695DC; Mon, 25 Mar 2024 03:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mt2lZwhl" 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 5B66814E2D1; Sun, 24 Mar 2024 23:18:01 +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=1711322281; cv=none; b=Sr9kwztiXfKll6ZrmQJVCuLTJAHMu7ImB7UCjX0zcgzCyyuX4b+saW13OxQS7s5nivnpaOfVzvS+aHYrlkCWwc96lyrsn+p7dESs7Ghar86wYFQ7gFmUdlfudJVrQsk/jEudc7Kp89sJQmM1TMSZWTqzp1TkvXRbZw1v7Km4HHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322281; c=relaxed/simple; bh=AS+JGYpUDsPlHwpiNSjJhMQhjdqKCPCQtDNBzfmKuyQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jVn4eNClFQ/sSPbjvHxbk8JvXd7ZFv4LtS5SOdKevJQb0I0oF8i36Ld/HPnkFnWbQUbOwtZWV9htQe4ZBKfwIoxKBGUoPTgCmzJIUGwIARpvGpTZ23XM9MvkuVDeywe1xxhb5KJkHOzHsyK3VThrQcoabO/RhP9228zFLjkpvJw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mt2lZwhl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91ADEC43394; Sun, 24 Mar 2024 23:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322281; bh=AS+JGYpUDsPlHwpiNSjJhMQhjdqKCPCQtDNBzfmKuyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mt2lZwhlwbRI1NOlbWrr0C4Z6Ad4f39k41bubtwDW/PN5IyqXiLz2TFGtxWZrPCg+ YzfHxqxFpA+FkD3AkwIw4aVjvPCv36W1sKL95QuT2eHMh7Q0AbLn7I3OATUgYMzz82 ewbiPbqRpYS14TLU7YKeVItiX3OcZT84d3V2EF37PVEqc0Q36WYvrZgOJ+Qrdkm229 0hTELRbmMYSeE8YG7j2O1k44J8pW+/1RBL/Bq3dcNPKdqo+WdddQxXHYfIrDW1D4bF pezqWEgkyoHhxYnkoRWDC/bSJEzoLqZZkZ2fIW9hXvfu/RlH2jm5QhTXniOwXzTT4y FzUS2U5j1LuBg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , "Martin K . Petersen" , Sasha Levin Subject: [PATCH 6.1 364/451] scsi: csiostor: Avoid function pointer casts Date: Sun, 24 Mar 2024 19:10:40 -0400 Message-ID: <20240324231207.1351418-365-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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