summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2005-12-30 02:03:29 +0000
committerJoris Vink <joris@cvs.openbsd.org>2005-12-30 02:03:29 +0000
commiteba90c397238078d4145046f9f6056ced60b52a2 (patch)
tree066c330f8d693daf3ac9fd783129c19fb2049af8 /usr.bin/cvs
parent0a6f2c57253516d05a4ecc720d8b82cc8f25697a (diff)
major cleanup of the functions handling the remote cvs protocol.
makes the code a lot more readable and understandable. ok xsa@ and niallo@
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/add.c24
-rw-r--r--usr.bin/cvs/admin.c138
-rw-r--r--usr.bin/cvs/annotate.c46
-rw-r--r--usr.bin/cvs/checkout.c69
-rw-r--r--usr.bin/cvs/cmd.c25
-rw-r--r--usr.bin/cvs/commit.c28
-rw-r--r--usr.bin/cvs/cvs.h4
-rw-r--r--usr.bin/cvs/diff.c51
-rw-r--r--usr.bin/cvs/edit.c30
-rw-r--r--usr.bin/cvs/getlog.c40
-rw-r--r--usr.bin/cvs/history.c51
-rw-r--r--usr.bin/cvs/import.c31
-rw-r--r--usr.bin/cvs/logmsg.c12
-rw-r--r--usr.bin/cvs/proto.c303
-rw-r--r--usr.bin/cvs/proto.h20
-rw-r--r--usr.bin/cvs/release.c6
-rw-r--r--usr.bin/cvs/remove.c29
-rw-r--r--usr.bin/cvs/status.c36
-rw-r--r--usr.bin/cvs/tag.c59
-rw-r--r--usr.bin/cvs/update.c65
-rw-r--r--usr.bin/cvs/watch.c52
21 files changed, 443 insertions, 676 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index 0b8d3b57730..fc95805e2c7 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.35 2005/12/10 20:27:45 joris Exp $ */
+/* $OpenBSD: add.c,v 1.36 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
@@ -110,10 +110,8 @@ cvs_add_pre_exec(struct cvsroot *root)
strlcpy(kbuf, "-k", sizeof(kbuf));
strlcat(kbuf, koptstr, sizeof(kbuf));
- if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cvs_sendarg(root, kbuf, 0) < 0)
- return (CVS_EX_PROTO);
- }
+ if (root->cr_method != CVS_METHOD_LOCAL)
+ cvs_sendarg(root, kbuf, 0);
}
return (0);
@@ -122,27 +120,19 @@ cvs_add_pre_exec(struct cvsroot *root)
static int
cvs_add_remote(CVSFILE *cf, void *arg)
{
- int ret;
struct cvsroot *root;
- ret = 0;
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
- ret = cvs_senddir(root, cf);
- if (ret == -1)
- ret = CVS_EX_PROTO;
- return (ret);
+ cvs_senddir(root, cf);
+ return (0);
}
if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED,
- cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ return (0);
}
static int
diff --git a/usr.bin/cvs/admin.c b/usr.bin/cvs/admin.c
index 389c62c7a1f..e56eb406477 100644
--- a/usr.bin/cvs/admin.c
+++ b/usr.bin/cvs/admin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: admin.c,v 1.24 2005/12/22 14:59:54 xsa Exp $ */
+/* $OpenBSD: admin.c,v 1.25 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
@@ -216,82 +216,81 @@ cvs_admin_pre_exec(struct cvsroot *root)
if (root->cr_method == CVS_METHOD_LOCAL)
return (0);
- if ((alist != NULL) && ((cvs_sendarg(root, "-a", 0) < 0) ||
- (cvs_sendarg(root, alist, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (alist != NULL) {
+ cvs_sendarg(root, "-a", 0);
+ cvs_sendarg(root, alist, 0);
+ }
- if ((userfile != NULL) && ((cvs_sendarg(root, "-A", 0) < 0) ||
- (cvs_sendarg(root, userfile, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (userfile != NULL) {
+ cvs_sendarg(root, "-A", 0);
+ cvs_sendarg(root, userfile, 0);
+ }
if (runflags & FLAG_BRANCH) {
- if (cvs_sendarg(root, "-b", 0) < 0)
- return (CVS_EX_PROTO);
- if ((branch_arg != NULL) &&
- (cvs_sendarg(root, branch_arg, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-b", 0);
+ if (branch_arg != NULL)
+ cvs_sendarg(root, branch_arg, 0);
}
- if ((comment != NULL) && ((cvs_sendarg(root, "-c", 0) < 0) ||
- (cvs_sendarg(root, comment, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (comment != NULL) {
+ cvs_sendarg(root, "-c", 0);
+ cvs_sendarg(root, comment, 0);
+ }
if (runflags & FLAG_DELUSER) {
- if (cvs_sendarg(root, "-e", 0) < 0)
- return (CVS_EX_PROTO);
- if ((elist != NULL) &&
- (cvs_sendarg(root, elist, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-e", 0);
+ if (elist != NULL)
+ cvs_sendarg(root, elist, 0);
}
- if (runflags & FLAG_INTERACTIVE) {
- if (cvs_sendarg(root, "-I", 0) < 0)
- return (CVS_EX_PROTO);
- }
+ if (runflags & FLAG_INTERACTIVE)
+ cvs_sendarg(root, "-I", 0);
- if ((subst != NULL) && ((cvs_sendarg(root, "-k", 0) < 0) ||
- (cvs_sendarg(root, subst, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (subst != NULL) {
+ cvs_sendarg(root, "-k", 0);
+ cvs_sendarg(root, subst, 0);
+ }
if (lockrev & LOCK_SET) {
- if (cvs_sendarg(root, "-l", 0) < 0)
- return (CVS_EX_PROTO);
- if ((lockrev_arg != NULL) &&
- (cvs_sendarg(root, lockrev_arg, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-l", 0);
+ if (lockrev_arg != NULL)
+ cvs_sendarg(root, lockrev_arg, 0);
}
- if ((lkmode == RCS_LOCK_STRICT) && (cvs_sendarg(root, "-L", 0) < 0))
- return (CVS_EX_PROTO);
- else if ((lkmode == RCS_LOCK_LOOSE) && (cvs_sendarg(root, "-U", 0) < 0))
- return (CVS_EX_PROTO);
+ if (lkmode == RCS_LOCK_STRICT)
+ cvs_sendarg(root, "-L", 0);
+ else if (lkmode == RCS_LOCK_LOOSE)
+ cvs_sendarg(root, "-U", 0);
- if ((replace_msg != NULL) && ((cvs_sendarg(root, "-m", 0) < 0)
- || (cvs_sendarg(root, replace_msg, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (replace_msg != NULL) {
+ cvs_sendarg(root, "-m", 0);
+ cvs_sendarg(root, replace_msg, 0);
+ }
- if ((ntag != NULL) && ((cvs_sendarg(root, "-n", 0) < 0) ||
- (cvs_sendarg(root, ntag, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (ntag != NULL) {
+ cvs_sendarg(root, "-n", 0);
+ cvs_sendarg(root, ntag, 0);
+ }
- if ((Ntag != NULL) && ((cvs_sendarg(root, "-N", 0) < 0) ||
- (cvs_sendarg(root, Ntag, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (Ntag != NULL) {
+ cvs_sendarg(root, "-N", 0);
+ cvs_sendarg(root, Ntag, 0);
+ }
- if ((range != NULL) && ((cvs_sendarg(root, "-o", 0) < 0) ||
- (cvs_sendarg(root, range, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (range != NULL) {
+ cvs_sendarg(root, "-o", 0);
+ cvs_sendarg(root, range, 0);
+ }
- if ((state != NULL) && ((cvs_sendarg(root, "-s", 0) < 0) ||
- (cvs_sendarg(root, state, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (state != NULL) {
+ cvs_sendarg(root, "-s", 0);
+ cvs_sendarg(root, state, 0);
+ }
if (lockrev & LOCK_REMOVE) {
- if (cvs_sendarg(root, "-u", 0) < 0)
- return (CVS_EX_PROTO);
- if ((unlockrev_arg != NULL) &&
- (cvs_sendarg(root, unlockrev_arg, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-u", 0);
+ if (unlockrev_arg != NULL)
+ cvs_sendarg(root, unlockrev_arg, 0);
}
return (0);
@@ -305,47 +304,38 @@ cvs_admin_pre_exec(struct cvsroot *root)
static int
cvs_admin_remote(CVSFILE *cf, void *arg)
{
- int ret;
char *repo, fpath[MAXPATHLEN];
struct cvsroot *root;
- ret = 0;
root = CVS_DIR_ROOT(cf);
repo = CVS_DIR_REPO(cf);
if (cf->cf_type == DT_DIR) {
if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
else
- ret = cvs_senddir(root, cf);
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ cvs_senddir(root, cf);
+ return (0);
}
cvs_file_getpath(cf, fpath, sizeof(fpath));
-
- if (cvs_sendentry(root, cf) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendentry(root, cf);
switch (cf->cf_cvstat) {
case CVS_FST_UNKNOWN:
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
break;
case CVS_FST_UPTODATE:
- ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
break;
case CVS_FST_MODIFIED:
- ret = cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name);
- if (ret == 0)
- ret = cvs_sendfile(root, fpath);
+ cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name);
+ cvs_sendfile(root, fpath);
default:
break;
}
- return (ret);
+ return (0);
}
/*
diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c
index e1a3f964623..065dd6c7f97 100644
--- a/usr.bin/cvs/annotate.c
+++ b/usr.bin/cvs/annotate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: annotate.c,v 1.24 2005/12/22 14:59:54 xsa Exp $ */
+/* $OpenBSD: annotate.c,v 1.25 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -37,7 +37,6 @@
#include "log.h"
#include "proto.h"
-
static int cvs_annotate_init(struct cvs_cmd *, int, char **, int *);
static int cvs_annotate_remote(CVSFILE *, void *);
static int cvs_annotate_local(CVSFILE *, void *);
@@ -102,19 +101,17 @@ static int
cvs_annotate_pre_exec(struct cvsroot *root)
{
if (root->cr_method != CVS_METHOD_LOCAL) {
- if (usehead && (cvs_sendarg(root, "-f", 0) < 0))
- return (CVS_EX_PROTO);
+ if (usehead)
+ cvs_sendarg(root, "-f", 0);
if (rev != NULL) {
- if ((cvs_sendarg(root, "-r", 0) < 0) ||
- (cvs_sendarg(root, rev, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, rev, 0);
}
if (date != NULL) {
- if ((cvs_sendarg(root, "-D", 0) < 0) ||
- (cvs_sendarg(root, date, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-D", 0);
+ cvs_sendarg(root, date, 0);
}
}
@@ -129,51 +126,38 @@ cvs_annotate_pre_exec(struct cvsroot *root)
static int
cvs_annotate_remote(CVSFILE *cf, void *arg)
{
- int ret;
char fpath[MAXPATHLEN];
struct cvsroot *root;
- ret = 0;
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
else
- ret = cvs_senddir(root, cf);
-
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ cvs_senddir(root, cf);
+ return (0);
}
cvs_file_getpath(cf, fpath, sizeof(fpath));
-
- if (cvs_sendentry(root, cf) < 0) {
- return (CVS_EX_PROTO);
- }
+ cvs_sendentry(root, cf);
switch (cf->cf_cvstat) {
case CVS_FST_UNKNOWN:
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
break;
case CVS_FST_UPTODATE:
- ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
break;
case CVS_FST_ADDED:
case CVS_FST_MODIFIED:
- ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
break;
default:
break;
}
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ return (0);
}
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 675eccfc108..c52968e25d4 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.41 2005/12/03 01:02:08 joris Exp $ */
+/* $OpenBSD: checkout.c,v 1.42 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -253,50 +253,45 @@ cvs_checkout_pre_exec(struct cvsroot *root)
* a checkout.
*/
for (i = 0; i < co_nmod; i++)
- if (cvs_sendarg(root, co_mods[i], 0) < 0)
- return (CVS_EX_PROTO);
- if (cvs_sendreq(root, CVS_REQ_DIRECTORY, ".") < 0)
- return (CVS_EX_PROTO);
- if (cvs_sendln(root, root->cr_dir) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, co_mods[i], 0);
- if (cvs_sendreq(root, CVS_REQ_XPANDMOD, NULL) < 0)
- cvs_log(LP_ERR, "failed to expand module");
+ cvs_sendreq(root, CVS_REQ_DIRECTORY, ".");
+ cvs_sendln(root, root->cr_dir);
+ cvs_sendreq(root, CVS_REQ_XPANDMOD, NULL);
- if ((usehead == 1) && (cvs_sendarg(root, "-f", 0) < 0))
- return (CVS_EX_PROTO);
+ if (usehead == 1)
+ cvs_sendarg(root, "-f", 0);
- if ((tgtdir != NULL) &&
- ((cvs_sendarg(root, "-d", 0) < 0) ||
- (cvs_sendarg(root, tgtdir, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (tgtdir != NULL) {
+ cvs_sendarg(root, "-d", 0);
+ cvs_sendarg(root, tgtdir, 0);
+ }
- if ((shorten == 0) && cvs_sendarg(root, "-N", 0) < 0)
- return (CVS_EX_PROTO);
+ if (shorten == 0)
+ cvs_sendarg(root, "-N", 0);
- if ((cvs_cmd_checkout.cmd_flags & CVS_CMD_PRUNEDIRS) &&
- (cvs_sendarg(root, "-P", 0) < 0))
- return (CVS_EX_PROTO);
+ if (cvs_cmd_checkout.cmd_flags & CVS_CMD_PRUNEDIRS);
+ cvs_sendarg(root, "-P", 0);
for (i = 0; i < co_nmod; i++)
- if (cvs_sendarg(root, co_mods[i], 0) < 0)
- return (CVS_EX_PROTO);
-
- if ((statmod == CVS_LISTMOD) &&
- (cvs_sendarg(root, "-c", 0) < 0))
- return (CVS_EX_PROTO);
- else if ((statmod == CVS_STATMOD) &&
- (cvs_sendarg(root, "-s", 0) < 0))
- return (CVS_EX_PROTO);
-
- if ((tag != NULL) && ((cvs_sendarg(root, "-r", 0) < 0) ||
- (cvs_sendarg(root, tag, 0) < 0)))
- return (CVS_EX_PROTO);
-
- if ((date != NULL) && ((cvs_sendarg(root, "-D", 0) < 0) ||
- (cvs_sendarg(root, date, 0) < 0)))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, co_mods[i], 0);
+
+ if (statmod == CVS_LISTMOD)
+ cvs_sendarg(root, "-c", 0);
+ else if (statmod == CVS_STATMOD)
+ cvs_sendarg(root, "-s", 0);
+
+ if (tag != NULL) {
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, tag, 0);
+ }
+
+ if (date != NULL) {
+ cvs_sendarg(root, "-D", 0);
+ cvs_sendarg(root, date, 0);
+ }
}
+
return (0);
}
diff --git a/usr.bin/cvs/cmd.c b/usr.bin/cvs/cmd.c
index 15f30b8b8ee..b3d1d5b742c 100644
--- a/usr.bin/cvs/cmd.c
+++ b/usr.bin/cvs/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.39 2005/12/10 20:27:45 joris Exp $ */
+/* $OpenBSD: cmd.c,v 1.40 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -235,8 +235,8 @@ cvs_startcmd(struct cvs_cmd *cmd, int argc, char **argv)
cvs_log(LP_TRACE, "cvs_startcmd() CVSROOT=%s", root->cr_str);
- if ((root->cr_method != CVS_METHOD_LOCAL) && (cvs_connect(root) < 0))
- return (CVS_EX_PROTO);
+ if (root->cr_method != CVS_METHOD_LOCAL)
+ cvs_connect(root);
if (cmd->cmd_pre_exec != NULL) {
if ((ret = cmd->cmd_pre_exec(root)) != 0)
@@ -273,24 +273,19 @@ cvs_startcmd(struct cvs_cmd *cmd, int argc, char **argv)
cf = cvs_file_loadinfo(".", CF_NOFILES, NULL, NULL, 1);
if (cf == NULL)
return (CVS_EX_DATA);
- if (cvs_senddir(root, cf) < 0) {
- cvs_file_free(cf);
- return (CVS_EX_PROTO);
- }
+ cvs_senddir(root, cf);
cvs_file_free(cf);
}
if (cmd->cmd_flags & CVS_CMD_SENDARGS2) {
- for (i = 0; i < argc; i++) {
- if (cvs_sendarg(root, argv[i], 0) < 0)
- return (CVS_EX_PROTO);
- }
+ for (i = 0; i < argc; i++)
+ cvs_sendarg(root, argv[i], 0);
}
- if (cmd->cmd_req != CVS_REQ_NONE &&
- cvs_sendreq(root, cmd->cmd_req,
- (cmd->cmd_op == CVS_OP_INIT) ? root->cr_dir : NULL) < 0)
- return (CVS_EX_PROTO);
+ if (cmd->cmd_req != CVS_REQ_NONE) {
+ cvs_sendreq(root, cmd->cmd_req,
+ (cmd->cmd_op == CVS_OP_INIT) ? root->cr_dir : NULL);
+ }
}
if (cmd->cmd_cleanup != NULL)
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index b5aeb0b6da9..a2b64bfeb78 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.49 2005/12/22 14:59:54 xsa Exp $ */
+/* $OpenBSD: commit.c,v 1.50 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -187,13 +187,11 @@ cvs_commit_pre_exec(struct cvsroot *root)
return (CVS_EX_DATA);
if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cvs_logmsg_send(root, cvs_msg) < 0)
- return (CVS_EX_PROTO);
+ cvs_logmsg_send(root, cvs_msg);
if (rev != NULL) {
- if ((cvs_sendarg(root, "-r", 0) < 0) ||
- (cvs_sendarg(root, rev, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, rev, 0);
}
}
@@ -243,10 +241,8 @@ cvs_commit_remote(CVSFILE *cf, void *arg)
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
- if (cf->cf_cvstat != CVS_FST_UNKNOWN) {
- if (cvs_senddir(root, cf) < 0)
- return (CVS_EX_PROTO);
- }
+ if (cf->cf_cvstat != CVS_FST_UNKNOWN)
+ cvs_senddir(root, cf);
return (0);
}
@@ -258,9 +254,7 @@ cvs_commit_remote(CVSFILE *cf, void *arg)
if ((cf->cf_cvstat == CVS_FST_ADDED) ||
(cf->cf_cvstat == CVS_FST_MODIFIED) ||
(cf->cf_cvstat == CVS_FST_REMOVED)) {
- if (cvs_sendentry(root, cf) < 0) {
- return (CVS_EX_PROTO);
- }
+ cvs_sendentry(root, cf);
/* if it's removed, don't bother sending a
* Modified request together with the file its
@@ -269,12 +263,8 @@ cvs_commit_remote(CVSFILE *cf, void *arg)
if (cf->cf_cvstat == CVS_FST_REMOVED)
return (0);
- if (cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name) < 0)
- return (CVS_EX_PROTO);
-
- if (cvs_sendfile(root, fpath) < 0) {
- return (CVS_EX_PROTO);
- }
+ cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name);
+ cvs_sendfile(root, fpath);
}
return (0);
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 1a1c128e0fe..89296c0df67 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.93 2005/12/24 19:07:52 xsa Exp $ */
+/* $OpenBSD: cvs.h,v 1.94 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -407,7 +407,7 @@ int cvs_hist_append(CVSHIST *, struct cvs_hent *);
char *cvs_logmsg_open(const char *);
char *cvs_logmsg_get(const char *, struct cvs_flist *,
struct cvs_flist *, struct cvs_flist *);
-int cvs_logmsg_send(struct cvsroot *, const char *);
+void cvs_logmsg_send(struct cvsroot *, const char *);
/* date.y */
time_t cvs_date_parse(const char *);
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index 42790b9133b..d7092561b1c 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.73 2005/12/21 09:09:02 xsa Exp $ */
+/* $OpenBSD: diff.c,v 1.74 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -447,36 +447,29 @@ cvs_diff_pre_exec(struct cvsroot *root)
{
if (root->cr_method != CVS_METHOD_LOCAL) {
/* send the flags */
- if ((Nflag == 1) && (cvs_sendarg(root, "-N", 0) < 0))
- return (CVS_EX_PROTO);
- if ((pflag ==1) && (cvs_sendarg(root, "-p", 0) < 0))
- return (CVS_EX_PROTO);
-
- if (diff_format == D_CONTEXT) {
- if (cvs_sendarg(root, "-c", 0) < 0)
- return (CVS_EX_PROTO);
- } else if (diff_format == D_UNIFIED) {
- if (cvs_sendarg(root, "-u", 0) < 0)
- return (CVS_EX_PROTO);
- }
+ if (Nflag == 1)
+ cvs_sendarg(root, "-N", 0);
+ if (pflag == 1)
+ cvs_sendarg(root, "-p", 0);
+
+ if (diff_format == D_CONTEXT)
+ cvs_sendarg(root, "-c", 0);
+ else if (diff_format == D_UNIFIED)
+ cvs_sendarg(root, "-u", 0);
if (dap->rev1 != NULL) {
- if ((cvs_sendarg(root, "-r", 0) < 0) ||
- (cvs_sendarg(root, dap->rev1, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, dap->rev1, 0);
} else if (dap->date1 != NULL) {
- if ((cvs_sendarg(root, "-D", 0) < 0) ||
- (cvs_sendarg(root, dap->date1, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-D", 0);
+ cvs_sendarg(root, dap->date1, 0);
}
if (dap->rev2 != NULL) {
- if ((cvs_sendarg(root, "-r", 0) < 0) ||
- (cvs_sendarg(root, dap->rev2, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, dap->rev2, 0);
} else if (dap->date2 != NULL) {
- if ((cvs_sendarg(root, "-D", 0) < 0) ||
- (cvs_sendarg(root, dap->date2, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-D", 0);
+ cvs_sendarg(root, dap->date2, 0);
}
}
@@ -538,8 +531,7 @@ cvs_diff_remote(struct cvs_file *cfp, void *arg)
return (0);
}
- if (cvs_sendentry(root, cfp) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendentry(root, cfp);
if (cfp->cf_cvstat == CVS_FST_UPTODATE) {
cvs_sendreq(root, CVS_REQ_UNCHANGED, cfp->cf_name);
@@ -547,9 +539,8 @@ cvs_diff_remote(struct cvs_file *cfp, void *arg)
}
/* at this point, the file is modified */
- if ((cvs_sendreq(root, CVS_REQ_MODIFIED, cfp->cf_name) < 0) ||
- (cvs_sendfile(root, diff_file) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendreq(root, CVS_REQ_MODIFIED, cfp->cf_name);
+ cvs_sendfile(root, diff_file);
return (0);
}
diff --git a/usr.bin/cvs/edit.c b/usr.bin/cvs/edit.c
index 4dfa42081fb..f6f5ba1f982 100644
--- a/usr.bin/cvs/edit.c
+++ b/usr.bin/cvs/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.9 2005/10/10 17:51:53 xsa Exp $ */
+/* $OpenBSD: edit.c,v 1.10 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -172,46 +172,34 @@ cvs_edit_local(CVSFILE *cf, void *arg)
static int
cvs_editors_remote(CVSFILE *cf, void *arg)
{
- int ret;
struct cvsroot *root;
- ret = 0;
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
else
- ret = cvs_senddir(root, cf);
-
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ cvs_senddir(root, cf);
+ return (0);
}
- if (cvs_sendentry(root, cf) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendentry(root, cf);
switch (cf->cf_cvstat) {
case CVS_FST_UNKNOWN:
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
break;
case CVS_FST_UPTODATE:
- ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
break;
case CVS_FST_ADDED:
case CVS_FST_MODIFIED:
- ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
break;
default:
break;
}
-
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ return (0);
}
diff --git a/usr.bin/cvs/getlog.c b/usr.bin/cvs/getlog.c
index 208e7839b90..1406f06ab2a 100644
--- a/usr.bin/cvs/getlog.c
+++ b/usr.bin/cvs/getlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getlog.c,v 1.48 2005/12/22 14:59:54 xsa Exp $ */
+/* $OpenBSD: getlog.c,v 1.49 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -134,14 +134,14 @@ static int
cvs_getlog_pre_exec(struct cvsroot *root)
{
if (root->cr_method != CVS_METHOD_LOCAL) {
- if (log_honly && (cvs_sendarg(root, "-h", 0) < 0))
- return (CVS_EX_PROTO);
- if (log_notags && (cvs_sendarg(root, "-N", 0) < 0))
- return (CVS_EX_PROTO);
- if (log_rfonly && (cvs_sendarg(root, "-R", 0) < 0))
- return (CVS_EX_PROTO);
- if (log_lhonly && (cvs_sendarg(root, "-t", 0) < 0))
- return (CVS_EX_PROTO);
+ if (log_honly)
+ cvs_sendarg(root, "-h", 0);
+ if (log_notags)
+ cvs_sendarg(root, "-N", 0);
+ if (log_rfonly)
+ cvs_sendarg(root, "-R", 0);
+ if (log_lhonly)
+ cvs_sendarg(root, "-t", 0);
}
return (0);
@@ -154,45 +154,39 @@ cvs_getlog_pre_exec(struct cvsroot *root)
static int
cvs_getlog_remote(CVSFILE *cf, void *arg)
{
- int ret;
char fpath[MAXPATHLEN];
struct cvsroot *root;
- ret = 0;
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
else
- ret = cvs_senddir(root, cf);
- return (ret);
+ cvs_senddir(root, cf);
+ return (0);
}
cvs_file_getpath(cf, fpath, sizeof(fpath));
- if (cvs_sendentry(root, cf) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendentry(root, cf);
switch (cf->cf_cvstat) {
case CVS_FST_UNKNOWN:
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
break;
case CVS_FST_UPTODATE:
- ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
break;
case CVS_FST_ADDED:
case CVS_FST_MODIFIED:
- ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
break;
default:
break;
}
- if (ret == -1)
- ret = CVS_EX_PROTO;
- return (ret);
+ return (0);
}
diff --git a/usr.bin/cvs/history.c b/usr.bin/cvs/history.c
index 887ae64a7ca..2698ce28690 100644
--- a/usr.bin/cvs/history.c
+++ b/usr.bin/cvs/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.23 2005/07/25 12:05:43 xsa Exp $ */
+/* $OpenBSD: history.c,v 1.24 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -170,44 +170,43 @@ static int
cvs_history_pre_exec(struct cvsroot *root)
{
if (root->cr_method != CVS_METHOD_LOCAL) {
- if ((flags & CVS_HF_A) && (cvs_sendarg(root, "-a", 0) < 0))
- return (CVS_EX_PROTO);
+ if (flags & CVS_HF_A)
+ cvs_sendarg(root, "-a", 0);
- if ((flags & CVS_HF_C) && (cvs_sendarg(root, "-c", 0) < 0))
- return (CVS_EX_PROTO);
+ if (flags & CVS_HF_C)
+ cvs_sendarg(root, "-c", 0);
- if ((flags & CVS_HF_O) && (cvs_sendarg(root, "-o", 0) < 0))
- return (CVS_EX_PROTO);
+ if (flags & CVS_HF_O)
+ cvs_sendarg(root, "-o", 0);
- if ((date != NULL) && ((cvs_sendarg(root, "-D", 0) < 0) ||
- (cvs_sendarg(root, date, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (date != NULL) {
+ cvs_sendarg(root, "-D", 0);
+ cvs_sendarg(root, date, 0);
+ }
- if ((rev != NULL) && ((cvs_sendarg(root, "-r", 0) < 0) ||
- (cvs_sendarg(root, rev, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (rev != NULL) {
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, rev, 0);
+ }
- if ((tag != NULL) && ((cvs_sendarg(root, "-t", 0) < 0) ||
- (cvs_sendarg(root, tag, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (tag != NULL) {
+ cvs_sendarg(root, "-t", 0);
+ cvs_sendarg(root, tag, 0);
+ }
/* if no user is specified, get login name of command issuer */
if (!(flags & CVS_HF_A) && (user == NULL)) {
- if ((user = getlogin()) == NULL) {
- cvs_log(LP_ERRNO, "cannot get login name");
- return (CVS_EX_DATA);
- }
+ if ((user = getlogin()) == NULL)
+ fatal("cannot get login name");
}
if (!(flags & CVS_HF_A)) {
- if ((cvs_sendarg(root, "-u", 0) < 0) ||
- (cvs_sendarg(root, user, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-u", 0);
+ cvs_sendarg(root, user, 0);
}
- if ((cvs_sendarg(root, "-z", 0) < 0) ||
- (cvs_sendarg(root, zone, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-z", 0);
+ cvs_sendarg(root, zone, 0);
}
return (0);
diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c
index ed36f5e3bb8..99673c21b41 100644
--- a/usr.bin/cvs/import.c
+++ b/usr.bin/cvs/import.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: import.c,v 1.33 2005/12/21 20:06:25 xsa Exp $ */
+/* $OpenBSD: import.c,v 1.34 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -149,13 +149,12 @@ cvs_import_pre_exec(struct cvsroot *root)
} else {
rcsnum_tostr(imp_brnum, numbuf, sizeof(numbuf));
- if ((cvs_sendarg(root, "-b", 0) < 0) ||
- (cvs_sendarg(root, numbuf, 0) < 0) ||
- (cvs_logmsg_send(root, cvs_msg) < 0) ||
- (cvs_sendarg(root, module, 0) < 0) ||
- (cvs_sendarg(root, vendor, 0) < 0) ||
- (cvs_sendarg(root, release, 0) < 0))
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, "-b", 0);
+ cvs_sendarg(root, numbuf, 0);
+ cvs_logmsg_send(root, cvs_msg);
+ cvs_sendarg(root, module, 0);
+ cvs_sendarg(root, vendor, 0);
+ cvs_sendarg(root, release, 0);
}
return (0);
@@ -209,10 +208,8 @@ cvs_import_remote(CVSFILE *cf, void *arg)
return (CVS_EX_DATA);
}
- if (cvs_sendreq(root, CVS_REQ_DIRECTORY, fpath) < 0)
- return (CVS_EX_PROTO);
- if (cvs_sendln(root, repodir) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendreq(root, CVS_REQ_DIRECTORY, fpath);
+ cvs_sendln(root, repodir);
return (0);
}
@@ -221,13 +218,11 @@ cvs_import_remote(CVSFILE *cf, void *arg)
sz = strlen(date);
if ((sz > 0) && (date[sz - 1] == '\n'))
date[--sz] = '\0';
- if (cvs_sendreq(root, CVS_REQ_CHECKINTIME, date) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendreq(root, CVS_REQ_CHECKINTIME, date);
}
- if (cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name) < 0)
- return (CVS_EX_PROTO);
- if (cvs_sendfile(root, fpath) < 0)
- return (CVS_EX_PROTO);
+
+ cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name);
+ cvs_sendfile(root, fpath);
return (0);
}
diff --git a/usr.bin/cvs/logmsg.c b/usr.bin/cvs/logmsg.c
index c4fdd880d9c..ef41c0abdce 100644
--- a/usr.bin/cvs/logmsg.c
+++ b/usr.bin/cvs/logmsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logmsg.c,v 1.25 2005/12/22 13:19:12 moritz Exp $ */
+/* $OpenBSD: logmsg.c,v 1.26 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -283,14 +283,13 @@ cvs_logmsg_get(const char *dir, struct cvs_flist *added,
* cvs_logmsg_send()
*
*/
-int
+void
cvs_logmsg_send(struct cvsroot *root, const char *msg)
{
const char *mp;
char *np, buf[256];
- if (cvs_sendarg(root, "-m", 0) < 0)
- fatal("cvs_logmsg_send: cvs_sendarg failed");
+ cvs_sendarg(root, "-m", 0);
for (mp = msg; mp != NULL; mp = strchr(mp, '\n')) {
if (*mp == '\n')
@@ -301,9 +300,6 @@ cvs_logmsg_send(struct cvsroot *root, const char *msg)
np = strchr(buf, '\n');
if (np != NULL)
*np = '\0';
- if (cvs_sendarg(root, buf, (mp == msg) ? 0 : 1) < 0)
- fatal("cvs_logmsg_send: cvs_sendarg failed");
+ cvs_sendarg(root, buf, (mp == msg) ? 0 : 1);
}
-
- return (0);
}
diff --git a/usr.bin/cvs/proto.c b/usr.bin/cvs/proto.c
index f477e684aea..ae9e5566820 100644
--- a/usr.bin/cvs/proto.c
+++ b/usr.bin/cvs/proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proto.c,v 1.81 2005/12/20 18:17:01 xsa Exp $ */
+/* $OpenBSD: proto.c,v 1.82 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -184,65 +184,44 @@ static char cvs_lastdir[MAXPATHLEN] = "";
* Once the connection has been established, we first send the list of
* responses we support and request the list of supported requests from the
* server. Then, a version request is sent and various global flags are sent.
- * Returns 0 on success, or -1 on failure.
*/
-int
+void
cvs_connect(struct cvsroot *root)
{
+ size_t len;
int argc, infd[2], outfd[2], errfd[2];
char *argv[16], *cvs_server_cmd, tmsg[1024], *vresp;
- if (root->cr_method == CVS_METHOD_PSERVER) {
- cvs_log(LP_ERR, "no pserver support due to security issues");
- return (-1);
- } else if ((root->cr_method == CVS_METHOD_KSERVER) ||
+ if (root->cr_method == CVS_METHOD_PSERVER)
+ fatal("no pserver support due to security issues");
+ else if ((root->cr_method == CVS_METHOD_KSERVER) ||
(root->cr_method == CVS_METHOD_GSERVER) ||
(root->cr_method == CVS_METHOD_EXT) ||
- (root->cr_method == CVS_METHOD_FORK)) {
- cvs_log(LP_ERR, "connection method not supported yet");
- return (-1);
- }
+ (root->cr_method == CVS_METHOD_FORK))
+ fatal("connection method not supported yet");
if (root->cr_flags & CVS_ROOT_CONNECTED) {
cvs_log(LP_NOTICE, "already connected to CVSROOT");
- return (0);
+ return;
}
- if (pipe(infd) == -1) {
- cvs_log(LP_ERRNO,
- "failed to create input pipe for client connection");
- return (-1);
- }
+ if (pipe(infd) == -1)
+ fatal("failed to create input pipe for client connection");
- if (pipe(outfd) == -1) {
- cvs_log(LP_ERRNO,
- "failed to create output pipe for client connection");
- (void)close(infd[0]);
- (void)close(infd[1]);
- return (-1);
- }
+ if (pipe(outfd) == -1)
+ fatal("failed to create output pipe for client connection");
- if (pipe(errfd) == -1) {
- cvs_log(LP_ERRNO,
- "failed to create error pipe for client connection");
- (void)close(infd[0]);
- (void)close(infd[1]);
- (void)close(outfd[0]);
- (void)close(outfd[1]);
- return (-1);
- }
+ if (pipe(errfd) == -1)
+ fatal("failed to create error pipe for client connection");
cvs_subproc_pid = fork();
if (cvs_subproc_pid == -1) {
- cvs_log(LP_ERRNO, "failed to fork for cvs server connection");
- return (-1);
+ fatal("failed to fork for cvs server connection");
} else if (cvs_subproc_pid == 0) {
if ((dup2(infd[0], STDIN_FILENO) == -1) ||
- (dup2(outfd[1], STDOUT_FILENO) == -1)) {
- cvs_log(LP_ERRNO,
- "failed to setup standard streams for cvs server");
- return (-1);
- }
+ (dup2(outfd[1], STDOUT_FILENO) == -1))
+ fatal("failed to setup standard streams for cvs server");
+
(void)close(infd[1]);
(void)close(outfd[0]);
(void)close(errfd[0]);
@@ -267,15 +246,20 @@ cvs_connect(struct cvsroot *root)
if (cvs_trace == 1) {
tmsg[0] = '\0';
for (argc = 0; argv[argc] != NULL; argc++) {
- strlcat(tmsg, argv[argc], sizeof(tmsg));
- strlcat(tmsg, " ", sizeof(tmsg));
+ len = strlcat(tmsg, argv[argc], sizeof(tmsg));
+ if (len >= sizeof(tmsg))
+ fatal("truncation in cvs_connect");
+
+ len = strlcat(tmsg, " ", sizeof(tmsg));
+ if (len >= sizeof(tmsg))
+ fatal("truncation in cvs_connect");
}
}
+
cvs_log(LP_TRACE, "Starting server: %s", tmsg);
execvp(argv[0], argv);
- cvs_log(LP_ERRNO, "failed to exec");
- exit(CVS_EX_PROTO);
+ fatal("failed to execute cvs server");
}
/* we are the parent */
@@ -284,16 +268,12 @@ cvs_connect(struct cvsroot *root)
(void)close(errfd[1]);
root->cr_srvin = fdopen(infd[1], "w");
- if (root->cr_srvin == NULL) {
- cvs_log(LP_ERRNO, "failed to create pipe stream");
- return (-1);
- }
+ if (root->cr_srvin == NULL)
+ fatal("failed to create pipe stream");
root->cr_srvout = fdopen(outfd[0], "r");
- if (root->cr_srvout == NULL) {
- cvs_log(LP_ERRNO, "failed to create pipe stream");
- return (-1);
- }
+ if (root->cr_srvout == NULL)
+ fatal("failed to create pipe stream");
/* make the streams line-buffered */
(void)setvbuf(root->cr_srvin, NULL, _IOLBF, (size_t)0);
@@ -306,61 +286,42 @@ cvs_connect(struct cvsroot *root)
* requests.
*/
- if ((vresp = cvs_resp_getvalid()) == NULL) {
- cvs_log(LP_ERR, "can't generate list of valid responses");
- return (-1);
- }
-
- if (cvs_sendreq(root, CVS_REQ_VALIDRESP, vresp) < 0) {
- cvs_log(LP_ERR, "failed to get valid responses");
- xfree(vresp);
- return (-1);
- }
+ vresp = cvs_resp_getvalid();
+ cvs_sendreq(root, CVS_REQ_VALIDRESP, vresp);
xfree(vresp);
- if (cvs_sendreq(root, CVS_REQ_VALIDREQ, NULL) < 0) {
- cvs_log(LP_ERR, "failed to get valid requests from server");
- return (-1);
- }
+ cvs_sendreq(root, CVS_REQ_VALIDREQ, NULL);
/* send the CVSROOT to the server */
- if (cvs_sendreq(root, CVS_REQ_ROOT, root->cr_dir) < 0)
- return (-1);
+ cvs_sendreq(root, CVS_REQ_ROOT, root->cr_dir);
/* don't fail if this request doesn't work */
- if (cvs_sendreq(root, CVS_REQ_VERSION, NULL) < 0)
- cvs_log(LP_WARN, "failed to get remote version");
+ cvs_sendreq(root, CVS_REQ_VERSION, NULL);
/* now share our global options with the server */
- if ((verbosity <= 1) &&
- (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-q") < 0))
- return (-1);
- if ((verbosity == 0) &&
- (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-Q") < 0))
- return (-1);
+ if (verbosity <= 1)
+ cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-q");
+ if (verbosity == 0)
+ cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-Q");
- if ((cvs_noexec == 1) &&
- (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-n") < 0))
- return (-1);
- if ((cvs_nolog == 1) &&
- (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-l") < 0))
- return (-1);
- if ((cvs_readonly == 1) &&
- (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-r") < 0))
- return (-1);
- if ((cvs_trace == 1) &&
- (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-t") < 0))
- return (-1);
+ if (cvs_noexec == 1)
+ cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-n");
+
+ if (cvs_nolog == 1)
+ cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-l");
+
+ if (cvs_readonly == 1)
+ cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-r");
+
+ if (cvs_trace == 1)
+ cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-t");
/* not sure why, but we have to send this */
- if (cvs_sendreq(root, CVS_REQ_USEUNCHANGED, NULL) < 0)
- return (-1);
+ cvs_sendreq(root, CVS_REQ_USEUNCHANGED, NULL);
cvs_log(LP_DEBUG, "connected to %s", root->cr_host);
root->cr_flags |= CVS_ROOT_CONNECTED;
-
- return (0);
}
@@ -376,6 +337,7 @@ cvs_disconnect(struct cvsroot *root)
return;
cvs_log(LP_DEBUG, "closing connection to %s", root->cr_host);
+
if (root->cr_srvin != NULL) {
(void)fclose(root->cr_srvin);
root->cr_srvin = NULL;
@@ -437,8 +399,6 @@ cvs_req_getvalid(void)
BUF *buf;
buf = cvs_buf_alloc((size_t)512, BUF_AUTOEXT);
- if (buf == NULL)
- return (NULL);
cvs_buf_set(buf, cvs_requests[0].req_str,
strlen(cvs_requests[0].req_str), (size_t)0);
@@ -509,8 +469,6 @@ cvs_resp_getvalid(void)
BUF *buf;
buf = cvs_buf_alloc((size_t)512, BUF_AUTOEXT);
- if (buf == NULL)
- return (NULL);
cvs_buf_set(buf, cvs_responses[0].resp_str,
strlen(cvs_responses[0].resp_str), (size_t)0);
@@ -539,7 +497,7 @@ cvs_resp_getvalid(void)
* Send the mode and size of a file followed by the file's contents.
* Returns 0 on success, or -1 on failure.
*/
-int
+void
cvs_sendfile(struct cvsroot *root, const char *path)
{
int fd, l;
@@ -550,47 +508,36 @@ cvs_sendfile(struct cvsroot *root, const char *path)
cvs_log(LP_TRACE, "Sending file `%s' to server", basename(path));
if (stat(path, &st) == -1) {
- cvs_log(LP_ERRNO, "failed to stat `%s'", path);
- return (-1);
+ fatal("cvs_sendfile(): stat failed on '%s': %s",
+ path, strerror(errno));
}
- if (cvs_modetostr(st.st_mode, buf, sizeof(buf)) < 0)
- return (-1);
+ cvs_modetostr(st.st_mode, buf, sizeof(buf));
fd = open(path, O_RDONLY, 0);
if (fd == -1) {
- cvs_log(LP_ERRNO, "failed to open `%s'", path);
- return (-1);
+ fatal("cvs_sendfile(): failed to open '%s': %s",
+ path, strerror(errno));
}
- if (cvs_sendln(root, buf) < 0) {
- (void)close(fd);
- return (-1);
- }
+ cvs_sendln(root, buf);
+
l = snprintf(buf, sizeof(buf), "%lld\n", st.st_size);
if (l == -1 || l >= (int)sizeof(buf))
- return (-1);
+ fatal("overflow in cvs_sendfile");
- if (cvs_sendln(root, buf) < 0) {
- (void)close(fd);
- return (-1);
- }
+ cvs_sendln(root, buf);
while ((ret = read(fd, buf, sizeof(buf))) != 0) {
if (ret == -1) {
(void)close(fd);
- cvs_log(LP_ERRNO, "failed to read file `%s'", path);
- return (-1);
+ fatal("cvs_sendfile: read error on '%s'", path);
}
- if (cvs_sendraw(root, buf, (size_t)ret) < 0) {
- (void)close(fd);
- return (-1);
- }
+ cvs_sendraw(root, buf, (size_t)ret);
}
(void)close(fd);
- return (0);
}
@@ -611,8 +558,6 @@ cvs_recvfile(struct cvsroot *root, mode_t *mode)
BUF *fbuf;
fbuf = cvs_buf_alloc(sizeof(buf), BUF_AUTOEXT);
- if (fbuf == NULL)
- return (NULL);
if ((cvs_getln(root, buf, sizeof(buf)) < 0) ||
(cvs_strtomode(buf, mode) < 0)) {
@@ -663,57 +608,49 @@ cvs_recvfile(struct cvsroot *root, mode_t *mode)
* contained in <arg>, which should not be terminated by a newline.
* Returns 0 on success, or -1 on failure.
*/
-int
+void
cvs_sendreq(struct cvsroot *root, u_int rid, const char *arg)
{
int ret, l;
struct cvs_req *req;
- if (root->cr_srvin == NULL) {
- cvs_log(LP_ERR, "cannot send request %u: Not connected", rid);
- return (-1);
- }
+ if (root->cr_srvin == NULL)
+ fatal("cannot send request %u: Not connected", rid);
req = cvs_req_getbyid(rid);
- if (req == NULL) {
- cvs_log(LP_ERR, "unsupported request type %u", rid);
- return (-1);
- }
+ if (req == NULL)
+ fatal("unsupported request type %u", rid);
/* is this request supported by the server? */
if (!CVS_GETVR(root, req->req_id)) {
if (rid == CVS_REQ_VERSION) {
- ret = cvs_sendreq(root, CVS_REQ_NOOP, arg);
+ cvs_sendreq(root, CVS_REQ_NOOP, arg);
} else {
cvs_log(LP_WARN,
"remote end does not support request `%s'",
req->req_str);
- ret = -1;
}
- return (ret);
+
+ return;
}
l = snprintf(cvs_proto_buf, sizeof(cvs_proto_buf), "%s%s%s\n",
req->req_str, (arg == NULL) ? "" : " ", (arg == NULL) ? "" : arg);
if (l == -1 || l >= (int)sizeof(cvs_proto_buf))
- return (-1);
+ fatal("overflow in cvs_sendreq");
if (cvs_server_inlog != NULL)
fputs(cvs_proto_buf, cvs_server_inlog);
ret = fputs(cvs_proto_buf, root->cr_srvin);
- if (ret == EOF) {
- cvs_log(LP_ERRNO, "failed to send request to server");
- return (-1);
- }
+ if (ret == EOF)
+ fatal("failed to send request to server");
if (rid == CVS_REQ_VERSION)
cvs_version_sent = 1;
if (req->req_flags & CVS_REQF_RESP)
- ret = cvs_getresp(root);
-
- return (ret);
+ cvs_getresp(root);
}
@@ -725,23 +662,19 @@ cvs_sendreq(struct cvsroot *root, u_int rid, const char *arg)
* non-zero (either an error occurred or the end of the response was reached).
* Returns the number of handled commands on success, or -1 on failure.
*/
-int
+void
cvs_getresp(struct cvsroot *root)
{
- int nbcmd, ret;
+ int ret;
size_t len;
- nbcmd = 0;
-
do {
/* wait for incoming data */
if (fgets(cvs_proto_buf, (int)sizeof(cvs_proto_buf),
root->cr_srvout) == NULL) {
if (feof(root->cr_srvout))
- return (0);
- cvs_log(LP_ERRNO,
- "failed to read response from server");
- return (-1);
+ return;
+ fatal("failed to read response from server");
}
if (cvs_server_outlog != NULL)
@@ -754,12 +687,7 @@ cvs_getresp(struct cvsroot *root)
}
ret = cvs_resp_handle(root, cvs_proto_buf);
- nbcmd++;
} while (ret == 0);
-
- if (ret > 0)
- ret = nbcmd;
- return (ret);
}
@@ -878,9 +806,8 @@ cvs_getreq(void)
*
* Send a single line <line> string to the remote end. The line is sent as is,
* without any modifications.
- * Returns 0 on success, or -1 on failure.
*/
-int
+void
cvs_sendln(struct cvsroot *root, const char *line)
{
int nl;
@@ -906,7 +833,6 @@ cvs_sendln(struct cvsroot *root, const char *line)
fputs(line, out);
if (nl)
putc('\n', out);
- return (0);
}
@@ -915,7 +841,7 @@ cvs_sendln(struct cvsroot *root, const char *line)
*
* Send the first <len> bytes from the buffer <src> to the server.
*/
-int
+void
cvs_sendraw(struct cvsroot *root, const void *src, size_t len)
{
FILE *out;
@@ -927,12 +853,8 @@ cvs_sendraw(struct cvsroot *root, const void *src, size_t len)
if (cvs_server_inlog != NULL)
fwrite(src, sizeof(char), len, cvs_server_inlog);
- if (fwrite(src, sizeof(char), len, out) < len) {
- cvs_log(LP_ERR, "failed to send data");
- return (-1);
- }
-
- return (0);
+ if (fwrite(src, sizeof(char), len, out) < len)
+ fatal("failed to send data");
}
@@ -968,36 +890,36 @@ cvs_recvraw(struct cvsroot *root, void *dst, size_t len)
* the directory info to be sent is the same as the last info sent, the
* call does nothing and simply returns without an error.
*/
-int
+void
cvs_senddir(struct cvsroot *root, CVSFILE *dir)
{
size_t len;
char lbuf[MAXPATHLEN], rbuf[MAXPATHLEN];
if (dir->cf_type != DT_DIR)
- return (-1);
+ fatal("cvs_senddir(): cf_type != DT_DIR: %d", dir->cf_type);
cvs_file_getpath(dir, lbuf, sizeof(lbuf));
if (strcmp(lbuf, cvs_lastdir) == 0 && cvs_cmdop != CVS_OP_CHECKOUT)
- return (0);
+ return;
- if (dir->cf_repo == NULL)
- strlcpy(rbuf, root->cr_dir, sizeof(rbuf));
- else {
+ if (dir->cf_repo == NULL) {
+ len = strlcpy(rbuf, root->cr_dir, sizeof(rbuf));
+ if (len >= sizeof(rbuf))
+ fatal("cvs_senddir: path truncation");
+ } else {
len = cvs_path_cat(root->cr_dir, dir->cf_repo, rbuf,
sizeof(rbuf));
if (len >= sizeof(rbuf))
- return (-1);
+ fatal("cvs_senddir: path truncation");
}
+ cvs_sendreq(root, CVS_REQ_DIRECTORY, lbuf);
+ cvs_sendln(root, rbuf);
- if ((cvs_sendreq(root, CVS_REQ_DIRECTORY, lbuf) < 0) ||
- (cvs_sendln(root, rbuf) < 0))
- return (-1);
-
- strlcpy(cvs_lastdir, lbuf, sizeof(cvs_lastdir));
-
- return (0);
+ len = strlcpy(cvs_lastdir, lbuf, sizeof(cvs_lastdir));
+ if (len >= sizeof(lbuf))
+ fatal("path truncation in cvs_senddir");
}
@@ -1008,11 +930,11 @@ cvs_senddir(struct cvsroot *root, CVSFILE *dir)
* determine if the argument should be simply appended to the last argument
* sent or if it should be created as a new argument (0).
*/
-int
+void
cvs_sendarg(struct cvsroot *root, const char *arg, int append)
{
- return cvs_sendreq(root, ((append == 0) ?
- CVS_REQ_ARGUMENT : CVS_REQ_ARGUMENTX), arg);
+ cvs_sendreq(root, ((append == 0) ? CVS_REQ_ARGUMENT :
+ CVS_REQ_ARGUMENTX), arg);
}
@@ -1022,31 +944,26 @@ cvs_sendarg(struct cvsroot *root, const char *arg, int append)
* Send an `Entry' request to the server along with the mandatory fields from
* the CVS entry <ent> (which are the name and revision).
*/
-int
+void
cvs_sendentry(struct cvsroot *root, const CVSFILE *file)
{
int l;
char ebuf[CVS_ENT_MAXLINELEN], numbuf[64];
- if (file->cf_type != DT_REG) {
- cvs_log(LP_ERR, "attempt to send Entry for non-regular file");
- return (-1);
- }
+ if (file->cf_type != DT_REG)
+ fatal("cvs_sendentry: cf_type != DT_REG: %d", file->cf_type);
/* don't send Entry for unknown files */
if (file->cf_cvstat == CVS_FST_UNKNOWN)
- return (0);
+ return;
l = snprintf(ebuf, sizeof(ebuf), "/%s/%s%s///", file->cf_name,
(file->cf_cvstat == CVS_FST_REMOVED) ? "-" : "",
rcsnum_tostr(file->cf_lrev, numbuf, sizeof(numbuf)));
- if (l == -1 || l >= (int)sizeof(ebuf)) {
- errno = ENAMETOOLONG;
- cvs_log(LP_ERRNO, "%s", ebuf);
- return (-1);
- }
+ if (l == -1 || l >= (int)sizeof(ebuf))
+ fatal("cvs_sendentry: overflow when creating entry buffer");
- return cvs_sendreq(root, CVS_REQ_ENTRY, ebuf);
+ cvs_sendreq(root, CVS_REQ_ENTRY, ebuf);
}
diff --git a/usr.bin/cvs/proto.h b/usr.bin/cvs/proto.h
index 26ca70f791b..1df7b7ff2a0 100644
--- a/usr.bin/cvs/proto.h
+++ b/usr.bin/cvs/proto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proto.h,v 1.8 2005/10/17 16:16:00 moritz Exp $ */
+/* $OpenBSD: proto.h,v 1.9 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -167,8 +167,8 @@ struct cvs_resp {
BUF *cvs_recvfile(struct cvsroot *, mode_t *);
-int cvs_sendfile(struct cvsroot *, const char *);
-int cvs_connect(struct cvsroot *);
+void cvs_sendfile(struct cvsroot *, const char *);
+void cvs_connect(struct cvsroot *);
void cvs_disconnect(struct cvsroot *);
int cvs_req_handle(char *);
@@ -181,15 +181,15 @@ struct cvs_resp* cvs_resp_getbyid(int);
struct cvs_resp* cvs_resp_getbyname(const char *);
char* cvs_resp_getvalid(void);
-int cvs_sendreq(struct cvsroot *, u_int, const char *);
-int cvs_getresp(struct cvsroot *);
+void cvs_sendreq(struct cvsroot *, u_int, const char *);
+void cvs_getresp(struct cvsroot *);
int cvs_sendresp(u_int, const char *);
int cvs_getln(struct cvsroot *, char *, size_t);
-int cvs_senddir(struct cvsroot *, CVSFILE *);
-int cvs_sendarg(struct cvsroot *, const char *, int);
-int cvs_sendln(struct cvsroot *, const char *);
-int cvs_sendentry(struct cvsroot *, const CVSFILE *);
-int cvs_sendraw(struct cvsroot *, const void *, size_t);
+void cvs_senddir(struct cvsroot *, CVSFILE *);
+void cvs_sendarg(struct cvsroot *, const char *, int);
+void cvs_sendln(struct cvsroot *, const char *);
+void cvs_sendentry(struct cvsroot *, const CVSFILE *);
+void cvs_sendraw(struct cvsroot *, const void *, size_t);
ssize_t cvs_recvraw(struct cvsroot *, void *, size_t);
diff --git a/usr.bin/cvs/release.c b/usr.bin/cvs/release.c
index 9c419ba3d1a..d75447f8ec7 100644
--- a/usr.bin/cvs/release.c
+++ b/usr.bin/cvs/release.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: release.c,v 1.25 2005/12/24 19:07:52 xsa Exp $ */
+/* $OpenBSD: release.c,v 1.26 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -95,8 +95,8 @@ static int
cvs_release_pre_exec(struct cvsroot *root)
{
if (root->cr_method != CVS_METHOD_LOCAL) {
- if (dflag && cvs_sendarg(root, "-d", 0) < 0)
- return (CVS_EX_PROTO);
+ if (dflag)
+ cvs_sendarg(root, "-d", 0);
}
return (0);
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index b0f2426c7ba..d508e121ec0 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.38 2005/12/03 01:02:09 joris Exp $ */
+/* $OpenBSD: remove.c,v 1.39 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004, 2005 Xavier Santolaria <xsa@openbsd.org>
@@ -109,14 +109,10 @@ cvs_remove_remote(CVSFILE *cf, void *arg)
if (cf->cf_type == DT_DIR) {
if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
else
- ret = cvs_senddir(root, cf);
-
- if (ret == -1)
- ret = CVS_EX_PROTO;
- return (ret);
+ cvs_senddir(root, cf);
+ return (0);
}
cvs_file_getpath(cf, fpath, sizeof(fpath));
@@ -124,21 +120,14 @@ cvs_remove_remote(CVSFILE *cf, void *arg)
if (cvs_remove_file(fpath) < 0)
return (CVS_EX_FILE);
- if (cvs_sendentry(root, cf) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendentry(root, cf);
if (cf->cf_cvstat != CVS_FST_LOST && force_remove != 1) {
- if (cf->cf_cvstat != CVS_FST_ADDED) {
- if (cvs_sendreq(root, CVS_REQ_MODIFIED,
- cf->cf_name) < 0) {
- return (CVS_EX_PROTO);
- }
- }
+ if (cf->cf_cvstat != CVS_FST_ADDED)
+ cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name);
- if (cf->cf_flags & CVS_FILE_ONDISK) {
- if (cvs_sendfile(root, fpath) < 0)
- return (CVS_EX_PROTO);
- }
+ if (cf->cf_flags & CVS_FILE_ONDISK)
+ cvs_sendfile(root, fpath);
}
return (0);
diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c
index abbfde6406c..391f47df053 100644
--- a/usr.bin/cvs/status.c
+++ b/usr.bin/cvs/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.49 2005/12/22 14:59:54 xsa Exp $ */
+/* $OpenBSD: status.c,v 1.50 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
@@ -109,8 +109,8 @@ static int
cvs_status_pre_exec(struct cvsroot *root)
{
if (root->cr_method != CVS_METHOD_LOCAL) {
- if ((verbose == 1) && (cvs_sendarg(root, "-v", 0) < 0))
- return (CVS_EX_PROTO);
+ if (verbose == 1)
+ cvs_sendarg(root, "-v", 0);
}
return (0);
@@ -124,51 +124,39 @@ cvs_status_pre_exec(struct cvsroot *root)
static int
cvs_status_remote(CVSFILE *cfp, void *arg)
{
- int ret;
char fpath[MAXPATHLEN];
struct cvsroot *root;
- ret = 0;
root = CVS_DIR_ROOT(cfp);
if (cfp->cf_type == DT_DIR) {
if (cfp->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- cfp->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cfp->cf_name);
else
- ret = cvs_senddir(root, cfp);
-
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ cvs_senddir(root, cfp);
+ return (0);
}
cvs_file_getpath(cfp, fpath, sizeof(fpath));
- if (cvs_sendentry(root, cfp) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendentry(root, cfp);
switch (cfp->cf_cvstat) {
case CVS_FST_UNKNOWN:
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cfp->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cfp->cf_name);
break;
case CVS_FST_UPTODATE:
- ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, cfp->cf_name);
+ cvs_sendreq(root, CVS_REQ_UNCHANGED, cfp->cf_name);
break;
case CVS_FST_ADDED:
case CVS_FST_MODIFIED:
- ret = cvs_sendreq(root, CVS_REQ_MODIFIED, cfp->cf_name);
- if (ret == 0)
- ret = cvs_sendfile(root, fpath);
+ cvs_sendreq(root, CVS_REQ_MODIFIED, cfp->cf_name);
+ cvs_sendfile(root, fpath);
default:
break;
}
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ return (0);
}
static int
diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c
index ca46d7bddca..b45a7c0f5d4 100644
--- a/usr.bin/cvs/tag.c
+++ b/usr.bin/cvs/tag.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tag.c,v 1.34 2005/12/22 14:59:54 xsa Exp $ */
+/* $OpenBSD: tag.c,v 1.35 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004 Joris Vink <joris@openbsd.org>
@@ -166,29 +166,29 @@ static int
cvs_tag_pre_exec(struct cvsroot *root)
{
if (root->cr_method != CVS_METHOD_LOCAL) {
- if ((tag_branch == 1) && (cvs_sendarg(root, "-b", 0) < 0))
- return (CVS_EX_PROTO);
+ if (tag_branch == 1)
+ cvs_sendarg(root, "-b", 0);
- if ((tag_delete ==1) && (cvs_sendarg(root, "-d", 0) < 0))
- return (CVS_EX_PROTO);
+ if (tag_delete == 1)
+ cvs_sendarg(root, "-d", 0);
- if ((tag_forcemove == 1) && (cvs_sendarg(root, "-F", 0) < 0))
- return (CVS_EX_PROTO);
+ if (tag_forcemove == 1)
+ cvs_sendarg(root, "-F", 0);
- if ((tag_forcehead == 1) && (cvs_sendarg(root, "-f", 0) < 0))
- return (CVS_EX_PROTO);
+ if (tag_forcehead == 1)
+ cvs_sendarg(root, "-f", 0);
- if ((tag_oldname != NULL) &&
- ((cvs_sendarg(root, "-r", 0) < 0) ||
- (cvs_sendarg(root, tag_oldname, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (tag_oldname != NULL) {
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, tag_oldname, 0);
+ }
- if ((tag_date != NULL) && ((cvs_sendarg(root, "-D", 0) < 0) ||
- (cvs_sendarg(root, tag_date, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (tag_date != NULL) {
+ cvs_sendarg(root, "-D", 0);
+ cvs_sendarg(root, tag_date, 0);
+ }
- if (cvs_sendarg(root, tag_name, 0) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendarg(root, tag_name, 0);
}
return (0);
@@ -203,42 +203,33 @@ cvs_tag_pre_exec(struct cvsroot *root)
static int
cvs_tag_remote(CVSFILE *cfp, void *arg)
{
- int ret;
char fpath[MAXPATHLEN];
struct cvsroot *root;
- ret = 0;
root = CVS_DIR_ROOT(cfp);
if (cfp->cf_type == DT_DIR) {
- if (cvs_senddir(root, cfp) < 0)
- ret = CVS_EX_PROTO;
- return (ret);
- }
-
- if (cvs_sendentry(root, cfp) < 0) {
- return (CVS_EX_PROTO);
+ cvs_senddir(root, cfp);
+ return (0);
}
+ cvs_sendentry(root, cfp);
cvs_file_getpath(cfp, fpath, sizeof(fpath));
switch (cfp->cf_cvstat) {
case CVS_FST_UNKNOWN:
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cfp->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cfp->cf_name);
break;
case CVS_FST_UPTODATE:
- ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, cfp->cf_name);
+ cvs_sendreq(root, CVS_REQ_UNCHANGED, cfp->cf_name);
break;
case CVS_FST_MODIFIED:
- ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED, cfp->cf_name);
+ cvs_sendreq(root, CVS_REQ_ISMODIFIED, cfp->cf_name);
default:
break;
}
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ return (0);
}
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index b42cb9a7198..141dea3fa4d 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.48 2005/12/22 14:59:54 xsa Exp $ */
+/* $OpenBSD: update.c,v 1.49 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -133,21 +133,24 @@ static int
cvs_update_pre_exec(struct cvsroot *root)
{
if (root->cr_method != CVS_METHOD_LOCAL) {
- if ((cvs_cmd_update.cmd_flags & CVS_CMD_PRUNEDIRS) &&
- (cvs_sendarg(root, "-P", 0) < 0))
- return (CVS_EX_PROTO);
- if (Aflag && cvs_sendarg(root, "-A", 0) < 0)
- return (CVS_EX_PROTO);
- if (dflag && cvs_sendarg(root, "-d", 0) < 0)
- return (CVS_EX_PROTO);
-
- if ((rev != NULL) && ((cvs_sendarg(root, "-r", 0) < 0) ||
- (cvs_sendarg(root, rev, 0) < 0)))
- return (CVS_EX_PROTO);
-
- if ((date != NULL) && ((cvs_sendarg(root, "-D", 0) < 0) ||
- (cvs_sendarg(root, date, 0) < 0)))
- return (CVS_EX_PROTO);
+ if (cvs_cmd_update.cmd_flags & CVS_CMD_PRUNEDIRS)
+ cvs_sendarg(root, "-P", 0);
+
+ if (Aflag)
+ cvs_sendarg(root, "-A", 0);
+
+ if (dflag)
+ cvs_sendarg(root, "-d", 0);
+
+ if (rev != NULL) {
+ cvs_sendarg(root, "-r", 0);
+ cvs_sendarg(root, rev, 0);
+ }
+
+ if (date != NULL) {
+ cvs_sendarg(root, "-D", 0);
+ cvs_sendarg(root, date, 0);
+ }
}
return (0);
@@ -162,55 +165,43 @@ cvs_update_pre_exec(struct cvsroot *root)
static int
cvs_update_remote(CVSFILE *cf, void *arg)
{
- int ret;
char fpath[MAXPATHLEN];
struct cvsroot *root;
- ret = 0;
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
else
- ret = cvs_senddir(root, cf);
-
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ cvs_senddir(root, cf);
+ return (0);
}
cvs_file_getpath(cf, fpath, sizeof(fpath));
- if (cvs_sendentry(root, cf) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendentry(root, cf);
if (!(cf->cf_flags & CVS_FILE_ONDISK))
return (0);
switch (cf->cf_cvstat) {
case CVS_FST_UNKNOWN:
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
break;
case CVS_FST_UPTODATE:
- ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
break;
case CVS_FST_ADDED:
case CVS_FST_MODIFIED:
- ret = cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name);
- if (ret == 0)
- ret = cvs_sendfile(root, fpath);
+ cvs_sendreq(root, CVS_REQ_MODIFIED, cf->cf_name);
+ cvs_sendfile(root, fpath);
break;
default:
break;
}
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ return (0);
}
/*
diff --git a/usr.bin/cvs/watch.c b/usr.bin/cvs/watch.c
index 781bad239e1..0fe5d86ea86 100644
--- a/usr.bin/cvs/watch.c
+++ b/usr.bin/cvs/watch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: watch.c,v 1.8 2005/12/10 20:27:45 joris Exp $ */
+/* $OpenBSD: watch.c,v 1.9 2005/12/30 02:03:28 joris Exp $ */
/*
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
* Copyright (c) 2005 Moritz Jodeit <moritz@openbsd.org>
@@ -155,23 +155,18 @@ cvs_watch_pre_exec(struct cvsroot *root)
if (aoptstr == NULL || strcmp(aoptstr, "all") == 0) {
/* Defaults to: edit, unedit, commit */
- if ((cvs_sendarg(root, "-a", 0) < 0) ||
- (cvs_sendarg(root, "edit", 0) < 0) ||
- (cvs_sendarg(root, "-a", 0) < 0) ||
- (cvs_sendarg(root, "unedit", 0) < 0) ||
- (cvs_sendarg(root, "-a", 0) < 0) ||
- (cvs_sendarg(root, "commit", 0) < 0)) {
- xfree(aoptstr);
- return (CVS_EX_PROTO);
- }
+ cvs_sendarg(root, "-a", 0);
+ cvs_sendarg(root, "edit", 0);
+ cvs_sendarg(root, "-a", 0);
+ cvs_sendarg(root, "unedit", 0);
+ cvs_sendarg(root, "-a", 0);
+ cvs_sendarg(root, "commit", 0);
} else {
- if ((cvs_sendarg(root, "-a", 0) < 0) ||
- (cvs_sendarg(root, aoptstr, 0) < 0)) {
- xfree(aoptstr);
- return (CVS_EX_PROTO);
- }
+ cvs_sendarg(root, "-a", 0);
+ cvs_sendarg(root, aoptstr, 0);
}
}
+
xfree(aoptstr);
return (CVS_EX_OK);
@@ -196,47 +191,36 @@ cvs_watch_local(CVSFILE *cf, void *arg)
static int
cvs_watch_remote(CVSFILE *cf, void *arg)
{
- int ret;
struct cvsroot *root;
- ret = 0;
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
if (cf->cf_cvstat == CVS_FST_UNKNOWN)
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
- cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
else
- ret = cvs_senddir(root, cf);
-
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ cvs_senddir(root, cf);
+ return (0);
}
- if (cvs_sendentry(root, cf) < 0)
- return (CVS_EX_PROTO);
+ cvs_sendentry(root, cf);
switch (cf->cf_cvstat) {
case CVS_FST_UNKNOWN:
- ret = cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_QUESTIONABLE, cf->cf_name);
break;
case CVS_FST_UPTODATE:
- ret = cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_UNCHANGED, cf->cf_name);
break;
case CVS_FST_ADDED:
case CVS_FST_MODIFIED:
- ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
+ cvs_sendreq(root, CVS_REQ_ISMODIFIED, cf->cf_name);
break;
default:
break;
}
- if (ret == -1)
- ret = CVS_EX_PROTO;
-
- return (ret);
+ return (0);
}