← Commit list

816cd16a4

Kevin Cernekee
Kevin Cernekee
2011-08-16
FAILED Duration: 236s

Subject

cttyhack: remove the trailing newline when reading console name from sysfs

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/cttyhack.c+5 -3
@@ -122,10 +122,12 @@ int cttyhack_main(int argc UNUSED_PARAM, char **argv)
do {
#ifdef __linux__
int s = open_read_close("/sys/class/tty/console/active",
- console + 5, sizeof(console) - 5 - 1);
+ console + 5, sizeof(console) - 5);
if (s > 0) {
- /* found active console via sysfs (Linux 2.6.38+) */
- console[5 + s] = '\0';
+ /* found active console via sysfs (Linux 2.6.38+)
+ * sysfs string looks like "ttyS0\n" so zap the newline:
+ */
+ console[4 + s] = '\0';
break;
}