alsamixer: fix the verbose compilation warnings for latest gcc

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2023-08-30 12:36:45 +02:00
parent d609a58664
commit 10a2557d7e
6 changed files with 32 additions and 24 deletions

View file

@ -160,7 +160,7 @@ static unsigned int parse_words(const char *name, const char* wordlist, unsigned
char *endptr;
while (*name) {
for (i = 0; i < sizeof(buf) - 1; ++i) {
for (i = 0; i < (int)sizeof(buf) - 1; ++i) {
if (*name == '\0')
break;
if (*name == '_') {
@ -342,7 +342,7 @@ static int cfg_bind(char **argv, unsigned int argc) {
}
keys[0] = curskey_parse(argv[0]);
if (keys[0] < 0 || keys[0] >= ARRAY_SIZE(mixer_bindings)) {
if (keys[0] < 0 || keys[0] >= (int)ARRAY_SIZE(mixer_bindings)) {
error_message = _("invalid key");
error_cause = argv[0];
return ERROR_CONFIG;

View file

@ -34,9 +34,11 @@
static WINDOW *curses_initialized;
static void black_hole_error_handler(const char *file, int line,
const char *function, int err,
const char *fmt, ...)
static void black_hole_error_handler(const char *file ATTRIBUTE_UNUSED,
int line ATTRIBUTE_UNUSED,
const char *function ATTRIBUTE_UNUSED,
int err ATTRIBUTE_UNUSED,
const char *fmt ATTRIBUTE_UNUSED, ...)
{
}

View file

@ -51,7 +51,7 @@ int menu_widget_handle_key(MENU *menu, int key)
return -1;
default:
if (key < ARRAY_SIZE(textbox_bindings)) {
if (key < (int)ARRAY_SIZE(textbox_bindings)) {
key = textbox_bindings[key];
if (key >= CMD_TEXTBOX___MIN_MENU_COMMAND &&
key <= CMD_TEXTBOX___MAX_MENU_COMMAND)

View file

@ -107,8 +107,8 @@ void init_mixer_layout(void)
_("F6: Select sound card"),
_("Esc: Exit"),
};
unsigned int label_width_left, label_width_right;
unsigned int right_x, i;
int label_width_left, label_width_right;
int right_x, i;
clickable_clear(0, 0, -1, -1);
screen_too_small = screen_lines < 14 || screen_cols < 12;
@ -198,7 +198,7 @@ void display_view_mode(void)
_("Capture"),
_("All"),
};
unsigned int widths[3];
int widths[3];
bool has_view_mode;
int i;
@ -585,7 +585,7 @@ static void display_control(unsigned int control_index)
CMD_MIXER_MOUSE_CLICK_CONTROL_ENUM, control_index);
}
if (control_index == focus_control_index) {
if ((int)control_index == focus_control_index) {
i = first_control_x + col * (control_width + 1) + (control_width - control_name_width) / 2;
wattrset(mixer_widget.window, attrs.ctl_mark_focus);
mvwaddch(mixer_widget.window, name_y, i - 1, '<');
@ -642,7 +642,7 @@ static void display_scroll_indicators(void)
y0 = screen_lines * 3 / 8;
y1 = screen_lines * 5 / 8;
left = first_visible_control_index > 0 ? ACS_LARROW : ACS_VLINE;
right = first_visible_control_index + visible_controls < controls_count
right = first_visible_control_index + visible_controls < (int)controls_count
? ACS_RARROW : ACS_VLINE;
wattrset(mixer_widget.window, attrs.mixer_frame);
mvwvline(mixer_widget.window, y0, 0, left, y1 - y0 + 1);
@ -655,9 +655,9 @@ static void display_scroll_indicators(void)
void display_controls(void)
{
unsigned int i;
int i;
if (first_visible_control_index > controls_count - visible_controls)
if (first_visible_control_index > (int)controls_count - visible_controls)
first_visible_control_index = controls_count - visible_controls;
if (first_visible_control_index > focus_control_index)
first_visible_control_index = focus_control_index;
@ -724,7 +724,7 @@ void compute_controls_layout(void)
control_width = screen_cols - 4;
visible_controls = (screen_cols - 3) / (control_width + 1);
if (visible_controls > controls_count)
if (visible_controls > (int)controls_count)
visible_controls = controls_count;
first_control_x = 2 + (screen_cols - 3 - visible_controls * (control_width + 1)) / 2;

View file

@ -58,7 +58,7 @@ bool controls_changed;
unsigned int mouse_wheel_step = 1;
bool mouse_wheel_focuses_control = 1;
static int elem_callback(snd_mixer_elem_t *elem, unsigned int mask)
static int elem_callback(snd_mixer_elem_t *elem ATTRIBUTE_UNUSED, unsigned int mask)
{
if (mask == SND_CTL_EVENT_MASK_REMOVE) {
controls_changed = TRUE;
@ -73,7 +73,7 @@ static int elem_callback(snd_mixer_elem_t *elem, unsigned int mask)
return 0;
}
static int mixer_callback(snd_mixer_t *mixer, unsigned int mask, snd_mixer_elem_t *elem)
static int mixer_callback(snd_mixer_t *mixer ATTRIBUTE_UNUSED, unsigned int mask, snd_mixer_elem_t *elem)
{
if (mask & SND_CTL_EVENT_MASK_ADD) {
snd_mixer_elem_set_callback(elem, elem_callback);
@ -228,7 +228,8 @@ static void show_help(void)
void refocus_control(void)
{
if (focus_control_index < controls_count) {
if (focus_control_index >= 0 &&
focus_control_index < (int)controls_count) {
snd_mixer_selem_get_id(controls[focus_control_index].elem, current_selem_id);
current_control_flags = controls[focus_control_index].flags;
}
@ -239,7 +240,7 @@ void refocus_control(void)
static struct control *get_focus_control(unsigned int type)
{
if (focus_control_index >= 0 &&
focus_control_index < controls_count &&
focus_control_index < (int)controls_count &&
(controls[focus_control_index].flags & IS_ACTIVE) &&
(controls[focus_control_index].flags & type))
return &controls[focus_control_index];
@ -294,7 +295,7 @@ static void change_enum_relative(struct control *control, int delta)
new_index = 0;
else if (new_index >= items)
new_index = items - 1;
if (new_index == index)
if (new_index == (int)index)
return;
for (i = 0; i <= SND_MIXER_SCHN_LAST; ++i)
if (control->enum_channel_bits & (1 << i))
@ -330,7 +331,7 @@ static void change_volume_relative(struct control *control, int delta, unsigned
{
double (*get_func)(snd_mixer_elem_t *, snd_mixer_selem_channel_id_t);
int (*set_func)(snd_mixer_elem_t *, snd_mixer_selem_channel_id_t, double, int);
double left, right;
double left = 0, right = 0;
int dir;
if (!(control->flags & HAS_VOLUME_1))
@ -501,6 +502,7 @@ static int on_mouse_key() {
case CMD_MIXER_MOUSE_CLICK_VOLUME_BAR:
if (mouse_wheel_focuses_control)
focus_control_index = rect->arg1;
/* fall through */
default:
return CMD_WITH_ARG((
@ -554,7 +556,7 @@ static void on_handle_key(int key)
if (key == KEY_MOUSE)
cmd = on_mouse_key();
else if (key < ARRAY_SIZE(mixer_bindings))
else if (key < (int)ARRAY_SIZE(mixer_bindings))
cmd = mixer_bindings[key];
else
return;
@ -567,6 +569,7 @@ static void on_handle_key(int key)
case CMD_MIXER_CONTROL_DOWN_RIGHT:
case CMD_MIXER_CONTROL_DOWN:
arg = (-arg);
/* fall through */
case CMD_MIXER_CONTROL_UP_LEFT:
case CMD_MIXER_CONTROL_UP_RIGHT:
case CMD_MIXER_CONTROL_UP:
@ -588,6 +591,7 @@ static void on_handle_key(int key)
break;
case CMD_MIXER_TOGGLE_VIEW_MODE:
arg = (view_mode + 1) % VIEW_MODE_COUNT;
/* fall through */
case CMD_MIXER_SET_VIEW_MODE:
set_view_mode((enum view_mode)(arg));
break;
@ -600,13 +604,15 @@ static void on_handle_key(int key)
break;
case CMD_MIXER_PREVIOUS:
arg = (-arg);
/* fall through */
case CMD_MIXER_NEXT:
arg = focus_control_index + arg;
/* fall through */
case CMD_MIXER_FOCUS_CONTROL:
focus_control_index = arg;
if (focus_control_index < 0)
focus_control_index = 0;
else if (focus_control_index >= controls_count)
else if (focus_control_index >= (int)controls_count)
focus_control_index = controls_count - 1;
refocus_control();
break;
@ -628,7 +634,7 @@ static void create(void)
widget_init(&mixer_widget, screen_lines, screen_cols, 0, 0,
attrs.mixer_frame, WIDGET_BORDER);
if (screen_cols >= (sizeof(title) - 1) + 2) {
if (screen_cols >= (int)(sizeof(title) - 1) + 2) {
wattrset(mixer_widget.window, attrs.mixer_active);
mvwaddstr(mixer_widget.window, 0, (screen_cols - (sizeof(title) - 1)) / 2, title);
}

View file

@ -216,7 +216,7 @@ static void move_y(int delta)
static void on_handle_key(int key)
{
if (key >= ARRAY_SIZE(textbox_bindings))
if (key >= (int)ARRAY_SIZE(textbox_bindings))
return;
switch (textbox_bindings[key]) {