Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752276AbdLKClK (ORCPT ); Sun, 10 Dec 2017 21:41:10 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40375 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751637AbdLKClG (ORCPT ); Sun, 10 Dec 2017 21:41:06 -0500 X-Google-Smtp-Source: AGs4zMZPKK4i8OB49BfrK8I/wZk/7BVbAsLlhdOxvgnX3u8SKmIwl+OBVYupnJDgC+zxz9h8F86L6AYSG/WJLVQwxpo= MIME-Version: 1.0 X-Originating-IP: [60.248.88.209] In-Reply-To: <20171209003414.17332-1-colin.king@canonical.com> References: <20171209003414.17332-1-colin.king@canonical.com> From: =?UTF-8?B?6buD5riF6ZqG?= Date: Mon, 11 Dec 2017 10:41:03 +0800 Message-ID: Subject: Re: [PATCH][next] scsi: arcmsr: remove redundant check for secs < 0 To: Colin King Cc: "James E . J . Bottomley" , "Martin K . Petersen" , "linux-scsi@vger.kernel.org" , kernel-janitors@vger.kernel.org, "linux-kernel@vger.kernel.org" , Dan Carpenter Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1478 Lines: 43 Colin, You are right. That's checking is redundant. secs is never be negative. Thanks for your correction and patch. Regards, Ching 2017-12-09 8:34 GMT+08:00 Colin King : > From: Colin Ian King > > The check for secs being less than zero is redundant for two reasons. > Firstly, secs is unsigned so the check is always going to be false. > Secondly, if secs was signed the proceeding calculation of secs is > never going to be negative. Hence we can remove this redundant check > and day and secs re-adjustment. > > Detected by static analysis with smatch: > arcmsr_set_iop_datetime() warn: unsigned 'secs' is never less than zero. > > Signed-off-by: Colin Ian King > --- > drivers/scsi/arcmsr/arcmsr_hba.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c > index 0707a60bf5c0..e4258b69f4be 100644 > --- a/drivers/scsi/arcmsr/arcmsr_hba.c > +++ b/drivers/scsi/arcmsr/arcmsr_hba.c > @@ -3679,10 +3679,6 @@ static void arcmsr_set_iop_datetime(struct timer_list *t) > secs = (u32)(tv.tv_sec - (sys_tz.tz_minuteswest * 60)); > days = secs / 86400; > secs = secs - 86400 * days; > - if (secs < 0) { > - days = days - 1; > - secs = secs + 86400; > - } > j = days / 146097; > i = days - 146097 * j; > a = i + 719468; > -- > 2.14.1 >