Repository: libsdl-org/SDL
File: src/core/freebsd/SDL_evdev_kbd_freebsd.c (C)

Code before:
        return;
    }

    if(tcgetattr(state->console_fd, &tios) == -1) {
        SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get terminal mode: %s", strerror(errno));
        return;
    }

    if (muted) {
        if(SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, true)) {
            ioctl(state->console_fd, KDSKBMODE, K_OFF);
            cfmakeraw(&tios);

            if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, false)) {
                kbd_register_emerg_cleanup(state);
            }
        }
    } else {
        kbd_unregister_emerg_cleanup();

        cfmakesane(&tios);
        ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode);
    }

    if(tcsetattr(state->console_fd, TCSAFLUSH, &tios) == -1) {
        SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set terminal mode to %s: %s", muted ? "raw" : "sane", strerror(errno));
        return;
    }

    state->muted = muted;
}

void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void *), void *release_callback_data, void (*acquire_callback)(void *), void *acquire_callback_data)
{
    if (state == NULL) {
        return;
    }

    state->vt_release_callback = release_callback;
    state->vt_release_callback_data = release_callback_data;
    state->vt_acquire_callback = acquire_callback;
    state->vt_acquire_callback_data = acquire_callback_data;
}

void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state)
{
    if (!state) {
        return;
    }

    int signal_pending = SDL_GetAtomicInt(&vt_signal_pending);

Review comment (suggestion):
```suggestion
    if (tcsetattr(state->console_fd, TCSAFLUSH, &tios) == -1) {
        SDL_LogError(SDL_LOG_CATEGORY_INPUT, "Could not set terminal mode to %s: %s", muted ? "raw" : "sane", strerror(errno));
```

Code after:
    }

    if (muted == state->muted) {
        return;
    }

    if (tcgetattr(state->console_fd, &tios) == -1) {
        SDL_LogError(SDL_LOG_CATEGORY_INPUT, "Could not get terminal mode: %s", strerror(errno));
        return;
    }

    if (muted) {
        if (SDL_GetHintBoolean(SDL_HINT_MUTE_CONSOLE_KEYBOARD, true)) {
            ioctl(state->console_fd, KDSKBMODE, K_OFF);
            cfmakeraw(&tios);

            if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, false)) {
                kbd_register_emerg_cleanup(state);
            }
        }
    } else {
        kbd_unregister_emerg_cleanup();

        cfmakesane(&tios);
        ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode);
    }

    if (tcsetattr(state->console_fd, TCSAFLUSH, &tios) == -1) {
        SDL_LogError(SDL_LOG_CATEGORY_INPUT, "Could not set terminal mode to %s: %s", muted ? "raw" : "sane", strerror(errno));
        return;
    }

    state->muted = muted;
}

void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void *), void *release_callback_data, void (*acquire_callback)(void *), void *acquire_callback_data)
{
    if (state == NULL) {
        return;
    }

    state->vt_release_callback = release_callback;
    state->vt_release_callback_data = release_callback_data;
    state->vt_acquire_callback = acquire_callback;
    state->vt_acquire_callback_data = acquire_callback_data;
}

void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state)
{
    if (!state) {
        return;