diff mbox

[9/9] ivtv-mailbox: avoid confusing smatch

Message ID 6a4d1872a94ba8450c9aff6599d1e86b515fd2a9.1456167652.git.mchehab@osg.samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab Feb. 22, 2016, 7:09 p.m. UTC
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 <mchehab@osg.samsung.com>
---
 drivers/media/pci/ivtv/ivtv-mailbox.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Andy Walls Feb. 22, 2016, 8:22 p.m. UTC | #1
On February 22, 2016 2:09:23 PM EST, Mauro Carvalho Chehab <mchehab@osg.samsung.com> wrote:
>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 <mchehab@osg.samsung.com>
>---
> drivers/media/pci/ivtv/ivtv-mailbox.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>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);
> 		}

Hi:

then is an unsigned long.
msecs_to_jiffies() returns an unsigned long.

timeout should be an unsigned long.

Regards,
Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);
 		}