From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751780AbcBVSf6 (ORCPT ); Mon, 22 Feb 2016 13:35:58 -0500 Received: from lists.s-osg.org ([54.187.51.154]:37587 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbcBVSf5 (ORCPT ); Mon, 22 Feb 2016 13:35:57 -0500 Date: Mon, 22 Feb 2016 15:35:52 -0300 From: Mauro Carvalho Chehab To: Dan Carpenter Cc: LKML Subject: Troubles with smatch and jiffies Message-ID: <20160222153552.6f318bcb@recife.lan> Organization: Samsung X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- Thanks, Mauro commit 6a4d1872a94ba8450c9aff6599d1e86b515fd2a9 Author: Mauro Carvalho Chehab 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 diff --git a/drivers/media/pci/ivtv/ivtv-mailbox.c b/drivers/media/pci/ivtv/ivtv-mailbox.c index e3ce96763785..4d6a3ad265a5 100644 --- a/drivers/media/pci/ivtv/ivtv-mailbox.c +++ b/drivers/media/pci/ivtv/ivtv-mailbox.c @@ -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); }