TT#26513 Preserve errno on error returns

We should preserve the errno value so that the caller can report
accurate error information, as the close() call could fail too.

Change-Id: I1a36ace8f47ad3ea550aa3e2e272922633abfdca
changes/95/17695/1
Guillem Jover 8 years ago
parent 77de3d06ea
commit 1b8f5e4a55

@ -30,6 +30,7 @@ struct kernel_interface kernel;
static int kernel_create_table(unsigned int id) {
char str[64];
int saved_errno;
int fd;
int i;
@ -45,12 +46,15 @@ static int kernel_create_table(unsigned int id) {
return 0;
fail:
saved_errno = errno;
close(fd);
errno = saved_errno;
return -1;
}
static int kernel_open_table(unsigned int id) {
char str[64];
int saved_errno;
int fd;
struct rtpengine_message msg;
int i;
@ -69,7 +73,9 @@ static int kernel_open_table(unsigned int id) {
return fd;
fail:
saved_errno = errno;
close(fd);
errno = saved_errno;
return -1;
}

Loading…
Cancel
Save