/* Prepend messages from STDOUT and STDERR with a tag and prio */
if (from_stdio) {
char *p;
- size_t chunk_len = 0;
+ size_t chunk_len = 0, c = 0;
/* -2 : priority byte and tag terminating '\0' */
size_t max_payload = LOGGER_ENTRY_MAX_PAYLOAD - writer->tag_len - 2;
if (writer->b_owner != current && writer->b_off)
flush_thread_data(file);
+ count = 0;
/* -1 : leave space for message terminating '\0' */
- count = min_t(size_t, iov_iter_count(from),
- max_payload - writer->b_off - 1);
+ c = min_t(size_t, iov_iter_count(from),
+ max_payload - writer->b_off - 1);
do {
- if (copy_from_iter(writer->buffer + writer->b_off, count, from) != count) {
+ if (copy_from_iter(writer->buffer + writer->b_off, c, from) != c) {
mutex_unlock(&log->mutex);
return -EFAULT;
}
-
+ count += c;
/* TODO: replace NULL characters with new lines */
- p = strnrchr(writer->buffer + writer->b_off, count, '\n');
+ p = strnrchr(writer->buffer + writer->b_off, c, '\n');
if (p) {
*p++ = '\0';
chunk_len = p - writer->buffer;
} else {
- writer->buffer[writer->b_off + count++] = '\0';
- p = &writer->buffer[writer->b_off + count];
+ writer->buffer[writer->b_off + c++] = '\0';
+ p = &writer->buffer[writer->b_off + c];
chunk_len = p - writer->buffer;
BUG_ON(chunk_len > max_payload);
if (chunk_len < max_payload ) {
- writer->b_off = writer->b_off + count - 1;
+ writer->b_off = writer->b_off + c - 1;
continue;
}
write_log_data(log, &header, writer, chunk_len);
/* move the remaining part of the message */
- memmove(writer->buffer, p, writer->b_off + count - chunk_len);
+ memmove(writer->buffer, p, writer->b_off + c - chunk_len);
/* new b_off points where the rimainder of the string ends */
- writer->b_off = writer->b_off + count - chunk_len;
+ writer->b_off = writer->b_off + c - chunk_len;
writer->buffer[writer->b_off] = '\0';
- } while ((count = min_t(size_t, iov_iter_count(from), max_payload - 1)));
+ } while ((c = min_t(size_t, iov_iter_count(from), max_payload - 1)));
/* save for remaining unfinished line */
writer->b_header = header;