Powered by Linux
Re: smatch vs. WARN_ON[_ONCE] — Semantic Matching Tool

Re: smatch vs. WARN_ON[_ONCE]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 09, 2012 at 10:40:13AM +0200, Johannes Berg wrote:
> Dan,
> 
> It seems like smatch doesn't have issues with this:
> 
> static void *array[MAX];
> 
> ...
> 
> for (i = 0; i < MAX; i++)
> 	if (!array[i])
> 		break;
> 
> if (i == MAX)
> 	return -EINVAL;
> array[i] = ...;
> 
> but if we modify this to
> 
> if (WARN_ON_ONCE(i == MAX))
> 	return -EINVAL;
> 
> or WARN_ON() then it warns about an out-of-bounds array access.
> 
> johannes

The bug is caused because Smatch is supposed to ignore:
	WARN_ON(i == MAX);
but pay attention to:
	if (WARN_ON(i == MAX)) { ...

But the code to do that was buggy.  I've fixed it now.

I'll try take a look at the other bug as well.  (If nothing else
I'll just comment out the message).

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe smatch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux