Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966654AbWKTUhQ (ORCPT ); Mon, 20 Nov 2006 15:37:16 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S966656AbWKTUhQ (ORCPT ); Mon, 20 Nov 2006 15:37:16 -0500 Received: from pentafluge.infradead.org ([213.146.154.40]:1187 "EHLO pentafluge.infradead.org") by vger.kernel.org with ESMTP id S966654AbWKTUhO (ORCPT ); Mon, 20 Nov 2006 15:37:14 -0500 Date: Mon, 20 Nov 2006 20:37:08 +0000 (GMT) From: James Simmons To: Andrew Morton cc: linux-fbdev-devel@lists.sourceforge.net, Tero Roponen , linux-kernel@vger.kernel.org Subject: Re: [Linux-fbdev-devel] fb: modedb uses wrong default_mode In-Reply-To: <20061120120521.68724342.akpm@osdl.org> Message-ID: References: <20061115152952.0e92c50d.akpm@osdl.org> <20061115234456.GB3674@cosmic.amd.com> <20061117124013.b6e4183d.akpm@osdl.org> <20061120120521.68724342.akpm@osdl.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1471 Lines: 42 > > I really don't trust dbsize. The driver writer can pass in the wrong > > number. > > That would be a bug. Excuse my paranoia about what driver writers will do :-/ > > 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. Good point about the pointer being valid. In that case we have to deal with dbsize. Still nervous about going out of bounds of the array. - 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/