lkml.org 
[lkml]   [2014]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCHv2] usb: f_fs: replace BUG in dead-code with less serious WARN_ON
Date
Even though the BUG() in __ffs_event_add is a dead-code, it is still
better to warn rather then crash the system if that code ever gets
executed.

Reported-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
drivers/usb/gadget/function/f_fs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

On Wed, Sep 10 2014, Felipe Balbi <balbi@ti.com> wrote:
> WARN(1, "unknown event type %d\n", type);
> Then you can drop pr_vdebug();

True, but the printk call will stay in the binary whereas pr_vdebug is not
included in non-debug builds. Furthermore, WARN() does not use pr_fmt.

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index ec50e0d..ea21565 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2321,7 +2321,8 @@ static void __ffs_event_add(struct ffs_data *ffs,
break;

default:
- BUG();
+ WARN(1, "%d: unknown event, this should not happen\n", type);
+ return;
}

{
--
2.1.0.rc2.206.gedb03e5

\
 
 \ /
  Last update: 2014-09-11 19:21    [W:0.038 / U:0.908 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site