Skip to content

[BUG] signed/unsigned confusions in MTK driver #4816

Closed

Description

@plbossart

cppcheck reports warnings in MTK code

src/drivers/mediatek/mt8195/afe-drv.c:304:9: style: Checking if unsigned expression 'fs' is less than zero. [unsignedLessThanZero]
 if (fs < 0)
        ^

Looking at the code, there are multiple places with signed/unsigned confusions

static unsigned int mt8195_afe_fs_timing(unsigned int rate)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(mt8195_afe_rates); i++)
		if (mt8195_afe_rates[i].rate == rate)
			return mt8195_afe_rates[i].reg_value;

	return -EINVAL; <<< that's not right for unsigned int!
}

int afe_irq_config(struct mtk_base_afe *afe, int id, unsigned int rate, unsigned int period)
{
	struct mtk_base_afe_irq *irq = &afe->irqs[id];
	unsigned int fs;

	afe_reg_update_bits(afe, irq->irq_data->irq_cnt_reg,
			    irq->irq_data->irq_cnt_maskbit << irq->irq_data->irq_cnt_shift,
			    period << irq->irq_data->irq_cnt_shift);

	/* set irq fs */
	fs = afe->irq_fs(rate);

	if (fs < 0) <<< never true
		return -EINVAL;	/* set irq fs */

Filing as a bug so that MTK folks can look at it.

Activity

  1. added
    bugSomething isn't working as expected
    on Sep 28, 2021
  2. lgirdwood commented on Oct 13, 2021

    @lgirdwood
    Member

    @yaochunhung I think this is fixed now ? Can we close ?

  3. yaochunhung commented on Mar 14, 2022

    @yaochunhung
    Contributor

    @lgirdwood Sorry to miss your comment. I will fix this bug. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working as expected

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions