Skip to content

Commit 24dea0c

Browse files
Dmitry Eremin-Solenikovdedekind
authored andcommitted
mtd: map: BUG() in non handled cases
Several map-related functions look like a serie of ifs, checking widths of map. Those functions do not have any handling for default case. Instead of fiddling with uninitialized_var in those functions, let's just add a (correct) BUG() to the default case on those maps. This will also allow us to catch potential errors in maps setup in future. Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
1 parent be0638d commit 24dea0c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎include/linux/mtd/map.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static inline int map_word_bitsset(struct map_info *map, map_word val1, map_word
329329

330330
static inline map_word map_word_load(struct map_info *map, const void *ptr)
331331
{
332-
map_word r = {{0} };
332+
map_word r;
333333

334334
if (map_bankwidth_is_1(map))
335335
r.x[0] = *(unsigned char *)ptr;
@@ -343,6 +343,8 @@ static inline map_word map_word_load(struct map_info *map, const void *ptr)
343343
#endif
344344
else if (map_bankwidth_is_large(map))
345345
memcpy(r.x, ptr, map->bankwidth);
346+
else
347+
BUG();
346348

347349
return r;
348350
}
@@ -392,7 +394,7 @@ static inline map_word map_word_ff(struct map_info *map)
392394

393395
static inline map_word inline_map_read(struct map_info *map, unsigned long ofs)
394396
{
395-
map_word uninitialized_var(r);
397+
map_word r;
396398

397399
if (map_bankwidth_is_1(map))
398400
r.x[0] = __raw_readb(map->virt + ofs);
@@ -426,6 +428,8 @@ static inline void inline_map_write(struct map_info *map, const map_word datum,
426428
#endif
427429
else if (map_bankwidth_is_large(map))
428430
memcpy_toio(map->virt+ofs, datum.x, map->bankwidth);
431+
else
432+
BUG();
429433
mb();
430434
}
431435

0 commit comments

Comments
 (0)