ida_alloc_range() check question

Harshit Mogalapalli <[email protected]> Sun, 11 Jan 2026 02:36:04 +0530
Newsgroups org.kernel.vger.smatch
Message-ID <[email protected]>
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 ?

diff --git a/check_ida_alloc.c b/check_ida_alloc.c
index e29b8ff1b28c..e6374dd31683 100644
--- a/check_ida_alloc.c
+++ b/check_ida_alloc.c
@@ -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