public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Felipe Balbi <balbi@ti.com>
Cc: Felipe Balbi <balbi@ti.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCHv2] usb: f_fs: replace BUG in dead-code with less serious WARN_ON
Date: Thu, 11 Sep 2014 18:52:49 +0200	[thread overview]
Message-ID: <xa1tegvi14m6.fsf@mina86.com> (raw)
In-Reply-To: <20140910161337.GL667@saruman.home>

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

  reply	other threads:[~2014-09-11 16:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 15:50 [PATCH 1/2] usb: f_fs: refactor and document __ffs_ep0_read_events better Michal Nazarewicz
2014-09-10 15:50 ` [PATCH 2/2] usb: f_fs: replace BUG in dead-code with less serious WARN_ON Michal Nazarewicz
2014-09-10 16:13   ` Felipe Balbi
2014-09-11 16:52     ` Michal Nazarewicz [this message]
2014-09-11 16:56       ` [PATCHv2] " Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xa1tegvi14m6.fsf@mina86.com \
    --to=mina86@mina86.com \
    --cc=balbi@ti.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox