mirror of
git://git.proxmox.com/git/proxmox-mini-journalreader.git
synced 2025-01-20 14:03:42 +03:00
correctly check write return value
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
de3b55a800
commit
d1a87ba237
@ -54,7 +54,10 @@ void print_to_buf(const char * string, uint32_t length) {
|
||||
strncpy(buf + offset, string + string_offset, BUFSIZE - offset);
|
||||
string_offset += BUFSIZE - offset;
|
||||
remaining = length - string_offset;
|
||||
write (1, buf, BUFSIZE);
|
||||
if (write (1, buf, BUFSIZE) <= 0) {
|
||||
perror("write to stdout failed");
|
||||
exit(1);
|
||||
}
|
||||
offset = 0;
|
||||
}
|
||||
strncpy(buf + offset, string + string_offset, remaining);
|
||||
@ -351,10 +354,13 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// print final cursor
|
||||
print_cursor(j);
|
||||
sd_journal_close(j);
|
||||
|
||||
// print remaining buffer
|
||||
write(1, buf, offset);
|
||||
sd_journal_close(j);
|
||||
if (write (1, buf, offset) <= 0) {
|
||||
perror("write to stdout failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user