Fakultas Ilmu Komputer UI

Commit 7b190eef authored by Ardhi Putra Pratama's avatar Ardhi Putra Pratama
Browse files

Fix bug extra char returned

parent c10aa4b9
......@@ -111,10 +111,11 @@ static ssize_t dev_write(struct file *filep, const char *buffer, size_t len, lof
size_t bytesNotCopied = 0;
bytesNotCopied = copy_from_user(message, buffer, bytesToCopy);
sprintf(message + bytesToCopy - bytesNotCopied, "(%zu letters)", bytesToCopy - bytesNotCopied);
size_of_message = bytesToCopy - bytesNotCopied + 1;
size_of_message = bytesToCopy - bytesNotCopied;
sprintf(message + size_of_message, "(%zu letters)", size_of_message);
printk(KERN_INFO "RDcdevdr: Received %zu characters from the user\n", bytesToCopy - bytesNotCopied);
printk(KERN_INFO "RDcdevdr: Received %zu characters from the user\n", size_of_message);
if(bytesNotCopied){
printk(KERN_INFO "RDcdevdr: Failed to receive %zu characters, -EFAULT!\n", bytesNotCopied);
return -EFAULT;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment