Troubles with smatch and jiffies
Subsystems (2)
Hi Dan,
I'm having some things that look like false positives when testing the media drivers against smatch. This is bothering me for some time, but, as this was harder to debug (as I needed to do a build with -j1), I postponed trying to fix it for a while.
Basically, smatch is complaining for things like:
time_before(jiffies, jiffies + msecs_to_jiffies(var));
I noticed the very same behavior on two places:
drivers/media/pci/ivtv/ivtv-mailbox.c
drivers/media/rc/ati_remote.c
The enclosed patch makes smatch to shut up for ivtv build, but, IMHO, we should make it stop making it complain about it globalwide, as the same warning may also be appearing on other places.
FYI, I'm using here gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2) and the very latest version of smatch from git://repo.or.cz/smatch.git.
Regards,
Mauro
Signature · 17 lines
Thanks, Mauro commit 6a4d1872a94ba8450c9aff6599d1e86b515fd2a9 Author: Mauro Carvalho Chehab <[email protected]> Date: Mon Feb 22 14:55:14 2016 -0300 ivtv-mailbox: avoid confusing smatch The current logic causes smatch to be confused: include/linux/jiffies.h:359:41: error: strange non-value function or array include/linux/jiffies.h:361:42: error: strange non-value function or array include/linux/jiffies.h:359:41: error: strange non-value function or array include/linux/jiffies.h:361:42: error: strange non-value function or array Use a different logic. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
drivers/media/pci/ivtv/ivtv-mailbox.c +4 -2
@@ -177,8 +177,10 @@ static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int f/* Sleep before a retry, if not atomic */ if (!(flags &API_NO_WAIT_MB )) { -if (time_after (jiffies, - then +msecs_to_jiffies (10 *retries))) +unsigned int timeout; + + timeout =msecs_to_jiffies (10 * retries); +if (time_after (jiffies, then + timeout))break ;ivtv_msleep_timeout (10 ,0 ); }
Please, don't apply that work around for Smatch bugs... :(
I have a sort of patch for this, but it might not be as complete as it should be. I am testing it out now.
regards,
dan carpenter
I pushed a fix for this. Thanks.
http://repo.or.cz/smatch.git/commitdiff/e6f67e92f3a81e5f7a06e60b17477c77ec5ec287
regards,
dan carpenter