Module Name: src
Committed By: pooka
Date: Fri Nov 5 13:50:48 UTC 2010
Modified Files:
src/lib/librumpclient: rumpclient.c
Log Message:
use -1/errno for failure: it's much more convenient for the users
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/librumpclient/rumpclient.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/librumpclient/rumpclient.c
diff -u src/lib/librumpclient/rumpclient.c:1.1 src/lib/librumpclient/rumpclient.c:1.2
--- src/lib/librumpclient/rumpclient.c:1.1 Thu Nov 4 21:01:29 2010
+++ src/lib/librumpclient/rumpclient.c Fri Nov 5 13:50:48 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpclient.c,v 1.1 2010/11/04 21:01:29 pooka Exp $ */
+/* $NetBSD: rumpclient.c,v 1.2 2010/11/05 13:50:48 pooka Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -186,25 +186,32 @@
unsigned idx;
int error, s;
- if ((p = getenv("RUMP_SP_CLIENT")) == NULL)
- return ENOENT;
+ if ((p = getenv("RUMP_SP_CLIENT")) == NULL) {
+ errno = ENOENT;
+ return -1;
+ }
- if ((error = parseurl(p, &sap, &idx, 0)) != 0)
- return error;
+ if ((error = parseurl(p, &sap, &idx, 0)) != 0) {
+ errno = error;
+ return -1;
+ }
s = socket(parsetab[idx].domain, SOCK_STREAM, 0);
if (s == -1)
- return errno;
+ return -1;
if (connect(s, sap, sap->sa_len) == -1) {
+ error = errno;
fprintf(stderr, "rump_sp: client connect failed\n");
- return errno;
+ errno = error;
+ return -1;
}
if ((error = parsetab[idx].connhook(s)) != 0) {
+ error = errno;
fprintf(stderr, "rump_sp: connect hook failed\n");
- return error;
+ errno = error;
+ return -1;
}
-
clispc.spc_fd = s;
return 0;