Skip to contentSkip to conversation

nouveua: sizeof() vs ARRAY_SIZE()

PATCH In review Dan Carpenter 2 participants 2 messages Dec 20, 2010 – Dec 21, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nouveua: sizeof() vs ARRAY_SIZE()

ARRAY_SIZE() was intended here, sizeof() is too large.

drivers/gpu/drm/nouveau/nv50_vram.c +1 -1
index 47489ed..58e98ad 100644
@@ -42,7 +42,7 @@ nv50_vram_flags_valid(struct drm_device *dev, u32 tile_flags)
 {
 	int type = (tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) >> 8;
 
-	if (likely(type < sizeof(types) && types[type]))
+	if (likely(type < ARRAY_SIZE(types) && types[type]))
 		return true;
 	return false;
 }
#1 lore raw
Quoted 1 line · Dan Carpenter

ARRAY_SIZE() was intended here, sizeof() is too large.

Thanks, I've queued this patch.

Ben.

Quoted 16 lines
drivers/gpu/drm/nouveau/nv50_vram.c +1 -1
index 47489ed..58e98ad 100644
@@ -42,7 +42,7 @@ nv50_vram_flags_valid(struct drm_device *dev, u32 tile_flags)
 {
 	int type = (tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) >> 8;
 
-	if (likely(type < sizeof(types) && types[type]))
+	if (likely(type < ARRAY_SIZE(types) && types[type]))
 		return true;
 	return false;
 }