Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel/libc: fix putchar() #616

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/kernel/sys/k_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@
ssize_t k_write(int fd, const void* buf, size_t count)
{
if (fd == STDOUT || fd == STDERR) {
// TODO: Make the code in this block better.
const char* s = (const char*)buf;
if (count > strlen(s)) {
count = strlen(s);
}

for (size_t i = 0; i < count; i++) {
arch_putchar(s[i]);
arch_putchar(((const char*)buf)[i]);
}

return count;
Expand Down
3 changes: 1 addition & 2 deletions src/libc/putchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

void putchar(char c)
{
// Make sure we write a null-terminated string.
write(STDOUT_FILENO, (char[]){ c, '\0' }, 1);
write(STDOUT_FILENO, &c, 1);
}