Skip to content

Commit 3434e29

Browse files
Tri VoGerrit Code Review
Tri Vo
authored and
Gerrit Code Review
committed
Merge changes I46a58ae9,I5eb8413e
* changes: trusty: wrap syscalls in TEMP_FAILURE_RETRY trusty: Reformat libtrusty
2 parents 279a719 + 27b0b3f commit 3434e29

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

trusty/libtrusty/trusty.c

+21-25
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,27 @@
2929

3030
#include <trusty/ipc.h>
3131

32-
int tipc_connect(const char *dev_name, const char *srv_name)
33-
{
34-
int fd;
35-
int rc;
32+
int tipc_connect(const char* dev_name, const char* srv_name) {
33+
int fd;
34+
int rc;
3635

37-
fd = open(dev_name, O_RDWR);
38-
if (fd < 0) {
39-
rc = -errno;
40-
ALOGE("%s: cannot open tipc device \"%s\": %s\n",
41-
__func__, dev_name, strerror(errno));
42-
return rc < 0 ? rc : -1;
43-
}
36+
fd = TEMP_FAILURE_RETRY(open(dev_name, O_RDWR));
37+
if (fd < 0) {
38+
rc = -errno;
39+
ALOGE("%s: cannot open tipc device \"%s\": %s\n", __func__, dev_name, strerror(errno));
40+
return rc < 0 ? rc : -1;
41+
}
4442

45-
rc = ioctl(fd, TIPC_IOC_CONNECT, srv_name);
46-
if (rc < 0) {
47-
rc = -errno;
48-
ALOGE("%s: can't connect to tipc service \"%s\" (err=%d)\n",
49-
__func__, srv_name, errno);
50-
close(fd);
51-
return rc < 0 ? rc : -1;
52-
}
43+
rc = TEMP_FAILURE_RETRY(ioctl(fd, TIPC_IOC_CONNECT, srv_name));
44+
if (rc < 0) {
45+
rc = -errno;
46+
ALOGE("%s: can't connect to tipc service \"%s\" (err=%d)\n", __func__, srv_name, errno);
47+
close(fd);
48+
return rc < 0 ? rc : -1;
49+
}
5350

54-
ALOGV("%s: connected to \"%s\" fd %d\n", __func__, srv_name, fd);
55-
return fd;
51+
ALOGV("%s: connected to \"%s\" fd %d\n", __func__, srv_name, fd);
52+
return fd;
5653
}
5754

5855
ssize_t tipc_send(int fd, const struct iovec* iov, int iovcnt, struct trusty_shm* shms,
@@ -63,15 +60,14 @@ ssize_t tipc_send(int fd, const struct iovec* iov, int iovcnt, struct trusty_shm
6360
req.shm = (__u64)shms;
6461
req.shm_cnt = (__u64)shmcnt;
6562

66-
int rc = ioctl(fd, TIPC_IOC_SEND_MSG, &req);
63+
int rc = TEMP_FAILURE_RETRY(ioctl(fd, TIPC_IOC_SEND_MSG, &req));
6764
if (rc < 0) {
6865
ALOGE("%s: failed to send message (err=%d)\n", __func__, rc);
6966
}
7067

7168
return rc;
7269
}
7370

74-
void tipc_close(int fd)
75-
{
76-
close(fd);
71+
void tipc_close(int fd) {
72+
close(fd);
7773
}

0 commit comments

Comments
 (0)