diff options
author | Miles Bader <miles@gnu.org> | 1996-06-21 05:55:31 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-06-21 05:55:31 +0000 |
commit | 9822c47592cbbfdbdeb2e9f6531e064ea355cc85 (patch) | |
tree | 806e2904d38d82e5a168f02288412ccae01458b3 /libdiskfs/opts-append-std.c | |
parent | c67cd904d454ef10ff53871a4aa14e10c24fa598 (diff) |
(diskfs_append_std_options):
Use argz_add instead of rolling our own. Deal with errors.
<argz.h>: New include.
Diffstat (limited to 'libdiskfs/opts-append-std.c')
-rw-r--r-- | libdiskfs/opts-append-std.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/libdiskfs/opts-append-std.c b/libdiskfs/opts-append-std.c index 0d6d172d..505752d5 100644 --- a/libdiskfs/opts-append-std.c +++ b/libdiskfs/opts-append-std.c @@ -20,36 +20,35 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <argz.h> + #include "priv.h" error_t diskfs_append_std_options (char **argz, unsigned *argz_len) { + error_t err; extern int diskfs_sync_interval; - void append_opt (char *str) - { - unsigned old_end = *argz_len; - *argz_len += strlen (str) + 1; - *argz = realloc (*argz, *argz_len); - strcpy (*argz + old_end, str);; - } - if (diskfs_readonly) - append_opt ("--readonly"); + err = argz_add (argz, argz_len, "--readonly"); else - append_opt ("--writable"); + err = argz_add (argz, argz_len, "--writable"); + if (err) + return err; if (diskfs_synchronous) - append_opt ("--sync"); + err = argz_add (argz, argz_len, "--sync"); else if (diskfs_sync_interval == 0) - append_opt ("--nosync"); + err = argz_add (argz, argz_len, "--nosync"); else { char buf[80]; sprintf (buf, "--sync=%d", diskfs_sync_interval); - append_opt (buf); + err = argz_add (argz, argz_len, buf); } + if (err) + free (argz); /* Free the first option allocated. */ - return 0; + return err; } |