summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-11-20 12:09:42 +0100
committerRichard Jones <rjones@redhat.com>2009-11-20 12:14:14 +0000
commitc372c7c23a298a940b8a0868396ef2ae0d824e4d (patch)
tree2c6bec16fd926e0bfd357c2623864f19f666decf /examples
parente94f89f40d989d111882178c87b5bfc22314fca8 (diff)
downloadlibguestfs-c372c7c23a298a940b8a0868396ef2ae0d824e4d.tar.gz
libguestfs-c372c7c23a298a940b8a0868396ef2ae0d824e4d.tar.xz
libguestfs-c372c7c23a298a940b8a0868396ef2ae0d824e4d.zip
maint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 to exit
Convert all uses automatically, via these two commands: git grep -l '\<exit *(1)' \ | grep -vEf .x-sc_prohibit_magic_number_exit \ | xargs --no-run-if-empty \ perl -pi -e 's/\b(exit ?)\(1\)/$1(EXIT_FAILURE)/' git grep -l '\<exit *(0)' \ | grep -vEf .x-sc_prohibit_magic_number_exit \ | xargs --no-run-if-empty \ perl -pi -e 's/\b(exit ?)\(0\)/$1(EXIT_SUCCESS)/' * .x-sc_prohibit_magic_number_exit: New file. Edit (RWMJ): Don't change Java code.
Diffstat (limited to 'examples')
-rw-r--r--examples/hello.c12
-rw-r--r--examples/to-xml.c6
2 files changed, 9 insertions, 9 deletions
diff --git a/examples/hello.c b/examples/hello.c
index 8b36ed44..b4d5d8c6 100644
--- a/examples/hello.c
+++ b/examples/hello.c
@@ -19,18 +19,18 @@ main (int argc, char *argv[])
if (argc != 3 || access (argv[1], F_OK) != 0) {
fprintf (stderr, "Usage: hello disk-image partition\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
- if (!(g = guestfs_create ())) exit (1);
+ if (!(g = guestfs_create ())) exit (EXIT_FAILURE);
- if (guestfs_add_drive (g, argv[1]) == -1) exit (1);
+ if (guestfs_add_drive (g, argv[1]) == -1) exit (EXIT_FAILURE);
- if (guestfs_launch (g) == -1) exit (1);
+ if (guestfs_launch (g) == -1) exit (EXIT_FAILURE);
- if (guestfs_mount (g, argv[2], "/") == -1) exit (1);
+ if (guestfs_mount (g, argv[2], "/") == -1) exit (EXIT_FAILURE);
- if (guestfs_touch (g, "/hello") == -1) exit (1);
+ if (guestfs_touch (g, "/hello") == -1) exit (EXIT_FAILURE);
guestfs_sync (g);
guestfs_close (g);
diff --git a/examples/to-xml.c b/examples/to-xml.c
index 6d0a1dfb..537ae915 100644
--- a/examples/to-xml.c
+++ b/examples/to-xml.c
@@ -25,7 +25,7 @@
* to stderr already.
*/
#define CALL(call,errcode) \
- if ((call) == (errcode)) exit (1);
+ if ((call) == (errcode)) exit (EXIT_FAILURE);
static void display_partition (guestfs_h *g, const char *dev);
static void display_partitions (guestfs_h *g, const char *dev);
@@ -39,12 +39,12 @@ main (int argc, char *argv[])
if (argc < 2 || access (argv[1], F_OK) != 0) {
fprintf (stderr, "Usage: to-xml guest.img [guest.img ...]\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (!(g = guestfs_create ())) {
fprintf (stderr, "Cannot create libguestfs handle.\n");
- exit (1);
+ exit (EXIT_FAILURE);
}
for (i = 1; i < argc; ++i)