summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2009-04-07 14:22:57 +0200
committerJulien Danjou <julien@danjou.info>2009-04-10 09:59:49 +0200
commitca978a9dae621126075712f9e2c29591208570bc (patch)
treed3e4679ffbd9eeff8bcfef35536468ccdc8ba8f5
parentcc191431412d8764c645a51b0f106c0dfe652213 (diff)
util: remove useless strlen calls from decnet opening
Signed-off-by: Julien Danjou <julien@danjou.info>
-rw-r--r--src/xcb_util.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/xcb_util.c b/src/xcb_util.c
index 54361f4..adac909 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -193,8 +193,9 @@ static int _xcb_open_decnet(const char *host, const char *protocol, const unsign
addr.sdn_add.a_len = nodeaddr->n_length;
memcpy(addr.sdn_add.a_addr, nodeaddr->n_addr, addr.sdn_add.a_len);
- sprintf((char *)addr.sdn_objname, "X$X%d", port);
- addr.sdn_objnamel = strlen((char *)addr.sdn_objname);
+ addr.sdn_objnamel = sprintf((char *)addr.sdn_objname, "X$X%d", port);
+ if(addr.sdn_objnamel < 0)
+ return -1;
addr.sdn_objnum = 0;
fd = socket(PF_DECnet, SOCK_STREAM, 0);
@@ -202,8 +203,9 @@ static int _xcb_open_decnet(const char *host, const char *protocol, const unsign
return -1;
memset(&accessdata, 0, sizeof(accessdata));
- sprintf((char*)accessdata.acc_acc, "%d", getuid());
- accessdata.acc_accl = strlen((char *)accessdata.acc_acc);
+ accessdata.acc_accl = sprintf((char*)accessdata.acc_acc, "%d", getuid());
+ if(accessdata.acc_accl < 0)
+ return -1;
setsockopt(fd, DNPROTO_NSP, SO_CONACCESS, &accessdata, sizeof(accessdata));
if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1) {