Add a safe wrapper for write and fix some warnings
1. Add a function writeall and make swrite wrap that function. Use either writeall or swrite, depending on whether we want to exit on errors or not. 2. Fix warnings when compiling with a higher optimisation level. (CFLAGS ?= -pipe -O3 -march=native -mtune=native -freorder-blocks-and-partition) Signed-off-by: hwangcc <hwangcc@csie.nctu.edu.tw>
This commit is contained in:
@ -296,18 +296,7 @@ int i3_send_msg(uint32_t type, const char *payload) {
|
||||
if (payload != NULL)
|
||||
strncpy(walk, payload, len);
|
||||
|
||||
uint32_t written = 0;
|
||||
|
||||
while (to_write > 0) {
|
||||
int n = write(i3_connection->fd, buffer + written, to_write);
|
||||
if (n == -1) {
|
||||
ELOG("write() failed: %s\n", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
to_write -= n;
|
||||
written += n;
|
||||
}
|
||||
swrite(i3_connection->fd, buffer, to_write);
|
||||
|
||||
FREE(buffer);
|
||||
|
||||
|
Reference in New Issue
Block a user