Re: fb: modedb uses wrong default_mode
flat view
From: James Simmons <hidden>
Date: 2006-11-20 20:37:16
Also in:
lkml
quoted
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 :-/
quoted
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.quoted
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. ------------------------------------------------------------------------- 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