Refactor, wrap write() syscall in new dprint() function

Fixes the GCC warning for unchecked return value from write():

  ... ignoring return value of ‘write’, declared with attribute warn_unused_result

The new dprint() function wraps write() in a bounded retry-loop that
catches EINTR.  The length argument is optional computed with strlen()
if omitted (zero).

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-04-04 12:35:35 +02:00
1 parent c84c17ea8c
commit 5342881bf4
5 files changed
+41 -24

No files matched your search

+1 -1
View File
@@ -170,7 +170,7 @@ ssize_t cprintf(const char *fmt, ...)
va_end(ap);
for (i = 0; i < num_cons; i++)
(void)write(fds[i], buf, size);
dprint(fds[i], buf, size);
return size;
}