summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-03-22 02:58:16 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-03-22 02:58:16 +0000
commit81a4ed1f9bea64d8ab270ac7a0391bc2e946299e (patch)
tree229f2de12a7e1e52c1345b0c633e650fb6ff6a92
parentcfd1633a697a51c117be976293541e310d357c36 (diff)
Clean up xfree() usage in rcs_choosefile().
OK xsa@
-rw-r--r--usr.bin/rcs/rcsprog.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c
index 1ed0cbb4e0b..f63e430bdbb 100644
--- a/usr.bin/rcs/rcsprog.c
+++ b/usr.bin/rcs/rcsprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.c,v 1.82 2006/03/21 08:34:36 xsa Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.83 2006/03/22 02:58:15 ray Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -306,10 +306,8 @@ rcs_choosefile(const char *filename)
/* Construct RCS file path. */
if (strlcpy(fpath, rcspath, sizeof(fpath)) >= sizeof(fpath) ||
- strlcat(fpath, ext, sizeof(fpath)) >= sizeof(fpath)) {
- xfree(suffixes);
- return (NULL);
- }
+ strlcat(fpath, ext, sizeof(fpath)) >= sizeof(fpath))
+ goto out;
/* Don't use `filename' as RCS file. */
if (strcmp(fpath, filename) == 0)
@@ -317,26 +315,24 @@ rcs_choosefile(const char *filename)
if (stat(fpath, &sb) == 0) {
ret = xstrdup(fpath);
- break;
+ goto out;
}
}
/*
- * If `ret' is still NULL no RCS file with any extension exists
+ * `ret' is still NULL. No RCS file with any extension exists
* so we use the first extension.
+ *
+ * `suffixes' should now be NUL separated, so the first
+ * extension can be read just by reading `suffixes'.
*/
- if (ret == NULL) {
- /*
- * `suffixes' should now be NUL separated, so the first
- * extension can be read just by reading `suffixes'.
- */
- if (strlcat(rcspath, suffixes, sizeof(rcspath)) >= sizeof(rcspath)) {
- xfree(suffixes);
- return (NULL);
- }
- ret = xstrdup(rcspath);
- }
+ if (strlcat(rcspath, suffixes, sizeof(rcspath)) >=
+ sizeof(rcspath))
+ goto out;
+ ret = xstrdup(rcspath);
+out:
+ /* `ret' may be NULL, which indicates an error. */
xfree(suffixes);
return (ret);
}