Commit 2829628
committed
Fix missing newline in sysfs file
When using cat command to read /sys/class/kxo/kxo/kxo_state file, the
output (e.g., "1 1 0") did not include a newline, causing the terminal
prompt to appear on the same line (e.g., "1 1 0user@Ubuntu:~$").
This truncation issue is diagnosed by examining kxo_state_show, which
uses snprintf with a format string "%c %c %c\n". The size parameter of
snprintf set to 6 included the null terminator \0 as the last character,
leaving only 5 bytes for the desired output (e.g., "1 0 0\n"), thus the
newline symbol \n was truncated by null terminator.
This commit resolves the issue by increasing the size parameter of
snprintf from 6 to 7, ensuring the output includes the newline.1 parent efff9ee commit 2829628
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
0 commit comments