Re: [REVIEW PATCH for v3.15 2/4] videobuf2-core: fix sparse errors.

2014-03-17 Thread Pawel Osciak
Hi Hans,
No issues with the patch, apart from one typo in a comment, but it may
not be worth the reupload.

On Sat, Mar 15, 2014 at 10:08 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 Sparse generated a bunch of errors like this:

 drivers/media/v4l2-core/videobuf2-core.c:2045:25: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:136:17: error: incompatible types in 
 conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:151:17: error: incompatible types in 
 conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:168:25: error: incompatible types in 
 conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:183:17: error: incompatible types in 
 conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:185:9: error: incompatible types in 
 conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:385:25: error: incompatible types in 
 conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1115:17: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1268:33: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1270:25: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1315:17: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1324:25: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1396:25: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1457:17: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1482:17: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1484:9: error: incompatible types in 
 conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1523:17: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1525:17: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1815:17: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1828:17: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1914:25: error: incompatible types 
 in conditional expression (different base types)
 drivers/media/v4l2-core/videobuf2-core.c:1944:9: error: incompatible types in 
 conditional expression (different base types)

 These are caused by the call*op defines which do something like this:

 (ops-op) ? ops-op(args) : 0

 which is OK as long as op is not a void function, because in that case one 
 part
 of the conditional expression returns void, the other an integer. Hence the 
 sparse
 errors.

 I've replaced this by introducing three variants of the call_ macros:
 call_*op for int returns, call_void_*op for void returns and call_ptr_*op for
 pointer returns.

 That's the bad news. The good news is that the fail_*op macros could be 
 removed
 since the call_*op macros now have enough information to determine if the op
 succeeded or not and can increment the op counter only on success. This at 
 least
 makes it more robust w.r.t. future changes.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Pawel Osciak pa...@osciak.com

 ---
  drivers/media/v4l2-core/videobuf2-core.c | 211 
 +++
  1 file changed, 130 insertions(+), 81 deletions(-)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index f9059bb..61149eb 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -36,58 +36,133 @@ module_param(debug, int, 0644);
  #ifdef CONFIG_VIDEO_ADV_DEBUG

  /*
 - * If advanced debugging is on, then count how often each op is called,
 - * which can either be per-buffer or per-queue.
 + * If advanced debugging is on, then count how often each op is called
 + * sucessfully, which can either be per-buffer or per-queue.

s/sucessfully/successfully/

   *
 - * If the op failed then the 'fail_' variant is called to decrease the
 - * counter. That makes it easy to check that the 'init' and 'cleanup'
 + * This makes it easy to check that the 'init' and 'cleanup'
   * (and variations thereof) stay balanced.
   */

 +#define log_memop(vb, op)

[REVIEW PATCH for v3.15 2/4] videobuf2-core: fix sparse errors.

2014-03-15 Thread Hans Verkuil
From: Hans Verkuil hans.verk...@cisco.com

Sparse generated a bunch of errors like this:

drivers/media/v4l2-core/videobuf2-core.c:2045:25: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:136:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:151:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:168:25: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:183:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:185:9: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:385:25: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1115:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1268:33: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1270:25: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1315:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1324:25: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1396:25: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1457:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1482:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1484:9: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1523:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1525:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1815:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1828:17: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1914:25: error: incompatible types in 
conditional expression (different base types)
drivers/media/v4l2-core/videobuf2-core.c:1944:9: error: incompatible types in 
conditional expression (different base types)

These are caused by the call*op defines which do something like this:

(ops-op) ? ops-op(args) : 0

which is OK as long as op is not a void function, because in that case one part
of the conditional expression returns void, the other an integer. Hence the 
sparse
errors.

I've replaced this by introducing three variants of the call_ macros:
call_*op for int returns, call_void_*op for void returns and call_ptr_*op for
pointer returns.

That's the bad news. The good news is that the fail_*op macros could be removed
since the call_*op macros now have enough information to determine if the op
succeeded or not and can increment the op counter only on success. This at least
makes it more robust w.r.t. future changes.

Signed-off-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/v4l2-core/videobuf2-core.c | 211 +++
 1 file changed, 130 insertions(+), 81 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index f9059bb..61149eb 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -36,58 +36,133 @@ module_param(debug, int, 0644);
 #ifdef CONFIG_VIDEO_ADV_DEBUG
 
 /*
- * If advanced debugging is on, then count how often each op is called,
- * which can either be per-buffer or per-queue.
+ * If advanced debugging is on, then count how often each op is called
+ * sucessfully, which can either be per-buffer or per-queue.
  *
- * If the op failed then the 'fail_' variant is called to decrease the
- * counter. That makes it easy to check that the 'init' and 'cleanup'
+ * This makes it easy to check that the 'init' and 'cleanup'
  * (and variations thereof) stay balanced.
  */
 
+#define log_memop(vb, op)  \
+   dprintk(2, call_memop(%p, %d, %s)%s\n,\
+   (vb)-vb2_queue, (vb)-v4l2_buf.index, #op, \
+   (vb)-vb2_queue-mem_ops-op ?  :  (nop))
+
 #define call_memop(vb, op, args...)\
 ({