api_debug_log doesn't print the last character if the buffer is full

21 views
Skip to first unread message

Sanguk Park

unread,
Aug 20, 2019, 1:56:20 AM8/20/19
to Hafnium
This is current implementation of api_debug_log is here:

int64_t api_debug_log(char c, struct vcpu *current)
{
    struct vm *vm = current->vm;
    struct vm_locked vm_locked = vm_lock(vm);
    if (c == '\n' || c == '\0' ||
        vm->log_buffer_length == sizeof(vm->log_buffer)) {
        dlog_flush_vm_buffer(vm->id, vm->log_buffer,
                     vm->log_buffer_length);
        vm->log_buffer_length = 0;
    } else {
        vm->log_buffer[vm->log_buffer_length++] = c;
    }
    vm_unlock(&vm_locked);
    return 0;
}

I think that this code doesn't print `c` if vm->log_buffer_length == sizeof(vm->log_buffer). Is it intended?

Andrew Scull

unread,
Aug 20, 2019, 6:11:38 AM8/20/19
to Sanguk Park, Hafnium
Thanks, again! No, that doesn't seem right. Uploaded a CL to https://hafnium-review.googlesource.com/c/hafnium/+/6321.

--
You received this message because you are subscribed to the Google Groups "Hafnium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hafnium-discu...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/hafnium-discuss/8548d472-e5da-4add-8791-fb2088ff7ae7%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages