summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Santolaria <xsa@cvs.openbsd.org>2006-01-27 12:45:22 +0000
committerXavier Santolaria <xsa@cvs.openbsd.org>2006-01-27 12:45:22 +0000
commit739bb3cc929be85a9a068c8a7ad8fcc528c50414 (patch)
tree36125757811e5ed71047703d5f3978d2bbc4b161
parent4b167e6e31e5fa912a7601a93867d55dd06bd7cc (diff)
errors handling cleaning here too;
-rw-r--r--usr.bin/cvs/add.c64
-rw-r--r--usr.bin/cvs/checkout.c10
-rw-r--r--usr.bin/cvs/release.c4
-rw-r--r--usr.bin/cvs/remove.c13
4 files changed, 36 insertions, 55 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index 9404b12d205..45873305503 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.38 2006/01/25 11:19:51 xsa Exp $ */
+/* $OpenBSD: add.c,v 1.39 2006/01/27 12:45:21 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
@@ -141,9 +141,7 @@ cvs_add_local(CVSFILE *cf, void *arg)
(strcmp(cf->cf_name, "..") == 0) ||
(strcmp(cf->cf_name, CVS_PATH_CVSDIR) == 0)) {
if (verbosity > 1)
- cvs_log(LP_ERR,
- "cannot add special file `%s'.", cf->cf_name);
- return (CVS_EX_FILE);
+ fatal("cannot add special file `%s'.", cf->cf_name);
}
if (cf->cf_type == DT_DIR)
@@ -230,14 +228,11 @@ cvs_add_directory(CVSFILE *cf)
repo = CVS_DIR_REPO(cf);
if (strlcpy(fpath, cf->cf_name, sizeof(fpath)) >= sizeof(fpath))
- return (CVS_EX_DATA);
+ fatal("cvs_add_directory: path truncation");
- if (strchr(fpath, '/') != NULL) {
- cvs_log(LP_ERR,
- "directory %s not added; must be a direct sub-directory",
+ if (strchr(fpath, '/') != NULL)
+ fatal("directory %s not added; must be a direct sub-directory",
fpath);
- return (CVS_EX_FILE);
- }
/* Let's see if we have any per-directory tags first */
cvs_parse_tagfile(&tag, &date, &nb);
@@ -249,11 +244,9 @@ cvs_add_directory(CVSFILE *cf)
strlcat(rcsdir, repo, sizeof(rcsdir)) >= sizeof(rcsdir))
fatal("cvs_add_directory: path truncation");
- if ((stat(rcsdir, &st) == 0) && !(S_ISDIR(st.st_mode))) {
- cvs_log(LP_ERRNO,
- "%s is not a directory; %s not added", rcsdir, fpath);
- return (CVS_EX_FILE);
- }
+ if ((stat(rcsdir, &st) == 0) && !(S_ISDIR(st.st_mode)))
+ fatal("%s is not a directory; %s not added: %s", rcsdir, fpath,
+ strerror(errno));
snprintf(msg, sizeof(msg),
"Directory %s added to the repository", rcsdir);
@@ -271,10 +264,9 @@ cvs_add_directory(CVSFILE *cf)
strlcat(msg, "\n", sizeof(msg));
if (cvs_noexec == 0) {
- if (mkdir(rcsdir, 0777) == -1) {
- cvs_log(LP_ERRNO, "failed to create %s", rcsdir);
- return (CVS_EX_FILE);
- }
+ if (mkdir(rcsdir, 0777) == -1)
+ fatal("cvs_add_directory: mkdir `%s': %s",
+ rcsdir, strerror(errno));
}
/* create CVS/ admin files */
@@ -288,15 +280,11 @@ cvs_add_directory(CVSFILE *cf)
strlcat(entry, "////", sizeof(entry)) >= sizeof(entry))
fatal("cvs_add_directory: path truncation");
- if ((ent = cvs_ent_parse(entry)) == NULL) {
- cvs_log(LP_ERR, "failed to parse entry");
- return (CVS_EX_DATA);
- }
+ if ((ent = cvs_ent_parse(entry)) == NULL)
+ fatal("cvs_add_directory: cvs_ent_parse failed");
- if (cvs_ent_add(entf, ent) < 0) {
- cvs_log(LP_ERR, "failed to add entry");
- return (CVS_EX_DATA);
- }
+ if (cvs_ent_add(entf, ent) < 0)
+ fatal("cvs_add_directory: cvs_ent_parse failed");
cvs_printf("%s", msg);
@@ -323,18 +311,14 @@ cvs_add_build_entry(CVSFILE *cf)
strlcat(path, CVS_DESCR_FILE_EXT, sizeof(path)) >= sizeof(path))
fatal("cvs_add_build_entry: path truncation");
- fp = fopen(path, "w+");
- if (fp == NULL) {
- cvs_log(LP_ERRNO, "failed to open `%s'", path);
- return (CVS_EX_FILE);
- }
+ if ((fp = fopen(path, "w+")) == NULL)
+ fatal("cvs_add_build_entry: fopen `%s': %s", path,
+ strerror(errno));
if (cvs_msg != NULL) {
- if (fputs(cvs_msg, fp) == EOF) {
- cvs_log(LP_ERRNO, "cannot write to `%s'", path);
- (void)fclose(fp);
- return (CVS_EX_FILE);
- }
+ if (fputs(cvs_msg, fp) == EOF)
+ fatal("cvs_add_build_entry: fputs `%s': %s", path,
+ strerror(errno));
}
(void)fclose(fp);
@@ -351,15 +335,13 @@ cvs_add_build_entry(CVSFILE *cf)
}
if ((ent = cvs_ent_parse(entry)) == NULL) {
- cvs_log(LP_ERR, "failed to parse entry");
(void)cvs_unlink(path);
- return (CVS_EX_DATA);
+ fatal("cvs_add_build_entry: cvs_ent_parse failed");
}
if (cvs_ent_add(entf, ent) < 0) {
- cvs_log(LP_ERR, "failed to add entry");
(void)cvs_unlink(path);
- return (CVS_EX_DATA);
+ fatal("cvs_add_build_entry: cvs_ent_add failed");
}
return (0);
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 662effce0db..2688c9b56cb 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.46 2006/01/27 10:53:23 xsa Exp $ */
+/* $OpenBSD: checkout.c,v 1.47 2006/01/27 12:45:21 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -319,11 +319,9 @@ cvs_checkout_local(CVSFILE *cf, void *arg)
* create the repository directory for us.
*/
if (cvs_create_dir(fpath, 1, root->cr_dir, NULL) < 0)
- return (CVS_EX_FILE);
- if (fchdir(cwdfd) < 0) {
- cvs_log(LP_ERRNO, "fchdir failed");
- return (CVS_EX_FILE);
- }
+ fatal("cvs_checkout_local: cvs_create_dir failed");
+ if (fchdir(cwdfd) < 0)
+ fatal("cvs_checkout_local: fchdir failed");
} else {
/*
* TODO: send responses to client so it'll
diff --git a/usr.bin/cvs/release.c b/usr.bin/cvs/release.c
index 1645d203a15..0779c859d5f 100644
--- a/usr.bin/cvs/release.c
+++ b/usr.bin/cvs/release.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: release.c,v 1.29 2006/01/03 12:47:14 xsa Exp $ */
+/* $OpenBSD: release.c,v 1.30 2006/01/27 12:45:21 xsa Exp $ */
/*
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -215,7 +215,7 @@ cvs_release_dir(CVSFILE *cf, void *arg)
if (dflag == 1) {
if (cvs_rmdir(dpath) != 0)
- return (CVS_EX_FILE);
+ fatal("cvs_release_dir: cvs_rmdir failed");
}
return (0);
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index b9722ce8cda..2619dceaba1 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.41 2006/01/25 08:15:05 xsa Exp $ */
+/* $OpenBSD: remove.c,v 1.42 2006/01/27 12:45:21 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004, 2005 Xavier Santolaria <xsa@openbsd.org>
@@ -110,7 +110,7 @@ cvs_remove_remote(CVSFILE *cf, void *arg)
cvs_file_getpath(cf, fpath, sizeof(fpath));
if (cvs_remove_file(fpath) < 0)
- return (CVS_EX_FILE);
+ fatal("cvs_remove_remote: cvs_remove_file `%s' failed", fpath);
cvs_sendentry(root, cf);
@@ -146,7 +146,8 @@ cvs_remove_local(CVSFILE *cf, void *arg)
cvs_file_getpath(cf, fpath, sizeof(fpath));
if (cvs_remove_file(fpath) < 0)
- return (CVS_EX_FILE);
+ fatal("cvs_remove_local: cvs_remove_file `%s' failed",
+ fpath);
}
if (nuked == 0) {
@@ -161,7 +162,7 @@ cvs_remove_local(CVSFILE *cf, void *arg)
return (0);
} else if (cf->cf_cvstat == CVS_FST_ADDED) {
if (cvs_ent_remove(entf, cf->cf_name, 0) == -1)
- return (CVS_EX_FILE);
+ fatal("cvs_remove_local: cvs_ent_remove failed");
if (strlcpy(buf, CVS_PATH_CVSDIR, sizeof(buf)) >= sizeof(buf) ||
strlcat(buf, "/", sizeof(buf)) >= sizeof(buf) ||
@@ -171,7 +172,7 @@ cvs_remove_local(CVSFILE *cf, void *arg)
fatal("cvs_remove_local: path truncation");
if (cvs_unlink(buf) == -1)
- return (CVS_EX_FILE);
+ fatal("cvs_remove_local: cvs_unlink `%s' failed", buf);
if (verbosity > 1)
cvs_log(LP_NOTICE, "removed `%s'", cf->cf_name);
@@ -184,7 +185,7 @@ cvs_remove_local(CVSFILE *cf, void *arg)
return (0);
} else {
if ((ent = cvs_ent_get(entf, cf->cf_name)) == NULL)
- return (CVS_EX_DATA);
+ fatal("cvs_remove_local: cvs_ent_get failed");
/* Prefix revision with `-' */
ent->ce_status = CVS_ENT_REMOVED;