[Spice-commits] 2 commits - tools/reds_stat.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Dec 23 17:05:19 UTC 2018


 tools/reds_stat.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit f7859820a12d9d8d4024004824942305d84e5500
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 22 08:37:14 2018 +0000

    reds_stat: Use EXIT_SUCCESS/EXIT_FAILURE for program result
    
    -1 is not much portable and standard.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Snir Sheriber <ssheribe at redhat.com>

diff --git a/tools/reds_stat.c b/tools/reds_stat.c
index 3110afb4..deffec1b 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,18 +102,18 @@ 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) {
         perror("shm_open");
         free(shm_name);
-        return -1;
+        return ret;
     }
     shm_size = sizeof(SpiceStat);
     reds_stat = (SpiceStat *)mmap(NULL, shm_size, PROT_READ, MAP_SHARED, fd, 0);
@@ -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);
commit caefeececdba5bba3bcc5eae7d1b9a509f9a6d93
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 22 08:14:25 2018 +0000

    reds_stat: Print errors on standard error, not standard output
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Snir Sheriber <ssheribe at redhat.com>

diff --git a/tools/reds_stat.c b/tools/reds_stat.c
index 10016fdb..3110afb4 100644
--- a/tools/reds_stat.c
+++ b/tools/reds_stat.c
@@ -101,7 +101,7 @@ int main(int argc, char **argv)
     }
 
     if (argc > 2 || !kvm_pid) {
-        printf("usage: reds_stat [qemu_pid] (e.g. `pgrep qemu`)\n");
+        fprintf(stderr, "usage: reds_stat [qemu_pid] (e.g. `pgrep qemu`)\n");
         return -1;
     }
     shm_name_len = strlen(SPICE_STAT_SHM_NAME) + 64;
@@ -128,11 +128,11 @@ int main(int argc, char **argv)
         goto error;
     }
     if (reds_stat->magic != SPICE_STAT_MAGIC) {
-        printf("bad magic %u\n", reds_stat->magic);
+        fprintf(stderr, "bad magic %u\n", reds_stat->magic);
         goto error;
     }
     if (reds_stat->version != SPICE_STAT_VERSION) {
-        printf("bad version %u\n", reds_stat->version);
+        fprintf(stderr, "bad version %u\n", reds_stat->version);
         goto error;
     }
     while (1) {


More information about the Spice-commits mailing list