scsi: elx: efct: Fix void-pointer-to-enum-cast warning for efc_nport_topology
authorJames Smart <jsmart2021@gmail.com>
Mon, 30 Aug 2021 23:10:50 +0000 (16:10 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 14 Sep 2021 02:15:40 +0000 (22:15 -0400)
The kernel test robot flagged an warning for ".../efc_device.c:932:6:
warning: cast to smaller integer type 'enum efc_nport_topology' from 'void
*'"

For the topology events, the "arg" field is generically defined as a void *
and is used to pass different arguments. Most of the arguments are pointers
to data structures. But for the EFC_EVT_NPORT_TOPOLOGY_NOTIFY event, the
argument is an enum value, and the code is typecasting the void * to an
enum generating the warning.

Fix by converting the EFC_EVT_NPORT_TOPOLOGY_NOTIFY event to pass a pointer
to the enum, thus it's a straight-forward pointer dereference in the event
handler.

Link: https://lore.kernel.org/r/20210830231050.5951-1-jsmart2021@gmail.com
Fixes: 202bfdffae27 ("scsi: elx: libefc: FC node ELS and state handling")
Reported-by: kernel test robot <lkp@intel.com>
Co-developed-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: Ram Vegesna <ram.vegesna@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/elx/libefc/efc_device.c
drivers/scsi/elx/libefc/efc_fabric.c

index 725ca2a23fb2a39c855d54d7f670820e28809648..52be01333c6e36c75fcb55c07579ca60a4c1e6ec 100644 (file)
@@ -928,22 +928,21 @@ __efc_d_wait_topology_notify(struct efc_sm_ctx *ctx,
                break;
 
        case EFC_EVT_NPORT_TOPOLOGY_NOTIFY: {
-               enum efc_nport_topology topology =
-                                       (enum efc_nport_topology)arg;
+               enum efc_nport_topology *topology = arg;
 
                WARN_ON(node->nport->domain->attached);
 
                WARN_ON(node->send_ls_acc != EFC_NODE_SEND_LS_ACC_PLOGI);
 
                node_printf(node, "topology notification, topology=%d\n",
-                           topology);
+                           *topology);
 
                /* At the time the PLOGI was received, the topology was unknown,
                 * so we didn't know which node would perform the domain attach:
                 * 1. The node from which the PLOGI was sent (p2p) or
                 * 2. The node to which the FLOGI was sent (fabric).
                 */
-               if (topology == EFC_NPORT_TOPO_P2P) {
+               if (*topology == EFC_NPORT_TOPO_P2P) {
                        /* if this is p2p, need to attach to the domain using
                         * the d_id from the PLOGI received
                         */
index d397220d9e543258f636fcf3cfee55f3e0aa13b6..3270ce40196c6f5ba6f7f6f36400de179f672470 100644 (file)
@@ -107,7 +107,6 @@ void
 efc_fabric_notify_topology(struct efc_node *node)
 {
        struct efc_node *tmp_node;
-       enum efc_nport_topology topology = node->nport->topology;
        unsigned long index;
 
        /*
@@ -118,7 +117,7 @@ efc_fabric_notify_topology(struct efc_node *node)
                if (tmp_node != node) {
                        efc_node_post_event(tmp_node,
                                            EFC_EVT_NPORT_TOPOLOGY_NOTIFY,
-                                           (void *)topology);
+                                           &node->nport->topology);
                }
        }
 }