]> Pileus Git - ~andy/linux/commitdiff
[media] videobuf2-core: Replace BUG_ON and return an error at vb2_queue_init()
authorEzequiel Garcia <elezegarcia@gmail.com>
Mon, 17 Sep 2012 17:59:30 +0000 (14:59 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 27 Sep 2012 09:09:10 +0000 (06:09 -0300)
This replaces BUG_ON() calls with WARN_ON(), and returns
EINVAL if some parameter is NULL, as suggested by Jonathan and Mauro.
The BUG_ON() call is too drastic to be used in this case.
See the full discussion here:
http://www.spinics.net/lists/linux-media/msg52462.html

Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/v4l2-core/videobuf2-core.c
include/media/videobuf2-core.h

index 59ed5223393bdccfcfda7a98f6495522d33bbe1a..e6a26b433e87ffe74728a5e3b93ca353d6e1d83d 100644 (file)
@@ -1738,14 +1738,17 @@ EXPORT_SYMBOL_GPL(vb2_poll);
  */
 int vb2_queue_init(struct vb2_queue *q)
 {
-       BUG_ON(!q);
-       BUG_ON(!q->ops);
-       BUG_ON(!q->mem_ops);
-       BUG_ON(!q->type);
-       BUG_ON(!q->io_modes);
-
-       BUG_ON(!q->ops->queue_setup);
-       BUG_ON(!q->ops->buf_queue);
+       /*
+        * Sanity check
+        */
+       if (WARN_ON(!q)                   ||
+           WARN_ON(!q->ops)              ||
+           WARN_ON(!q->mem_ops)          ||
+           WARN_ON(!q->type)             ||
+           WARN_ON(!q->io_modes)         ||
+           WARN_ON(!q->ops->queue_setup) ||
+           WARN_ON(!q->ops->buf_queue))
+               return -EINVAL;
 
        INIT_LIST_HEAD(&q->queued_list);
        INIT_LIST_HEAD(&q->done_list);
index 8dd9b6cc296b57c2ee2b37612f796d6cb975aca1..e04252a9fea65e5f5db25a901368e82a3aa8b4d6 100644 (file)
@@ -324,7 +324,7 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
 int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);
 int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b);
 
-int vb2_queue_init(struct vb2_queue *q);
+int __must_check vb2_queue_init(struct vb2_queue *q);
 
 void vb2_queue_release(struct vb2_queue *q);