power: fix socket indicator value
authorMarcin Hajkowski <marcinx.hajkowski@intel.com>
Fri, 27 Sep 2019 08:42:13 +0000 (09:42 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 27 Oct 2019 18:26:35 +0000 (19:26 +0100)
Currently 0 is being used for not connected slot indication.
This is not consistent with linux doc which identifies 0 as valid
(connected) slot, thus modification was done to change it.

Fixes: cd0d5547 ("power: vm communication channels in guest")
Cc: stable@dpdk.org
Signed-off-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_power/guest_channel.c

index c17ea46..9cf7d2c 100644 (file)
@@ -19,7 +19,7 @@
 
 #define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
 
-static int global_fds[RTE_MAX_LCORE];
+static int global_fds[RTE_MAX_LCORE] = { [0 ... RTE_MAX_LCORE-1] = -1 };
 
 int
 guest_channel_host_connect(const char *path, unsigned int lcore_id)
@@ -35,7 +35,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)
                return -1;
        }
        /* check if path is already open */
-       if (global_fds[lcore_id] != 0) {
+       if (global_fds[lcore_id] != -1) {
                RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is already open with fd %d\n",
                                lcore_id, global_fds[lcore_id]);
                return -1;
@@ -84,7 +84,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)
        return 0;
 error:
        close(fd);
-       global_fds[lcore_id] = 0;
+       global_fds[lcore_id] = -1;
        return -1;
 }
 
@@ -100,7 +100,7 @@ guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id)
                return -1;
        }
 
-       if (global_fds[lcore_id] == 0) {
+       if (global_fds[lcore_id] < 0) {
                RTE_LOG(ERR, GUEST_CHANNEL, "Channel is not connected\n");
                return -1;
        }
@@ -134,8 +134,8 @@ guest_channel_host_disconnect(unsigned int lcore_id)
                                lcore_id, RTE_MAX_LCORE-1);
                return;
        }
-       if (global_fds[lcore_id] == 0)
+       if (global_fds[lcore_id] < 0)
                return;
        close(global_fds[lcore_id]);
-       global_fds[lcore_id] = 0;
+       global_fds[lcore_id] = -1;
 }