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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,


On 12/22/18 6:45 PM, Frediano Ziglio wrote:
-1 is not much portable and standard.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
  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);


If we keep return -1 when shm_open fail we may want also to return -1 when mremap fail

Otherwise, ack for both.

Snir.

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]