{
struct netifd_process *proc;
const char *log_prefix;
- char *buf, *cur;
+ char *buf, *start, *cur;
int maxlen, len, read_len;
proc = container_of(fd, struct netifd_process, log_uloop);
proc->log_buf_ofs += len;
cur = buf;
- buf = proc->log_buf;
- while (len > 0 && (cur = memchr(cur, '\n', len))) {
+ start = proc->log_buf;
+ while (len > 0) {
+ cur = memchr(cur, '\n', len);
+ if (!cur)
+ break;
+
*cur = 0;
if (!proc->log_overflow)
netifd_log_message(L_NOTICE, "%s (%d): %s\n",
- log_prefix, proc->uloop.pid, buf);
+ log_prefix, proc->uloop.pid, start);
else
proc->log_overflow = false;
cur++;
len -= cur - buf;
- buf = cur;
+ buf = start = cur;
}
if (buf > proc->log_buf && len > 0)