From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: fb: modedb uses wrong default_mode Date: Mon, 20 Nov 2006 12:05:21 -0800 Message-ID: <20061120120521.68724342.akpm@osdl.org> References: <20061115152952.0e92c50d.akpm@osdl.org> <20061115234456.GB3674@cosmic.amd.com> <20061117124013.b6e4183d.akpm@osdl.org> Reply-To: linux-fbdev-devel@lists.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.91] helo=mail.sourceforge.net) by sc8-sf-list1-new.sourceforge.net with esmtp (Exim 4.43) id 1GmFP8-0007Ri-9f for linux-fbdev-devel@lists.sourceforge.net; Mon, 20 Nov 2006 12:06:10 -0800 Received: from smtp.osdl.org ([65.172.181.25]) by mail.sourceforge.net with esmtps (TLSv1:DES-CBC3-SHA:168) (Exim 4.44) id 1GmFP4-0001vv-Cg for linux-fbdev-devel@lists.sourceforge.net; Mon, 20 Nov 2006 12:06:10 -0800 In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-fbdev-devel-bounces@lists.sourceforge.net Errors-To: linux-fbdev-devel-bounces@lists.sourceforge.net To: James Simmons Cc: Tero Roponen , linux-fbdev-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org On Mon, 20 Nov 2006 16:48:05 +0000 (GMT) James Simmons wrote: > > > db = modedb; > > > dbsize = ARRAY_SIZE(modedb); > > > > > > if (!default_mode) > > > default_mode = &db[DEFAULT_MODEDB_INDEX]; > > > if (!default_bpp) > > > default_bpp = 8; > > > > > > db will always be set. > > > > I think we do need dbsize, and that the code which I have now: > > I really don't trust dbsize. The driver writer can pass in the wrong > number. That would be a bug. > Whereas ARRAY_SIZE will always be correct. Lets take the position > that we use dbsize then we need to test if dbsize is greater than the > really size of the modedb. The dbsize parameter was for the days before we > had ARRAY_SIZE. > > > int fb_find_mode(struct fb_var_screeninfo *var, > > struct fb_info *info, const char *mode_option, > > const struct fb_videomode *db, unsigned int dbsize, > > const struct fb_videomode *default_mode, > > unsigned int default_bpp) > > { > > int i; > > > > /* Set up defaults */ > > if (!db) { > > db = modedb; > > dbsize = ARRAY_SIZE(modedb); > > } > > if (dbsize > ARRAY_SIZE(db)) > dbsize = ARRAY_SIZE(db); We can't do ARRAY_SIZE on a random pointer like this: the compiler needs to see the full definition of the array itself, and that is back in the caller's compilation unit. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV