power: update error handling
authorLukasz Krakowiak <lukaszx.krakowiak@intel.com>
Thu, 28 Mar 2019 15:55:07 +0000 (16:55 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 29 Mar 2019 14:29:31 +0000 (15:29 +0100)
Update for handling negative returned status from functions
call.

Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
examples/vm_power_manager/channel_manager.c
examples/vm_power_manager/channel_monitor.c

index de1a868..09bfa5c 100644 (file)
@@ -224,7 +224,7 @@ open_non_blocking_channel(struct channel_info *info)
        struct timeval tv;
 
        info->fd = socket(AF_UNIX, SOCK_STREAM, 0);
-       if (info->fd == -1) {
+       if (info->fd < 0) {
                RTE_LOG(ERR, CHANNEL_MANAGER, "Error(%s) creating socket for '%s'\n",
                                strerror(errno),
                                info->channel_path);
@@ -285,7 +285,7 @@ open_host_channel(struct channel_info *info)
        int flags;
 
        info->fd = open(info->channel_path, O_RDWR | O_RSYNC);
-       if (info->fd == -1) {
+       if (info->fd < 0) {
                RTE_LOG(ERR, CHANNEL_MANAGER, "Error(%s) opening fifo for '%s'\n",
                                strerror(errno),
                                info->channel_path);
index 1a3a0fa..22f2eb8 100644 (file)
@@ -435,7 +435,7 @@ update_policy(struct channel_packet *pkt)
                        /* Copy the contents of *pkt into the policy.pkt */
                        policies[i].pkt = *pkt;
                        get_pcpu_to_control(&policies[i]);
-                       if (get_pfid(&policies[i]) == -1) {
+                       if (get_pfid(&policies[i]) < 0) {
                                updated = 1;
                                break;
                        }
@@ -449,7 +449,7 @@ update_policy(struct channel_packet *pkt)
                        if (policies[i].enabled == 0) {
                                policies[i].pkt = *pkt;
                                get_pcpu_to_control(&policies[i]);
-                               if (get_pfid(&policies[i]) == -1)
+                               if (get_pfid(&policies[i]) < 0)
                                        break;
                                core_share_status(i);
                                policies[i].enabled = 1;
@@ -756,7 +756,7 @@ read_binary_packet(struct channel_info *chan_info)
                                buffer, buffer_len);
                if (n_bytes == buffer_len)
                        break;
-               if (n_bytes == -1) {
+               if (n_bytes < 0) {
                        err = errno;
                        RTE_LOG(DEBUG, CHANNEL_MONITOR,
                                "Received error on "