Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757560Ab1EZNnY (ORCPT ); Thu, 26 May 2011 09:43:24 -0400 Received: from mail.tpi.com ([70.99.223.143]:1609 "EHLO mail.tpi.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756454Ab1EZNnW (ORCPT ); Thu, 26 May 2011 09:43:22 -0400 Message-ID: <4DDE58E9.1050307@canonical.com> Date: Thu, 26 May 2011 07:43:05 -0600 From: Tim Gardner Reply-To: tim.gardner@canonical.com User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: Maxin B John CC: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, airlied@redhat.com, lethal@linux-sh.org, james@albanarts.com, error27@gmail.com, randy.dunlap@oracle.com Subject: Re: [PATCH] drivers: video: Remove useless checks References: <20110519182702.GA3337@maxin> <4DDCFA6F.2020801@canonical.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1791 Lines: 56 On 05/26/2011 03:30 AM, Maxin B John wrote: > Hi, > > On Wed, May 25, 2011 at 1:47 PM, Tim Gardner wrote: >> On 05/19/2011 12:27 PM, Maxin B John wrote: >>> >>> Comparing unsigned less than zero will never be true. >>> Removing similar checks from 'fbmem.c' and 'fbcmap.c'. >> >> Looks right to me, though there are other places that suffer from the same >> issue. See fb_set_cmap() and its use of 'int start' and cmap->start. > > Thank you very much for reviewing the patch. As per your suggestion, I > have checked > the scenario is fb_set_cmap() and the use of 'int start' and 'cmap->start'. > > IMHO, that scenario doesn't fall under the comparison of unsigned int > < 0. That scenario > looks similar to the below given code to me: > /*---------------------------------*/ > #include > > int > main () > { > unsigned int u_int = -1; > int s_int = 0; > s_int = u_int; > if (s_int< 0) > printf ("s_int is less than 0\n"); > return 0; > } > /*---------------------------------*/ > > Please let me know your comments. > > Best Regards, > Maxin > IMHO mixing signed and unsigned comparisons like this is just wrong. Its unnecessarily complicated and misleading, especially for a device driver. I'm a firm believer in the KISS philosophy for driver development. Its likely that the reason the fb code got into this situation is because a type was changed from signed to unsigned whence long ago, and nobody has bothered to clean it up. rtg -- Tim Gardner tim.gardner@canonical.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/