Skip to contentSkip to conversation

ida_alloc_range() check question

PATCH Harshit Mogalapalli 2 participants 2 messages Jan 10 – Jan 22

lore
Share & tools
lore
#0 lore raw

Hi,

I have seen this warning on linux-next:
drivers/pci/ide.c:42 reserve_stream_index() error: Calling ida_alloc_range() with a 'max' argument which is a power of 2. -1 missing?

I was wondering if it would be reasonable to skip when min is not zero ?

check_ida_alloc.c +0 -0
index e29b8ff1b28c..e6374dd31683 100644
@@ -74,21 +74,21 @@ static void match_ida_alloc_max(const char *fn, struct expression *expr, void *_
 static void match_ida_alloc_range(const char *fn, struct expression 

*expr, void *info)

 {
        struct expression *arg_expr1, *arg_expr2;

        sval_t sval;

        arg_expr1 = get_argument_from_call_expr(expr->args, 1);
        arg_expr1 = strip_expr(arg_expr1);
        arg_expr2 = get_argument_from_call_expr(expr->args, 2);
        arg_expr2 = strip_expr(arg_expr2);

        if (!get_implied_value(arg_expr1, &sval))
                return;

- if (sval.uvalue == 1)
+ if (sval.uvalue != 0)

                return;

        if (is_power_of_two(arg_expr2))
                sm_error("Calling %s() with a 'max' argument which is a 
power of 2. -1 missing?",
                          fn);

}

This wouldn't still help silencing warning in this case, but maybe help reduce FPs ? Thoughts ?

Thanks,
Harshit

#1 lore raw

Harshit sent me private email to ignore so I did. But he meant to ignore a different copy of this email...

Quoted 9 lines · Harshit Mogalapalli

Hi,

I have seen this warning on linux-next:
drivers/pci/ide.c:42 reserve_stream_index() error: Calling ida_alloc_range() with a 'max' argument which is a power of 2. -1 missing?

I was wondering if it would be reasonable to skip when min is not zero ?

I don't get a warning in drivers/pci/ide.c. I don't see how it triggers a warning for you. I'm on linux next.

I reviewed the other 5 warnings and they all seem like real bugs. I should update the inline warnings to be a better format, but I can't promise when that will happen.

regards,
dan carpenter