lint(tidy): some clang-tidy work

This commit is contained in:
2025-06-10 21:43:01 +02:00
parent 6975c265f0
commit a846c1b4c9
16 changed files with 265 additions and 205 deletions

View File

@@ -11,6 +11,7 @@ static char* vterms[] = {"/dev/tty", "/dev/tty0", "/dev/vc/0", "/dev/systty",
int chvt_str(char* str) {
char* err;
errno = 0;
// NOLINTNEXTLINE(readability-identifier-length)
long i = strtol(str, &err, 10);
if (errno) {
perror("strol");
@@ -23,13 +24,16 @@ int chvt_str(char* str) {
}
int chvt(int n) {
fprintf(stderr, "activating vt %d\n", n);
// NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
(void)fprintf(stderr, "activating vt %d\n", n);
// NOLINTNEXTLINE(readability-identifier-length)
char c = 0;
for (size_t i = 0; i < sizeof(vterms) / sizeof(vterms[0]); i++) {
int fd = open(vterms[i], O_RDWR);
if (fd >= 0 && isatty(fd) && ioctl(fd, KDGKBTYPE, &c) == 0 && c < 3) {
if (ioctl(fd, VT_ACTIVATE, n) < 0 || ioctl(fd, VT_WAITACTIVE, n) < 0) {
fprintf(stderr, "Couldn't activate vt %d\n", n);
// NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
(void)fprintf(stderr, "Couldn't activate vt %d\n", n);
return -1;
}
return 0;
@@ -37,6 +41,6 @@ int chvt(int n) {
close(fd);
}
fprintf(stderr, "Couldn't get a file descriptor referring to the console.\n");
(void)fputs("Couldn't get a file descriptor referring to the console.\n", stderr);
return -1;
}