treewide: Use L_TFR macro

This commit is contained in:
Denis Kenzior 2019-05-24 11:55:38 -05:00
parent 8bde9f095a
commit 765c6655f2
4 changed files with 30 additions and 35 deletions

View File

@ -421,7 +421,7 @@ static int receive_header(struct mbim_device *device, int fd)
{ {
size_t to_read = sizeof(struct mbim_message_header) - size_t to_read = sizeof(struct mbim_message_header) -
device->header_offset; device->header_offset;
ssize_t len = TEMP_FAILURE_RETRY(read(fd, ssize_t len = L_TFR(read(fd,
device->header + device->header_offset, device->header + device->header_offset,
to_read)); to_read));
@ -485,7 +485,7 @@ static bool command_write_handler(struct l_io *io, void *user_data)
pos += body[i].iov_len; pos += body[i].iov_len;
} }
written = TEMP_FAILURE_RETRY(write(fd, buf, pos)); written = L_TFR(write(fd, buf, pos));
l_info("n_iov: %zu, %zu", n_iov + 1, (size_t) written); l_info("n_iov: %zu, %zu", n_iov + 1, (size_t) written);
@ -656,7 +656,7 @@ static bool command_read_handler(struct l_io *io, void *user_data)
(header_size - device->header_offset); (header_size - device->header_offset);
n_iov += 1; n_iov += 1;
len = TEMP_FAILURE_RETRY(readv(fd, iov, n_iov)); len = L_TFR(readv(fd, iov, n_iov));
if (len < 0) { if (len < 0) {
if (errno == EAGAIN) if (errno == EAGAIN)
return true; return true;
@ -717,7 +717,7 @@ static bool open_write_handler(struct l_io *io, void *user_data)
fd = l_io_get_fd(io); fd = l_io_get_fd(io);
written = TEMP_FAILURE_RETRY(write(fd, buf, sizeof(buf))); written = L_TFR(write(fd, buf, sizeof(buf)));
if (written < 0) if (written < 0)
return false; return false;
@ -758,7 +758,7 @@ static bool open_read_handler(struct l_io *io, void *user_data)
sizeof(struct mbim_message_header); sizeof(struct mbim_message_header);
} }
len = TEMP_FAILURE_RETRY(read(fd, buf, len = L_TFR(read(fd, buf,
device->segment_bytes_remaining)); device->segment_bytes_remaining));
if (len < 0) { if (len < 0) {
if (errno == EAGAIN) if (errno == EAGAIN)
@ -812,7 +812,7 @@ static bool close_write_handler(struct l_io *io, void *user_data)
fd = l_io_get_fd(io); fd = l_io_get_fd(io);
written = TEMP_FAILURE_RETRY(write(fd, buf, sizeof(buf))); written = L_TFR(write(fd, buf, sizeof(buf)));
if (written < 0) if (written < 0)
return false; return false;
@ -865,7 +865,7 @@ static bool close_read_handler(struct l_io *io, void *user_data)
sizeof(struct mbim_message_header); sizeof(struct mbim_message_header);
} }
len = TEMP_FAILURE_RETRY(read(fd, buf, len = L_TFR(read(fd, buf,
device->segment_bytes_remaining)); device->segment_bytes_remaining));
if (len < 0) { if (len < 0) {
if (errno == EAGAIN) if (errno == EAGAIN)

View File

@ -274,7 +274,7 @@ static void sim_fs_end_current(struct sim_fs *fs)
__ofono_sim_remove_session_watch(fs->session, fs->watch_id); __ofono_sim_remove_session_watch(fs->session, fs->watch_id);
if (fs->fd != -1) { if (fs->fd != -1) {
TFR(close(fs->fd)); L_TFR(close(fs->fd));
fs->fd = -1; fs->fd = -1;
} }
@ -320,7 +320,7 @@ static gboolean cache_block(struct sim_fs *fs, int block, int block_len,
SIM_CACHE_HEADER_SIZE, SEEK_SET) == (off_t) -1) SIM_CACHE_HEADER_SIZE, SEEK_SET) == (off_t) -1)
return FALSE; return FALSE;
r = TFR(write(fs->fd, data, num_bytes)); r = L_TFR(write(fs->fd, data, num_bytes));
if (r != num_bytes) if (r != num_bytes)
return FALSE; return FALSE;
@ -335,7 +335,7 @@ static gboolean cache_block(struct sim_fs *fs, int block, int block_len,
b = fs->bitmap[offset]; b = fs->bitmap[offset];
b |= 1 << bit; b |= 1 << bit;
r = TFR(write(fs->fd, &b, sizeof(b))); r = L_TFR(write(fs->fd, &b, sizeof(b)));
if (r != sizeof(b)) if (r != sizeof(b))
return FALSE; return FALSE;
@ -477,7 +477,7 @@ static gboolean sim_fs_op_read_block(gpointer user_data)
if (lseek(fs->fd, seekoff, SEEK_SET) == (off_t) -1) if (lseek(fs->fd, seekoff, SEEK_SET) == (off_t) -1)
break; break;
if (TFR(read(fs->fd, op->buffer + bufoff, toread)) != toread) if (L_TFR(read(fs->fd, op->buffer + bufoff, toread)) != toread)
break; break;
op->current += 1; op->current += 1;
@ -569,7 +569,7 @@ static gboolean sim_fs_op_read_record(gpointer user)
SIM_CACHE_HEADER_SIZE, SEEK_SET) == (off_t) -1) SIM_CACHE_HEADER_SIZE, SEEK_SET) == (off_t) -1)
break; break;
if (TFR(read(fs->fd, buf, op->record_length)) != if (L_TFR(read(fs->fd, buf, op->record_length)) !=
op->record_length) op->record_length)
break; break;
@ -660,17 +660,17 @@ static void sim_fs_op_cache_fileinfo(struct sim_fs *fs,
fileinfo[6] = file_status; fileinfo[6] = file_status;
path = g_strdup_printf(SIM_CACHE_PATH, imsi, phase, op->id); path = g_strdup_printf(SIM_CACHE_PATH, imsi, phase, op->id);
fs->fd = TFR(open(path, O_WRONLY | O_CREAT | O_TRUNC, SIM_CACHE_MODE)); fs->fd = L_TFR(open(path, O_WRONLY | O_CREAT | O_TRUNC, SIM_CACHE_MODE));
g_free(path); g_free(path);
if (fs->fd == -1) if (fs->fd == -1)
return; return;
if (TFR(write(fs->fd, fileinfo, SIM_CACHE_HEADER_SIZE)) == if (L_TFR(write(fs->fd, fileinfo, SIM_CACHE_HEADER_SIZE)) ==
SIM_CACHE_HEADER_SIZE) SIM_CACHE_HEADER_SIZE)
return; return;
TFR(close(fs->fd)); L_TFR(close(fs->fd));
fs->fd = -1; fs->fd = -1;
} }
@ -761,7 +761,7 @@ static gboolean sim_fs_op_check_cached(struct sim_fs *fs)
if (path == NULL) if (path == NULL)
return FALSE; return FALSE;
fd = TFR(open(path, O_RDWR)); fd = L_TFR(open(path, O_RDWR));
g_free(path); g_free(path);
if (fd == -1) { if (fd == -1) {
@ -773,7 +773,7 @@ static gboolean sim_fs_op_check_cached(struct sim_fs *fs)
return FALSE; return FALSE;
} }
len = TFR(read(fd, fileinfo, SIM_CACHE_HEADER_SIZE)); len = L_TFR(read(fd, fileinfo, SIM_CACHE_HEADER_SIZE));
if (len != SIM_CACHE_HEADER_SIZE) if (len != SIM_CACHE_HEADER_SIZE)
goto error; goto error;
@ -827,7 +827,7 @@ static gboolean sim_fs_op_check_cached(struct sim_fs *fs)
return TRUE; return TRUE;
error: error:
TFR(close(fd)); L_TFR(close(fd));
return FALSE; return FALSE;
} }
@ -1187,8 +1187,8 @@ char *sim_fs_get_cached_image(struct sim_fs *fs, int id)
path = g_strdup_printf(SIM_IMAGE_CACHE_PATH, imsi, phase, id); path = g_strdup_printf(SIM_IMAGE_CACHE_PATH, imsi, phase, id);
TFR(stat(path, &st_buf)); L_TFR(stat(path, &st_buf));
fd = TFR(open(path, O_RDONLY)); fd = L_TFR(open(path, O_RDONLY));
g_free(path); g_free(path);
if (fd < 0) if (fd < 0)
@ -1198,12 +1198,12 @@ char *sim_fs_get_cached_image(struct sim_fs *fs, int id)
buffer = g_try_new0(char, image_length + 1); buffer = g_try_new0(char, image_length + 1);
if (buffer == NULL) { if (buffer == NULL) {
TFR(close(fd)); L_TFR(close(fd));
return NULL; return NULL;
} }
len = TFR(read(fd, buffer, image_length)); len = L_TFR(read(fd, buffer, image_length));
TFR(close(fd)); L_TFR(close(fd));
if (len != image_length) { if (len != image_length) {
g_free(buffer); g_free(buffer);

View File

@ -33,6 +33,7 @@
#include <errno.h> #include <errno.h>
#include <glib.h> #include <glib.h>
#include <ell/ell.h>
#include "storage.h" #include "storage.h"
@ -95,16 +96,16 @@ ssize_t read_file(unsigned char *buffer, size_t len,
path = g_strdup_vprintf(path_fmt, ap); path = g_strdup_vprintf(path_fmt, ap);
va_end(ap); va_end(ap);
fd = TFR(open(path, O_RDONLY)); fd = L_TFR(open(path, O_RDONLY));
g_free(path); g_free(path);
if (fd == -1) if (fd == -1)
return -1; return -1;
r = TFR(read(fd, buffer, len)); r = L_TFR(read(fd, buffer, len));
TFR(close(fd)); L_TFR(close(fd));
return r; return r;
} }
@ -137,13 +138,13 @@ ssize_t write_file(const unsigned char *buffer, size_t len, mode_t mode,
if (create_dirs(path, mode | S_IXUSR) != 0) if (create_dirs(path, mode | S_IXUSR) != 0)
goto error_create_dirs; goto error_create_dirs;
fd = TFR(g_mkstemp_full(tmp_path, O_WRONLY | O_CREAT | O_TRUNC, mode)); fd = L_TFR(g_mkstemp_full(tmp_path, O_WRONLY | O_CREAT | O_TRUNC, mode));
if (fd == -1) if (fd == -1)
goto error_mkstemp_full; goto error_mkstemp_full;
r = TFR(write(fd, buffer, len)); r = L_TFR(write(fd, buffer, len));
TFR(close(fd)); L_TFR(close(fd));
if (r != (ssize_t) len) { if (r != (ssize_t) len) {
r = -1; r = -1;

View File

@ -19,12 +19,6 @@
* *
*/ */
#ifdef TEMP_FAILURE_RETRY
#define TFR TEMP_FAILURE_RETRY
#else
#define TFR
#endif
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>