basic/io-util: invert return value from IOVEC_INCREMENT()
We would try to return a value that could be nonzero only if the kernel reported writing more bytes than we gave to it, hopefully a rare occurence. Instead, assert that this doesn't happen. Instead, return true if we got to the end of the iovec array. The caller can use this information to know that the whole iovec array was written. This allows one loop to be dropped in write_to_syslog(). Also drop _unlikely_: this function is called with very short arrays, and it *is* likely that we trigger this condition. Let's just let the compiler generate normal code without giving it a potentially false hint.
This commit is contained in:
+3
-3
@@ -491,11 +491,11 @@ static int write_to_syslog(
|
||||
if (n < 0)
|
||||
return -errno;
|
||||
|
||||
if (!syslog_is_stream ||
|
||||
(size_t) n >= IOVEC_TOTAL_SIZE(iovec, ELEMENTSOF(iovec)))
|
||||
if (!syslog_is_stream)
|
||||
break;
|
||||
|
||||
IOVEC_INCREMENT(iovec, ELEMENTSOF(iovec), n);
|
||||
if (IOVEC_INCREMENT(iovec, ELEMENTSOF(iovec), n))
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user