Received: by 10.223.176.5 with SMTP id f5csp893274wra; Tue, 6 Feb 2018 09:04:53 -0800 (PST) X-Google-Smtp-Source: AH8x227P84jq6Fk6Tc7IOBhYnt9XuvMQ+JafbMb7eKELszRaGa3K/n3XvrF2kFkC63LiXHhFnlm3 X-Received: by 2002:a17:902:208:: with SMTP id 8-v6mr3054585plc.359.1517936693519; Tue, 06 Feb 2018 09:04:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517936693; cv=none; d=google.com; s=arc-20160816; b=cnzzTgiZOvjOYgoXRIUieRYrpb+0DeMFyFl0LNuo7OhGCKU4p6ssYjBtLMHry07Kbk MwgLLa1rkRR+Km9MRINB2yjq+NYf771qxM0dQp5Ywa/ddDwPnRUVNidR5wvdkqNO679+ ActWPqqC5dPD1WMt7vw4uNgSgwp7ZGkGqdcAt+RY68xgS6A2LX3eUCGezxqxMlAEHihV qFV97iJ2Upn6R4Wtr4b0ANWgxaN9aS5h7OCaQBTgaVqpq/w3xzLTI8jqd/eU3d/uljHx uLewSgGf4hnbmPMrbjJ8o078JwFIQAviNcAT+Ug7KKZ031s/TbgTfxJHC7vnbX86a5FD ENxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :user-agent:in-reply-to:references:subject:cc:to:from:message-id :date:arc-authentication-results; bh=f+RootAwYcpWK5aapvIKu0bLRJVC3JOyCGK1+/s8944=; b=lWJxs0oFvPiCbKyk2MwNq6QwyjVU+w4k6L2tMDOcoyQTsv78T/ETuSn8f/ej4C3mQ4 fYUv588ZTjRdHwE5Tq7lGbhuWtk+4ETQZ/4L1+1r7MR7yTu5ZIJCUMV5NT2Bg4Eqv2ZE eDclfKnXkp60k7Qet2SNWs0b7zp13TD5/QJp+DkfeIhdcWe+jLZqrVd9wRM/MBClzQzt 7D6KQOFFRp7VzAnc7kXE6idgW7zOQS72xj37cWMnimnE7UlCmp7vHAJ0Cc0IiKPdE2KO u42c2GluffeSWEVD16VEohwjFER5p/+FWy5Vchn24o9BvpMnw3n1fh14VCE1kfKEbV1p E+lQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o61-v6si1496138pld.259.2018.02.06.09.04.19; Tue, 06 Feb 2018 09:04:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752840AbeBFRBv (ORCPT + 99 others); Tue, 6 Feb 2018 12:01:51 -0500 Received: from gateway36.websitewelcome.com ([192.185.188.18]:25244 "EHLO gateway36.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752650AbeBFRAG (ORCPT ); Tue, 6 Feb 2018 12:00:06 -0500 X-Greylist: delayed 1461 seconds by postgrey-1.27 at vger.kernel.org; Tue, 06 Feb 2018 12:00:06 EST Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway36.websitewelcome.com (Postfix) with ESMTP id E9AA540169388 for ; Tue, 6 Feb 2018 10:35:42 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id j6DeelnszmzEzj6Deeoael; Tue, 06 Feb 2018 10:35:42 -0600 Received: from gator4166.hostgator.com ([108.167.133.22]:29319) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1ej6De-000XJ4-KG; Tue, 06 Feb 2018 10:35:42 -0600 Received: from 189.175.4.238 ([189.175.4.238]) by gator4166.hostgator.com (Horde Framework) with HTTPS; Tue, 06 Feb 2018 10:35:42 -0600 Date: Tue, 06 Feb 2018 10:35:42 -0600 Message-ID: <20180206103542.Horde.31PkL6hVZU4E1wZePDF8kId@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Hans Verkuil Cc: "Gustavo A. R. Silva" , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 8/8] platform: vivid-cec: use 64-bit arithmetic instead of 32-bit References: <20180205155419.Horde.WgpJoLkqF8wsBtPMp9n7V8U@gator4166.hostgator.com> <238647bc-106d-8dbf-569e-82e7968f887d@xs4all.nl> In-Reply-To: <238647bc-106d-8dbf-569e-82e7968f887d@xs4all.nl> User-Agent: Horde Application Framework 5 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 108.167.133.22 X-Source-L: Yes X-Exim-ID: 1ej6De-000XJ4-KG X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:29319 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 1 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Hans Verkuil : > On 02/05/18 22:54, Gustavo A. R. Silva wrote: >> Hi Hans, >> >> Quoting Hans Verkuil : >> >>> On 02/05/2018 09:36 PM, Gustavo A. R. Silva wrote: >>>> Add suffix ULL to constant 10 in order to give the compiler complete >>>> information about the proper arithmetic to use. Notice that this >>>> constant is used in a context that expects an expression of type >>>> u64 (64 bits, unsigned). >>>> >>>> The expression len * 10 * CEC_TIM_DATA_BIT_TOTAL is currently being >>>> evaluated using 32-bit arithmetic. >>>> >>>> Also, remove unnecessary parentheses and add a code comment to make it >>>> clear what is the reason of the code change. >>>> >>>> Addresses-Coverity-ID: 1454996 >>>> Signed-off-by: Gustavo A. R. Silva >>>> --- >>>> Changes in v2: >>>> - Update subject and changelog to better reflect the proposed >>>> code changes. >>>> - Add suffix ULL to constant instead of casting a variable. >>>> - Remove unncessary parentheses. >>> >>> unncessary -> unnecessary >>> >> >> Thanks for this. >> >>>> - Add code comment. >>>> >>>> drivers/media/platform/vivid/vivid-cec.c | 11 +++++++++-- >>>> 1 file changed, 9 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/media/platform/vivid/vivid-cec.c >>>> b/drivers/media/platform/vivid/vivid-cec.c >>>> index b55d278..614787b 100644 >>>> --- a/drivers/media/platform/vivid/vivid-cec.c >>>> +++ b/drivers/media/platform/vivid/vivid-cec.c >>>> @@ -82,8 +82,15 @@ static void vivid_cec_pin_adap_events(struct >>>> cec_adapter *adap, ktime_t ts, >>>> >>>> if (adap == NULL) >>>> return; >>>> - ts = ktime_sub_us(ts, (CEC_TIM_START_BIT_TOTAL + >>>> - len * 10 * CEC_TIM_DATA_BIT_TOTAL)); >>>> + >>>> + /* >>>> + * Suffix ULL on constant 10 makes the expression >>>> + * CEC_TIM_START_BIT_TOTAL + 10ULL * len * CEC_TIM_DATA_BIT_TOTAL >>>> + * be evaluated using 64-bit unsigned arithmetic (u64), which >>>> + * is what ktime_sub_us expects as second argument. >>>> + */ >>> >>> That's not really the comment that I was looking for. It still doesn't >>> explain *why* this is needed at all. How about something like this: >>> >> >> In MHO the reason for the change is simply the discrepancy between the >> arithmetic expected by >> the function ktime_sub_us and the arithmetic in which the expression >> is being evaluated. And this >> has nothing to do with any particular tool. > > Hmm, you have a point. > > OK, I've looked at the other patches in this patch series as well, and > the only thing I would like to see changed is the 'Addresses-Coverity-ID' > line in the patches: patch 4 says: > > Addresses-Coverity-ID: 1324146 ("Unintentional integer overflow") > > but that's the only one that mentions the specific coverity error. > It would be nice if that can be added to the other patches as well so > we have a record of the actual coverity error. > OK. I'll send v3 of the whole patch series shortly. Thank you! >> >>> /* >>> * Add the ULL suffix to the constant 10 to work around a false Coverity >>> * "Unintentional integer overflow" warning. Coverity isn't smart enough >>> * to understand that len is always <= 16, so there is no chance of an >>> * integer overflow. >>> */ >>> >> >> :P >> >> In my opinion it is not a good idea to tie the code to a particular tool. >> There are only three appearances of the word 'Coverity' in the whole >> code base, and, honestly I don't want to add more. >> >> So I think I will document this issue as a FP in the Coverity platform. > > FP? > False Positive. > Regards, > > Hans -- Gustavo