mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Check return values from some syscalls and warn if they fail
This commit is contained in:
parent
85d9fa1922
commit
dac67a567d
@ -968,7 +968,9 @@ static void cmd_cd(const char *data)
|
||||
if (*data == '\0') return;
|
||||
|
||||
str = convert_home(data);
|
||||
chdir(str);
|
||||
if (chdir(str) != 0) {
|
||||
g_warning("Failed to chdir(): %s", strerror(errno));
|
||||
}
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
|
@ -102,10 +102,15 @@ void rawlog_redirect(RAWLOG_REC *rawlog, const char *str)
|
||||
static void rawlog_dump(RAWLOG_REC *rawlog, int f)
|
||||
{
|
||||
GSList *tmp;
|
||||
ssize_t ret = 1;
|
||||
|
||||
for (tmp = rawlog->lines; tmp != NULL; tmp = tmp->next) {
|
||||
write(f, tmp->data, strlen((char *) tmp->data));
|
||||
write(f, "\n", 1);
|
||||
for (tmp = rawlog->lines; ret && tmp != NULL; tmp = tmp->next) {
|
||||
ret = write(f, tmp->data, strlen((char *) tmp->data));
|
||||
ret &= write(f, "\n", 1);
|
||||
}
|
||||
|
||||
if (ret <= 0) {
|
||||
g_warning("rawlog write() failed: %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,9 @@ static int write_buffer_flush_rec(void *handlep, BUFFER_REC *rec)
|
||||
for (tmp = rec->blocks; tmp != NULL; tmp = tmp->next) {
|
||||
size = tmp->data != rec->active_block ? BUFFER_BLOCK_SIZE :
|
||||
rec->active_block_pos;
|
||||
write(handle, tmp->data, size);
|
||||
if (write(handle, tmp->data, size) != size) {
|
||||
g_warning("Failed to write(): %s", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
empty_blocks = g_slist_concat(empty_blocks, rec->blocks);
|
||||
|
Loading…
Reference in New Issue
Block a user