Messages in this thread | | | Date | Sat, 19 Apr 2014 09:07:26 -0400 | From | Tejun Heo <> | Subject | Re: [PATCH 5/9 V2] idr: covert BUG_ON() to WARN_ON_ONCE() if the argument is invalid. |
| |
On Sat, Apr 19, 2014 at 07:38:12PM +0800, Lai Jiangshan wrote: > @@ -559,7 +559,7 @@ void idr_remove(struct idr *idp, int id) > struct idr_layer *p; > struct idr_layer *to_free; > > - if (id < 0) > + if (WARN_ON_ONCE(id < 0)) > return;
ISTR callers which call in with error value, but yeah weeding them out could be a good idea. Shouldn't it be idr_remove_warning() though?
> @@ -1030,6 +1030,9 @@ void ida_remove(struct ida *ida, int id) > int n; > struct ida_bitmap *bitmap; > > + if (WARN_ON_ONCE(id < 0)) > + return;
Why not jump to err?
> + > if (idr_id > idr_max(ida->idr.layers)) > goto err; > > @@ -1096,13 +1099,14 @@ int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, > unsigned int max; > unsigned long flags; > > - BUG_ON((int)start < 0); > - BUG_ON((int)end < 0); > + if (WARN_ON_ONCE(((int)start < 0) || ((int)end < 0))) > + return -EINVAL; > > if (end == 0) > max = 0x80000000; > else { > - BUG_ON(end < start); > + if (WARN_ON_ONCE(end < start)) > + return -ENOSPC;
-EINVAL
Thanks.
-- tejun
| |