diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2006-08-16 07:39:16 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2006-08-16 07:39:16 +0000 |
commit | dd109580266c56df7b5feb24de5100e6d457579f (patch) | |
tree | b386c6f592769599dd4e9d5d096971816e90aa69 /usr.bin/rcs/rcsutil.c | |
parent | 65bc33032d45046943c4d18a409e2c0e7d02b696 (diff) |
Improve rcs_buf_load() by setting errno appropriately on failure and
never print errors or quit on error.
Fix usages of rcs_buf_load() and rcs_set_description.
Also plug an fd leak.
OK xsa@
Diffstat (limited to 'usr.bin/rcs/rcsutil.c')
-rw-r--r-- | usr.bin/rcs/rcsutil.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c index 3a7b3da11f8..6c25e21acd2 100644 --- a/usr.bin/rcs/rcsutil.c +++ b/usr.bin/rcs/rcsutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsutil.c,v 1.17 2006/07/08 09:14:03 ray Exp $ */ +/* $OpenBSD: rcsutil.c,v 1.18 2006/08/16 07:39:15 ray Exp $ */ /* * Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -437,8 +437,9 @@ rcs_rev_select(RCSFILE *file, const char *range) * If <in> starts with a `-', <in> is taken as the description. * Otherwise <in> is the name of the file containing the description. * If <in> is NULL, the description is read from stdin. + * Returns 0 on success, -1 on failure, setting errno. */ -void +int rcs_set_description(RCSFILE *file, const char *in) { BUF *bp; @@ -449,7 +450,8 @@ rcs_set_description(RCSFILE *file, const char *in) /* Description is in file <in>. */ if (in != NULL && *in != '-') { - bp = rcs_buf_load(in, BUF_AUTOEXT); + if ((bp = rcs_buf_load(in, BUF_AUTOEXT)) == NULL) + return (-1); rcs_buf_putc(bp, '\0'); content = rcs_buf_release(bp); /* Description is in <in>. */ @@ -462,6 +464,7 @@ rcs_set_description(RCSFILE *file, const char *in) rcs_desc_set(file, content); xfree(content); + return (0); } /* |