linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: map: BUG() in non handled cases
@ 2013-01-31 17:06 Dmitry Eremin-Solenikov
  2013-02-04 10:32 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Eremin-Solenikov @ 2013-01-31 17:06 UTC (permalink / raw)
  To: linux-mtd; +Cc: linux-kernel, Artem Bityutskiy, David Woodhouse

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>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
---
 include/linux/mtd/map.h |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
index f6eb433..1d6ef97 100644
--- a/include/linux/mtd/map.h
+++ b/include/linux/mtd/map.h
@@ -328,7 +328,7 @@ static inline int map_word_bitsset(struct map_info *map, map_word val1, map_word
 
 static inline map_word map_word_load(struct map_info *map, const void *ptr)
 {
-	map_word r = {{0} };
+	map_word r;
 
 	if (map_bankwidth_is_1(map))
 		r.x[0] = *(unsigned char *)ptr;
@@ -342,6 +342,8 @@ static inline map_word map_word_load(struct map_info *map, const void *ptr)
 #endif
 	else if (map_bankwidth_is_large(map))
 		memcpy(r.x, ptr, map->bankwidth);
+	else
+		BUG();
 
 	return r;
 }
@@ -391,7 +393,7 @@ static inline map_word map_word_ff(struct map_info *map)
 
 static inline map_word inline_map_read(struct map_info *map, unsigned long ofs)
 {
-	map_word uninitialized_var(r);
+	map_word r;
 
 	if (map_bankwidth_is_1(map))
 		r.x[0] = __raw_readb(map->virt + ofs);
@@ -425,6 +427,8 @@ static inline void inline_map_write(struct map_info *map, const map_word datum,
 #endif
 	else if (map_bankwidth_is_large(map))
 		memcpy_toio(map->virt+ofs, datum.x, map->bankwidth);
+	else
+		BUG();
 	mb();
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: map: BUG() in non handled cases
  2013-01-31 17:06 [PATCH] mtd: map: BUG() in non handled cases Dmitry Eremin-Solenikov
@ 2013-02-04 10:32 ` Artem Bityutskiy
  0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2013-02-04 10:32 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd, linux-kernel, David Woodhouse

[-- Attachment #1: Type: text/plain, Size: 573 bytes --]

On Thu, 2013-01-31 at 21:06 +0400, Dmitry Eremin-Solenikov wrote:
> 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>

Pushed to l2-mtd.git, thanks!

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-04 10:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-31 17:06 [PATCH] mtd: map: BUG() in non handled cases Dmitry Eremin-Solenikov
2013-02-04 10:32 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).