On Wednesday 10 September 2003 18:54, Greg KH wrote:
> On Wed, Sep 10, 2003 at 12:52:45PM +0200, Duncan Sands wrote:
> >  speedtch.c |    7 +------
> >  1 files changed, 1 insertion(+), 6 deletions(-)
> >
> >
> > diff -Nru a/drivers/usb/misc/speedtch.c b/drivers/usb/misc/speedtch.c
> > --- a/drivers/usb/misc/speedtch.c   Wed Sep 10 13:25:09 2003
> > +++ b/drivers/usb/misc/speedtch.c   Wed Sep 10 13:25:09 2003
> > @@ -1293,14 +1293,9 @@
> >
> >  static int __init udsl_usb_init (void)
> >  {
> > -   struct sk_buff *skb; /* dummy for sizeof */
> > -
> >     dbg ("udsl_usb_init: driver version " DRIVER_VERSION);
> >
> > -   if (sizeof (struct udsl_control) > sizeof (skb->cb)) {
> > -           printk (KERN_ERR __FILE__ ": unusable with this kernel!\n");
> > -           return -EIO;
> > -   }
> > +   BUG_ON (sizeof (struct udsl_control) > sizeof (((struct sk_buff
> > *)0)->cb));
>
> No, I will not take a patch that adds any new BUG* calls to the usb
> code.  I know you already have some in this driver, and that really is
> unacceptable.  Device drivers should not shut down a system if they can
> help it at all.  The original code that returns an error code is
> correct.
>
> I will gladly take patches to remove the other calls to BUG_ON() in this
> driver (hint...)

Something like this?

--------------------------

Biscuit for Greg.


 speedtch.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)


diff -Nru a/drivers/usb/misc/speedtch.c b/drivers/usb/misc/speedtch.c
--- a/drivers/usb/misc/speedtch.c       Fri Sep 12 17:43:32 2003
+++ b/drivers/usb/misc/speedtch.c       Fri Sep 12 17:43:32 2003
@@ -84,6 +84,11 @@
 
 #include <linux/usb.h>
 
+#ifdef DEBUG
+#define DEBUG_ON(x)    BUG_ON(x)
+#else
+#define DEBUG_ON(x)    do { if (x); } while (0)
+#endif
 
 #ifdef VERBOSE_DEBUG
 static int udsl_print_packet (const unsigned char *data, int len);
@@ -351,7 +356,7 @@
                        dbg ("udsl_extract_cells: buffer overrun (max_pdu: %u, 
skb->len %u, vcc: 0x%p)", vcc_data->max_pdu, skb->len, vcc);
                        /* discard cells already received */
                        skb_trim (skb, 0);
-                       BUG_ON (vcc_data->max_pdu < ATM_CELL_PAYLOAD);
+                       DEBUG_ON (vcc_data->max_pdu < ATM_CELL_PAYLOAD);
                }
 
                memcpy (skb->tail, source + ATM_CELL_HEADER, ATM_CELL_PAYLOAD);
@@ -498,7 +503,7 @@
                memset (target, 0, ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER);
                target += ATM_CELL_PAYLOAD - ATM_AAL5_TRAILER;
 
-               BUG_ON (--ctrl->num_cells);
+               DEBUG_ON (--ctrl->num_cells);
        }
 
        memcpy (target, ctrl->aal5_trailer, ATM_AAL5_TRAILER);
@@ -535,7 +540,7 @@
 
        vdbg ("udsl_complete_receive: urb 0x%p, status %d, actual_length %d, 
filled_cells %u, rcv 0x%p, buf 0x%p", urb, urb->status, urb->actual_length, 
buf->filled_cells, rcv, buf);
 
-       BUG_ON (buf->filled_cells > rcv_buf_size);
+       DEBUG_ON (buf->filled_cells > rcv_buf_size);
 
        /* may not be in_interrupt() */
        spin_lock_irqsave (&instance->receive_lock, flags);
@@ -1216,8 +1221,7 @@
                count = 0;
                spin_lock_irq (&instance->receive_lock);
                list_for_each (pos, &instance->spare_receivers)
-                       if (++count > num_rcv_urbs)
-                               panic (__FILE__ ": memory corruption detected at line 
%d!\n", __LINE__);
+                       DEBUG_ON (++count > num_rcv_urbs);
                spin_unlock_irq (&instance->receive_lock);
 
                dbg ("udsl_usb_disconnect: found %u spare receivers", count);
@@ -1253,8 +1257,7 @@
                count = 0;
                spin_lock_irq (&instance->send_lock);
                list_for_each (pos, &instance->spare_senders)
-                       if (++count > num_snd_urbs)
-                               panic (__FILE__ ": memory corruption detected at line 
%d!\n", __LINE__);
+                       DEBUG_ON (++count > num_snd_urbs);
                spin_unlock_irq (&instance->send_lock);
 
                dbg ("udsl_usb_disconnect: found %u spare senders", count);


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to