From e57b4a0ad419ce9af8017120ab60b54304fa0835 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 30 Jan 2013 12:35:55 +0900 Subject: Make it easier to tell if a zero read/write happened or an error --- libvxi11client/libvxi11client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libvxi11client') diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c index 586e84f..601e490 100644 --- a/libvxi11client/libvxi11client.c +++ b/libvxi11client/libvxi11client.c @@ -200,8 +200,10 @@ int vxi11_write(VXI11Context* context, char* data, int len, bool waitlock, bool params.data.data_val = data; Device_WriteResp* resp = device_write_1(¶ms, context->clnt); - if (resp != NULL && resp->error == 0) + if (resp != NULL && resp->error == 0) { + errno = 0; return resp->size; + } else if (resp == NULL ) { errno = ERRNO_NULLRESULT; return 0; @@ -230,6 +232,7 @@ int vxi11_read(VXI11Context* context, char* buffer, unsigned int bufferlen, bool #ifdef DEBUG printf("Got \"%s\" from server\n", resp->data.data_val); #endif + errno = 0; if (buffer != NULL && resp->data.data_val != NULL ) { int lengthtocopy = ((bufferlen - 1) < resp->data.data_len ? (bufferlen - 1) : resp->data.data_len); strncpy(buffer, resp->data.data_val, lengthtocopy); -- cgit