diff options
author | daniel <danieruru@gmail.com> | 2013-01-30 12:35:55 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-30 12:35:55 +0900 |
commit | e57b4a0ad419ce9af8017120ab60b54304fa0835 (patch) | |
tree | 311cf6c265997db9db4805cf12170fecc24f71ec /libvxi11client | |
parent | c4957e4c650008698226c9b4b236222280f16396 (diff) |
Make it easier to tell if a zero read/write happened or an error
Diffstat (limited to 'libvxi11client')
-rw-r--r-- | libvxi11client/libvxi11client.c | 5 |
1 files changed, 4 insertions, 1 deletions
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); |