[Spice-devel] [PATCH spice-server 2/2] reds_stat: Use EXIT_SUCCESS/EXIT_FAILURE for program result

Frediano Ziglio fziglio at redhat.com
Sat Dec 22 16:45:51 UTC 2018


-1 is not much portable and standard.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 tools/reds_stat.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/reds_stat.c b/tools/reds_stat.c
index 3110afb4..1e83bf10 100644
--- a/tools/reds_stat.c
+++ b/tools/reds_stat.c
@@ -88,7 +88,7 @@ int main(int argc, char **argv)
     size_t shm_size;
     size_t shm_old_size;
     int shm_name_len;
-    int ret = -1;
+    int ret = EXIT_FAILURE;
     int fd;
     struct stat st;
     unsigned header_size = sizeof(SpiceStat);
@@ -102,12 +102,12 @@ int main(int argc, char **argv)
 
     if (argc > 2 || !kvm_pid) {
         fprintf(stderr, "usage: reds_stat [qemu_pid] (e.g. `pgrep qemu`)\n");
-        return -1;
+        return ret;
     }
     shm_name_len = strlen(SPICE_STAT_SHM_NAME) + 64;
     if (!(shm_name = (char *)malloc(shm_name_len))) {
         perror("malloc");
-        return -1;
+        return ret;
     }
     snprintf(shm_name, shm_name_len, SPICE_STAT_SHM_NAME, kvm_pid);
     if ((fd = shm_open(shm_name, O_RDONLY, 0444)) == -1) {
@@ -160,7 +160,7 @@ int main(int argc, char **argv)
         print_stat_tree(reds_stat->root_index, 0);
         sleep(1);
     }
-    ret = 0;
+    ret = EXIT_SUCCESS;
 
 error:
     free(values);
-- 
2.17.2



More information about the Spice-devel mailing list