All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/46] Several static analizer fixes
@ 2014-09-03 20:27 Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 01/46] [media] dmxdev: don't use before checking file->private_data Mauro Carvalho Chehab
                   ` (45 more replies)
  0 siblings, 46 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:27 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

There are several small issues reported by static analyzers.
Let's fix some of them on this patch series. One of this patch
is a real bug (dmxdev one, at patch 01/46).

The other ones are just code cleanups.

The main goal is to be able to run a static analyzer test more
frequently, so we want to have a cleaner report.

Mauro Carvalho Chehab (46):
  [media] dmxdev: don't use before checking file->private_data
  [media] marvel-ccic: don't initialize static vars with 0
  [media] soc_camera: use kmemdup()
  [media] vivid-vid-out: use memdup_user()
  [media] s5k5baf: remove an uneeded semicolon
  [media] bttv-driver: remove an uneeded semicolon
  [media] soc_camera: remove uneeded semicolons
  [media] stv0900_core: don't allocate a temporary var
  [media] em28xx: use true/false for boolean vars
  [media] tuner-core: use true/false for boolean vars
  [media] af9013: use true/false for boolean vars
  [media] cxd2820r: use true/false for boolean vars
  [media] m88ds3103: use true/false for boolean vars
  [media] af9013: use true/false for boolean vars
  [media] tda10071: use true/false for boolean vars
  [media] smiapp-core: use true/false for boolean vars
  [media] ov9740: use true/false for boolean vars
  [media] omap3isp: use true/false for boolean vars
  [media] ti-vpe: use true/false for boolean vars
  [media] vivid-tpg: use true/false for boolean vars
  [media] radio: use true/false for boolean vars
  [media] ene_ir: use true/false for boolean vars
  [media] au0828-dvb: use true/false for boolean vars
  [media] lmedm04: use true/false for boolean vars
  [media] af9005: use true/false for boolean vars
  [media] msi2500: simplify boolean tests
  [media] drxk_hard: simplify test logic
  [media] lm3560: simplify boolean tests
  [media] lm3560: simplify a boolean test
  [media] omap: simplify test logic
  [media] via-camera: simplify boolean tests
  [media] e4000: simplify boolean tests
  [media] s5p-tv: Simplify the return logic
  [media] siano: just return 0 instead of using a var
  [media] stv0367: just return 0 instead of using a var
  [media] media-devnode: just return 0 instead of using a var
  [media] bt8xx: just return 0 instead of using a var
  [media] saa7164: just return 0 instead of using a var
  [media] davinci: just return 0 instead of using a var
  [media] marvel-ccic: just return 0 instead of using a var
  [media] fintek-cir: just return 0 instead of using a var
  [media] ite-cir: just return 0 instead of using a var
  [media] nuvoton-cir: just return 0 instead of using a var
  [media] mt2060: just return 0 instead of using a var
  [media] mxl5005s: just return 0 instead of using a var
  [media] cx231xx: just return 0 instead of using a var

 drivers/media/common/siano/smscoreapi.c            |  4 +--
 drivers/media/dvb-core/dmxdev.c                    |  3 +-
 drivers/media/dvb-frontends/af9013.c               | 24 +++++++--------
 drivers/media/dvb-frontends/cxd2820r_c.c           |  4 +--
 drivers/media/dvb-frontends/cxd2820r_core.c        |  4 +--
 drivers/media/dvb-frontends/cxd2820r_t.c           |  4 +--
 drivers/media/dvb-frontends/drxk_hard.c            | 34 +++++++++++-----------
 drivers/media/dvb-frontends/m88ds3103.c            | 12 ++++----
 drivers/media/dvb-frontends/rtl2832.c              |  2 +-
 drivers/media/dvb-frontends/rtl2832_sdr.c          |  2 +-
 drivers/media/dvb-frontends/stv0367.c              |  4 +--
 drivers/media/dvb-frontends/stv0900_core.c         |  7 ++---
 drivers/media/dvb-frontends/tda10071.c             |  2 +-
 drivers/media/i2c/lm3560.c                         |  4 +--
 drivers/media/i2c/s5k5baf.c                        |  2 +-
 drivers/media/i2c/smiapp/smiapp-core.c             |  8 ++---
 drivers/media/i2c/soc_camera/ov9740.c              |  4 +--
 drivers/media/media-devnode.c                      |  3 +-
 drivers/media/pci/bt8xx/bttv-driver.c              |  5 ++--
 drivers/media/pci/bt8xx/dst_ca.c                   |  4 +--
 drivers/media/pci/saa7164/saa7164-api.c            |  3 +-
 drivers/media/pci/zoran/zoran_device.c             |  2 +-
 drivers/media/platform/davinci/vpfe_capture.c      |  3 +-
 drivers/media/platform/exynos4-is/fimc-isp-video.c |  3 +-
 drivers/media/platform/marvell-ccic/mcam-core.c    |  2 +-
 drivers/media/platform/omap/omap_vout.c            |  8 ++---
 drivers/media/platform/omap/omap_vout_vrfb.c       | 10 +++----
 drivers/media/platform/omap3isp/ispccdc.c          |  2 +-
 drivers/media/platform/s5p-tv/hdmi_drv.c           |  2 +-
 drivers/media/platform/s5p-tv/sdo_drv.c            |  2 +-
 drivers/media/platform/s5p-tv/sii9234_drv.c        |  2 +-
 drivers/media/platform/soc_camera/pxa_camera.c     |  2 +-
 drivers/media/platform/soc_camera/rcar_vin.c       |  2 +-
 drivers/media/platform/soc_camera/soc_camera.c     |  4 +--
 drivers/media/platform/ti-vpe/vpe.c                |  4 +--
 drivers/media/platform/via-camera.c                |  2 +-
 drivers/media/platform/vivid/vivid-tpg.c           |  4 +--
 drivers/media/platform/vivid/vivid-vid-out.c       | 10 ++-----
 drivers/media/radio/radio-gemtek.c                 |  2 +-
 drivers/media/radio/radio-sf16fmi.c                |  4 +--
 drivers/media/radio/si470x/radio-si470x-common.c   |  4 +--
 drivers/media/rc/ene_ir.c                          |  2 +-
 drivers/media/rc/fintek-cir.c                      |  6 ++--
 drivers/media/rc/ite-cir.c                         |  3 +-
 drivers/media/rc/nuvoton-cir.c                     |  6 ++--
 drivers/media/tuners/e4000.c                       |  4 +--
 drivers/media/tuners/mt2060.c                      |  3 +-
 drivers/media/tuners/mxl5005s.c                    |  3 +-
 drivers/media/usb/au0828/au0828-dvb.c              |  2 +-
 drivers/media/usb/cx231xx/cx231xx-dvb.c            |  4 +--
 drivers/media/usb/dvb-usb-v2/lmedm04.c             |  2 +-
 drivers/media/usb/dvb-usb/af9005.c                 |  2 +-
 drivers/media/usb/em28xx/em28xx-input.c            |  6 ++--
 drivers/media/usb/em28xx/em28xx-video.c            |  4 +--
 drivers/media/usb/msi2500/msi2500.c                |  2 +-
 drivers/media/v4l2-core/tuner-core.c               |  2 +-
 56 files changed, 117 insertions(+), 147 deletions(-)

-- 
1.9.3


^ permalink raw reply	[flat|nested] 64+ messages in thread

* [PATCH 01/46] [media] dmxdev: don't use before checking file->private_data
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 02/46] [media] marvel-ccic: don't initialize static vars with 0 Mauro Carvalho Chehab
                   ` (44 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Changbing Xiong

As reported by smatch:
	drivers/media/dvb-core/dmxdev.c:1091 dvb_demux_poll() warn: variable dereferenced before check 'dmxdevfilter' (see line 1088)

This was introduced by changeset d102cac8097c.

We need to test if dmxdevfilter exists before using it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index 42b5e70d5ca7..abff803ad69a 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -1085,10 +1085,9 @@ static long dvb_demux_ioctl(struct file *file, unsigned int cmd,
 static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
 {
 	struct dmxdev_filter *dmxdevfilter = file->private_data;
-	struct dmxdev *dmxdev = dmxdevfilter->dev;
 	unsigned int mask = 0;
 
-	if ((!dmxdevfilter) || (dmxdev->exit))
+	if ((!dmxdevfilter) || dmxdevfilter->dev->exit)
 		return POLLERR;
 
 	poll_wait(file, &dmxdevfilter->buffer.queue, wait);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 02/46] [media] marvel-ccic: don't initialize static vars with 0
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 01/46] [media] dmxdev: don't use before checking file->private_data Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 03/46] [media] soc_camera: use kmemdup() Mauro Carvalho Chehab
                   ` (43 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Jonathan Corbet

alloc_bufs_at_read is static. No need to initialize with
zero, as the Kernel will cleanup the data memory already.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index be4b51212106..7a86c77bffa0 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -67,7 +67,7 @@ MODULE_PARM_DESC(dma_buf_size,
 		"parameters require larger buffers, an attempt to reallocate "
 		"will be made.");
 #else /* MCAM_MODE_VMALLOC */
-static const bool alloc_bufs_at_read = 0;
+static const bool alloc_bufs_at_read;
 static const int n_dma_bufs = 3;  /* Used by S/G_PARM */
 #endif /* MCAM_MODE_VMALLOC */
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 03/46] [media] soc_camera: use kmemdup()
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 01/46] [media] dmxdev: don't use before checking file->private_data Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 02/46] [media] marvel-ccic: don't initialize static vars with 0 Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:44   ` Guennadi Liakhovetski
  2014-09-03 20:32 ` [PATCH 04/46] [media] vivid-vid-out: use memdup_user() Mauro Carvalho Chehab
                   ` (42 subsequent siblings)
  45 siblings, 1 reply; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Guennadi Liakhovetski

Instead of calling kzalloc and then copying, use kmemdup(). That
avoids zeroing the data structure before copying.

Found by coccinelle.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index f4308fed5431..ee8cdc95a9f9 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1347,13 +1347,11 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
 		return -ENODEV;
 	}
 
-	ssdd = kzalloc(sizeof(*ssdd), GFP_KERNEL);
+	ssdd = kmemdup(&sdesc->subdev_desc, sizeof(*ssdd), GFP_KERNEL);
 	if (!ssdd) {
 		ret = -ENOMEM;
 		goto ealloc;
 	}
-
-	memcpy(ssdd, &sdesc->subdev_desc, sizeof(*ssdd));
 	/*
 	 * In synchronous case we request regulators ourselves in
 	 * soc_camera_pdrv_probe(), make sure the subdevice driver doesn't try
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 04/46] [media] vivid-vid-out: use memdup_user()
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 03/46] [media] soc_camera: use kmemdup() Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:49   ` Hans Verkuil
  2014-09-03 20:32 ` [PATCH 05/46] [media] s5k5baf: remove an uneeded semicolon Mauro Carvalho Chehab
                   ` (41 subsequent siblings)
  45 siblings, 1 reply; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Hans Verkuil

Instead of allocating and coping from __user, do it using
one atomic call. That makes the code simpler. Also,

Found by coccinelle.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
index c983461f29d5..8ed9f6d9f505 100644
--- a/drivers/media/platform/vivid/vivid-vid-out.c
+++ b/drivers/media/platform/vivid/vivid-vid-out.c
@@ -897,14 +897,10 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv,
 		return ret;
 
 	if (win->bitmap) {
-		new_bitmap = kzalloc(bitmap_size, GFP_KERNEL);
+		new_bitmap = memdup_user(win->bitmap, bitmap_size);
 
-		if (new_bitmap == NULL)
-			return -ENOMEM;
-		if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) {
-			kfree(new_bitmap);
-			return -EFAULT;
-		}
+		if (IS_ERR(new_bitmap))
+			return PTR_ERR(new_bitmap);
 	}
 
 	dev->overlay_out_top = win->w.top;
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 05/46] [media] s5k5baf: remove an uneeded semicolon
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (3 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 04/46] [media] vivid-vid-out: use memdup_user() Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 06/46] [media] bttv-driver: " Mauro Carvalho Chehab
                   ` (40 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Kyungmin Park, Andrzej Hajda

We don't use semicolons after curly braces in the middle of the
code.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 564f05f2c9ef..0e461a6fd065 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -816,7 +816,7 @@ static void s5k5baf_hw_find_min_fiv(struct s5k5baf *state)
 				 "error setting frame interval: %d\n", err);
 			state->error = -EINVAL;
 		}
-	};
+	}
 	v4l2_err(&state->sd, "cannot find correct frame interval\n");
 	state->error = -ERANGE;
 }
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 06/46] [media] bttv-driver: remove an uneeded semicolon
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (4 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 05/46] [media] s5k5baf: remove an uneeded semicolon Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 07/46] [media] soc_camera: remove uneeded semicolons Mauro Carvalho Chehab
                   ` (39 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Hans Verkuil

We don't use semicolons after curly braces in the middle of the
code.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 970e542d3a51..750bdab8aacb 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -3856,7 +3856,7 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
 
 				btwrite(btread(BT848_INT_MASK) & (-1 ^ BT848_INT_GPINT),
 						BT848_INT_MASK);
-			};
+			}
 
 			bttv_print_irqbits(stat,astat);
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 07/46] [media] soc_camera: remove uneeded semicolons
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (5 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 06/46] [media] bttv-driver: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 08/46] [media] stv0900_core: don't allocate a temporary var Mauro Carvalho Chehab
                   ` (38 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Guennadi Liakhovetski

We don't use semicolons after curly braces in the middle of the
code.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c
index 64dc80ccd6f9..66178fc9f9eb 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -1694,7 +1694,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
 		break;
 	default:
 		break;
-	};
+	}
 
 	if (ep.bus.parallel.flags & V4L2_MBUS_MASTER)
 		pcdev->platform_flags |= PXA_CAMERA_MASTER;
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 85d579f65f52..b122c2cf5b85 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1502,7 +1502,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
 	} else {
 		priv->ici.nr = of_alias_get_id(pdev->dev.of_node, "vin");
 		priv->chip = (enum chip_id)match->data;
-	};
+	}
 
 	spin_lock_init(&priv->lock);
 	INIT_LIST_HEAD(&priv->capture);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 08/46] [media] stv0900_core: don't allocate a temporary var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (6 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 07/46] [media] soc_camera: remove uneeded semicolons Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 09/46] [media] em28xx: use true/false for boolean vars Mauro Carvalho Chehab
                   ` (37 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

The error return code STV0900_NO_ERROR happens only once, at
the end of the functions. So, just return it directly.

This driver should actually be fixed to return standard
Linux error codes, instead of its own macros, but this
should be done on a separate patchset.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/dvb-frontends/stv0900_core.c b/drivers/media/dvb-frontends/stv0900_core.c
index e5a87b57d855..2c88abfab531 100644
--- a/drivers/media/dvb-frontends/stv0900_core.c
+++ b/drivers/media/dvb-frontends/stv0900_core.c
@@ -1270,7 +1270,6 @@ enum fe_stv0900_error stv0900_st_dvbs2_single(struct stv0900_internal *intp,
 					enum fe_stv0900_demod_mode LDPC_Mode,
 					enum fe_stv0900_demod_num demod)
 {
-	enum fe_stv0900_error error = STV0900_NO_ERROR;
 	s32 reg_ind;
 
 	dprintk("%s\n", __func__);
@@ -1337,7 +1336,7 @@ enum fe_stv0900_error stv0900_st_dvbs2_single(struct stv0900_internal *intp,
 		break;
 	}
 
-	return error;
+	return STV0900_NO_ERROR;
 }
 
 static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe,
@@ -1555,8 +1554,6 @@ static int stv0900_status(struct stv0900_internal *intp,
 static int stv0900_set_mis(struct stv0900_internal *intp,
 				enum fe_stv0900_demod_num demod, int mis)
 {
-	enum fe_stv0900_error error = STV0900_NO_ERROR;
-
 	dprintk("%s\n", __func__);
 
 	if (mis < 0 || mis > 255) {
@@ -1569,7 +1566,7 @@ static int stv0900_set_mis(struct stv0900_internal *intp,
 		stv0900_write_reg(intp, ISIBITENA, 0xff);
 	}
 
-	return error;
+	return STV0900_NO_ERROR;
 }
 
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 09/46] [media] em28xx: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (7 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 08/46] [media] stv0900_core: don't allocate a temporary var Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 10/46] [media] tuner-core: " Mauro Carvalho Chehab
                   ` (36 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index ed843bd221ea..e978a2ae6f21 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -609,17 +609,17 @@ static int em28xx_register_snapshot_button(struct em28xx *dev)
 static void em28xx_init_buttons(struct em28xx *dev)
 {
 	u8  i = 0, j = 0;
-	bool addr_new = 0;
+	bool addr_new = false;
 
 	dev->button_polling_interval = EM28XX_BUTTONS_DEBOUNCED_QUERY_INTERVAL;
 	while (dev->board.buttons[i].role >= 0 &&
 			 dev->board.buttons[i].role < EM28XX_NUM_BUTTON_ROLES) {
 		struct em28xx_button *button = &dev->board.buttons[i];
 		/* Check if polling address is already on the list */
-		addr_new = 1;
+		addr_new = true;
 		for (j = 0; j < dev->num_button_polling_addresses; j++) {
 			if (button->reg_r == dev->button_polling_addresses[j]) {
-				addr_new = 0;
+				addr_new = false;
 				break;
 			}
 		}
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index f6cf99fa30b2..3642438bc7d4 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -721,7 +721,7 @@ static inline void process_frame_data_em25xx(struct em28xx *dev,
 	struct em28xx_buffer    *buf = dev->usb_ctl.vid_buf;
 	struct em28xx_dmaqueue  *dmaq = &dev->vidq;
 	struct em28xx_v4l2      *v4l2 = dev->v4l2;
-	bool frame_end = 0;
+	bool frame_end = false;
 
 	/* Check for header */
 	/* NOTE: at least with bulk transfers, only the first packet
@@ -2308,7 +2308,7 @@ static int em28xx_v4l2_init(struct em28xx *dev)
 	v4l2->v4l2_dev.ctrl_handler = hdl;
 
 	if (dev->board.is_webcam)
-		v4l2->progressive = 1;
+		v4l2->progressive = true;
 
 	/*
 	 * Default format, used for tvp5150 or saa711x output formats
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 10/46] [media] tuner-core: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (8 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 09/46] [media] em28xx: use true/false for boolean vars Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 11/46] [media] af9013: " Mauro Carvalho Chehab
                   ` (35 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Hans Verkuil

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index 177023200737..559f8372e2eb 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -601,7 +601,7 @@ static int tuner_probe(struct i2c_client *client,
 	t->name = "(tuner unset)";
 	t->type = UNSET;
 	t->audmode = V4L2_TUNER_MODE_STEREO;
-	t->standby = 1;
+	t->standby = true;
 	t->radio_freq = 87.5 * 16000;	/* Initial freq range */
 	t->tv_freq = 400 * 16; /* Sets freq to VHF High - needed for some PLL's to properly start */
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 11/46] [media] af9013: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (9 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 10/46] [media] tuner-core: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 12/46] [media] cxd2820r: " Mauro Carvalho Chehab
                   ` (34 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Antti Palosaari

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
index ecf6388d2200..8001690d7576 100644
--- a/drivers/media/dvb-frontends/af9013.c
+++ b/drivers/media/dvb-frontends/af9013.c
@@ -683,7 +683,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 
 	switch (c->transmission_mode) {
 	case TRANSMISSION_MODE_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case TRANSMISSION_MODE_2K:
 		break;
@@ -693,12 +693,12 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid transmission_mode\n",
 				__func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->guard_interval) {
 	case GUARD_INTERVAL_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case GUARD_INTERVAL_1_32:
 		break;
@@ -714,12 +714,12 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid guard_interval\n",
 				__func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->hierarchy) {
 	case HIERARCHY_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case HIERARCHY_NONE:
 		break;
@@ -734,12 +734,12 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 		break;
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid hierarchy\n", __func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->modulation) {
 	case QAM_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case QPSK:
 		break;
@@ -751,7 +751,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 		break;
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid modulation\n", __func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	/* Use HP. How and which case we can switch to LP? */
@@ -759,7 +759,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 
 	switch (c->code_rate_HP) {
 	case FEC_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case FEC_1_2:
 		break;
@@ -778,12 +778,12 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid code_rate_HP\n",
 				__func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->code_rate_LP) {
 	case FEC_AUTO:
-		auto_mode = 1;
+		auto_mode = true;
 		break;
 	case FEC_1_2:
 		break;
@@ -804,7 +804,7 @@ static int af9013_set_frontend(struct dvb_frontend *fe)
 	default:
 		dev_dbg(&state->i2c->dev, "%s: invalid code_rate_LP\n",
 				__func__);
-		auto_mode = 1;
+		auto_mode = true;
 	}
 
 	switch (c->bandwidth_hz) {
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 12/46] [media] cxd2820r: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (10 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 11/46] [media] af9013: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 13/46] [media] m88ds3103: " Mauro Carvalho Chehab
                   ` (33 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Antti Palosaari

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/dvb-frontends/cxd2820r_c.c b/drivers/media/dvb-frontends/cxd2820r_c.c
index 0f4657e01cde..149fdca3fb44 100644
--- a/drivers/media/dvb-frontends/cxd2820r_c.c
+++ b/drivers/media/dvb-frontends/cxd2820r_c.c
@@ -65,7 +65,7 @@ int cxd2820r_set_frontend_c(struct dvb_frontend *fe)
 	}
 
 	priv->delivery_system = SYS_DVBC_ANNEX_A;
-	priv->ber_running = 0; /* tune stops BER counter */
+	priv->ber_running = false; /* tune stops BER counter */
 
 	/* program IF frequency */
 	if (fe->ops.tuner_ops.get_if_frequency) {
@@ -168,7 +168,7 @@ int cxd2820r_read_ber_c(struct dvb_frontend *fe, u32 *ber)
 			start_ber = 1;
 		}
 	} else {
-		priv->ber_running = 1;
+		priv->ber_running = true;
 		start_ber = 1;
 	}
 
diff --git a/drivers/media/dvb-frontends/cxd2820r_core.c b/drivers/media/dvb-frontends/cxd2820r_core.c
index 03930d5e9fea..cd2af3edbd04 100644
--- a/drivers/media/dvb-frontends/cxd2820r_core.c
+++ b/drivers/media/dvb-frontends/cxd2820r_core.c
@@ -564,10 +564,10 @@ static enum dvbfe_search cxd2820r_search(struct dvb_frontend *fe)
 
 	/* check if we have a valid signal */
 	if (status & FE_HAS_LOCK) {
-		priv->last_tune_failed = 0;
+		priv->last_tune_failed = false;
 		return DVBFE_ALGO_SEARCH_SUCCESS;
 	} else {
-		priv->last_tune_failed = 1;
+		priv->last_tune_failed = true;
 		return DVBFE_ALGO_SEARCH_AGAIN;
 	}
 
diff --git a/drivers/media/dvb-frontends/cxd2820r_t.c b/drivers/media/dvb-frontends/cxd2820r_t.c
index 9b5a45b907bc..51401d036530 100644
--- a/drivers/media/dvb-frontends/cxd2820r_t.c
+++ b/drivers/media/dvb-frontends/cxd2820r_t.c
@@ -89,7 +89,7 @@ int cxd2820r_set_frontend_t(struct dvb_frontend *fe)
 	}
 
 	priv->delivery_system = SYS_DVBT;
-	priv->ber_running = 0; /* tune stops BER counter */
+	priv->ber_running = false; /* tune stops BER counter */
 
 	/* program IF frequency */
 	if (fe->ops.tuner_ops.get_if_frequency) {
@@ -272,7 +272,7 @@ int cxd2820r_read_ber_t(struct dvb_frontend *fe, u32 *ber)
 			start_ber = 1;
 		}
 	} else {
-		priv->ber_running = 1;
+		priv->ber_running = true;
 		start_ber = 1;
 	}
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 13/46] [media] m88ds3103: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (11 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 12/46] [media] cxd2820r: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 14/46] [media] af9013: " Mauro Carvalho Chehab
                   ` (32 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Antti Palosaari

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index 6eae2c619843..81657e94c5a4 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -1063,16 +1063,16 @@ static int m88ds3103_set_voltage(struct dvb_frontend *fe,
 
 	switch (fe_sec_voltage) {
 	case SEC_VOLTAGE_18:
-		voltage_sel = 1;
-		voltage_dis = 0;
+		voltage_sel = true;
+		voltage_dis = false;
 		break;
 	case SEC_VOLTAGE_13:
-		voltage_sel = 0;
-		voltage_dis = 0;
+		voltage_sel = false;
+		voltage_dis = false;
 		break;
 	case SEC_VOLTAGE_OFF:
-		voltage_sel = 0;
-		voltage_dis = 1;
+		voltage_sel = false;
+		voltage_dis = true;
 		break;
 	default:
 		dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_voltage\n",
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 14/46] [media] af9013: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (12 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 13/46] [media] m88ds3103: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 15/46] [media] tda10071: " Mauro Carvalho Chehab
                   ` (31 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Antti Palosaari

Instead of using 0 or 1 for boolean, use the true/false
defines.

Also, instead of testing foo == false, just use the
simplified notation if(!foo).

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index fdbed35c87fa..eb737cf29a36 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -936,7 +936,7 @@ static void rtl2832_i2c_gate_work(struct work_struct *work)
 	if (ret != 1)
 		goto err;
 
-	priv->i2c_gate_state = 0;
+	priv->i2c_gate_state = false;
 
 	return;
 err:
diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c
index 023e0f49c786..5bcf48bb4a71 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -1432,7 +1432,7 @@ struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
 	s->pixelformat = formats[0].pixelformat;
 	s->buffersize = formats[0].buffersize;
 	s->num_formats = NUM_FORMATS;
-	if (rtl2832_sdr_emulated_fmt == false)
+	if (!rtl2832_sdr_emulated_fmt)
 		s->num_formats -= 1;
 
 	mutex_init(&s->v4l2_lock);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 15/46] [media] tda10071: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (13 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 14/46] [media] af9013: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 16/46] [media] smiapp-core: " Mauro Carvalho Chehab
                   ` (30 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Antti Palosaari

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c
index 9619be5d4827..4a19b85995f1 100644
--- a/drivers/media/dvb-frontends/tda10071.c
+++ b/drivers/media/dvb-frontends/tda10071.c
@@ -1037,7 +1037,7 @@ static int tda10071_init(struct dvb_frontend *fe)
 			ret = -EFAULT;
 			goto error;
 		} else {
-			priv->warm = 1;
+			priv->warm = true;
 		}
 
 		cmd.args[0] = CMD_GET_FW_VERSION;
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 16/46] [media] smiapp-core: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (14 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 15/46] [media] tda10071: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-04  7:03   ` Sakari Ailus
  2014-09-03 20:32 ` [PATCH 17/46] [media] ov9740: " Mauro Carvalho Chehab
                   ` (29 subsequent siblings)
  45 siblings, 1 reply; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Sakari Ailus

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index c4cc5de3ae59..d312932bc56e 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -1312,7 +1312,7 @@ static void smiapp_power_off(struct smiapp_sensor *sensor)
 		clk_disable_unprepare(sensor->ext_clk);
 	usleep_range(5000, 5000);
 	regulator_disable(sensor->vana);
-	sensor->streaming = 0;
+	sensor->streaming = false;
 }
 
 static int smiapp_set_power(struct v4l2_subdev *subdev, int on)
@@ -1509,13 +1509,13 @@ static int smiapp_set_stream(struct v4l2_subdev *subdev, int enable)
 		return 0;
 
 	if (enable) {
-		sensor->streaming = 1;
+		sensor->streaming = true;
 		rval = smiapp_start_streaming(sensor);
 		if (rval < 0)
-			sensor->streaming = 0;
+			sensor->streaming = false;
 	} else {
 		rval = smiapp_stop_streaming(sensor);
-		sensor->streaming = 0;
+		sensor->streaming = false;
 	}
 
 	return rval;
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 17/46] [media] ov9740: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (15 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 16/46] [media] smiapp-core: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 18/46] [media] omap3isp: " Mauro Carvalho Chehab
                   ` (28 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Guennadi Liakhovetski

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/i2c/soc_camera/ov9740.c b/drivers/media/i2c/soc_camera/ov9740.c
index ea76863dfdb4..ee9eb635d540 100644
--- a/drivers/media/i2c/soc_camera/ov9740.c
+++ b/drivers/media/i2c/soc_camera/ov9740.c
@@ -564,13 +564,13 @@ static int ov9740_set_res(struct i2c_client *client, u32 width, u32 height)
 	u32 y_start;
 	u32 x_end;
 	u32 y_end;
-	bool scaling = 0;
+	bool scaling = false;
 	u32 scale_input_x;
 	u32 scale_input_y;
 	int ret;
 
 	if ((width != OV9740_MAX_WIDTH) || (height != OV9740_MAX_HEIGHT))
-		scaling = 1;
+		scaling = true;
 
 	/*
 	 * Try to use as much of the sensor area as possible when supporting
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 18/46] [media] omap3isp: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (16 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 17/46] [media] ov9740: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-04 20:24   ` Laurent Pinchart
  2014-09-03 20:32 ` [PATCH 19/46] [media] ti-vpe: " Mauro Carvalho Chehab
                   ` (27 subsequent siblings)
  45 siblings, 1 reply; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Laurent Pinchart

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index cabf46b4b645..81a9dc053d58 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -1806,7 +1806,7 @@ static int ccdc_video_queue(struct isp_video *video, struct isp_buffer *buffer)
 	spin_lock_irqsave(&ccdc->lock, flags);
 	if (ccdc->state == ISP_PIPELINE_STREAM_CONTINUOUS && !ccdc->running &&
 	    ccdc->bt656)
-		restart = 1;
+		restart = true;
 	else
 		ccdc->underrun = 1;
 	spin_unlock_irqrestore(&ccdc->lock, flags);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 19/46] [media] ti-vpe: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (17 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 18/46] [media] omap3isp: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 20/46] [media] vivid-tpg: " Mauro Carvalho Chehab
                   ` (26 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Archit Taneja, Hans Verkuil, Sakari Ailus

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index 773b1fbf3269..febeca70211b 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -835,10 +835,10 @@ static int set_srcdst_params(struct vpe_ctx *ctx)
 					VPDMA_STRIDE_ALIGN);
 		mv_buf_size = bytes_per_line * s_q_data->height;
 
-		ctx->deinterlacing = 1;
+		ctx->deinterlacing = true;
 		src_h <<= 1;
 	} else {
-		ctx->deinterlacing = 0;
+		ctx->deinterlacing = false;
 		mv_buf_size = 0;
 	}
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 20/46] [media] vivid-tpg: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (18 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 19/46] [media] ti-vpe: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 21/46] [media] radio: " Mauro Carvalho Chehab
                   ` (25 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Hans Verkuil

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/vivid/vivid-tpg.c b/drivers/media/platform/vivid/vivid-tpg.c
index 8576b2c1d4a1..57ff428c897e 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -183,7 +183,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
 	case V4L2_PIX_FMT_XBGR32:
 	case V4L2_PIX_FMT_ARGB32:
 	case V4L2_PIX_FMT_ABGR32:
-		tpg->is_yuv = 0;
+		tpg->is_yuv = false;
 		break;
 	case V4L2_PIX_FMT_NV16M:
 	case V4L2_PIX_FMT_NV61M:
@@ -193,7 +193,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
 	case V4L2_PIX_FMT_UYVY:
 	case V4L2_PIX_FMT_YVYU:
 	case V4L2_PIX_FMT_VYUY:
-		tpg->is_yuv = 1;
+		tpg->is_yuv = true;
 		break;
 	default:
 		return false;
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 21/46] [media] radio: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (19 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 20/46] [media] vivid-tpg: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 22/46] [media] ene_ir: " Mauro Carvalho Chehab
                   ` (24 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Hans Verkuil, Ramakrishnan Muthukrishnan

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 235c0e349820..cff1eb144a5c 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -332,7 +332,7 @@ static int __init gemtek_init(void)
 
 static void __exit gemtek_exit(void)
 {
-	hardmute = 1;	/* Turn off PLL */
+	hardmute = true;	/* Turn off PLL */
 #ifdef CONFIG_PNP
 	pnp_unregister_driver(&gemtek_driver.pnp_driver);
 #endif
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index d7ce8fe6b5ae..bcd0946c84a5 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -285,7 +285,7 @@ static int __init fmi_init(void)
 				io = isapnp_fmi_probe();
 				if (io < 0)
 					continue;
-				pnp_attached = 1;
+				pnp_attached = true;
 			}
 			if (!request_region(io, 2, "radio-sf16fmi")) {
 				if (pnp_attached)
@@ -349,7 +349,7 @@ static int __init fmi_init(void)
 	mutex_init(&fmi->lock);
 
 	/* mute card and set default frequency */
-	fmi->mute = 1;
+	fmi->mute = true;
 	fmi->curfreq = RSF16_MINFREQ;
 	fmi_set_freq(fmi);
 
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c
index 0e750aef656a..909c3f92d839 100644
--- a/drivers/media/radio/si470x/radio-si470x-common.c
+++ b/drivers/media/radio/si470x/radio-si470x-common.c
@@ -208,7 +208,7 @@ static int si470x_set_band(struct si470x_device *radio, int band)
 static int si470x_set_chan(struct si470x_device *radio, unsigned short chan)
 {
 	int retval;
-	bool timed_out = 0;
+	bool timed_out = false;
 
 	/* start tuning */
 	radio->registers[CHANNEL] &= ~CHANNEL_CHAN;
@@ -300,7 +300,7 @@ static int si470x_set_seek(struct si470x_device *radio,
 {
 	int band, retval;
 	unsigned int freq;
-	bool timed_out = 0;
+	bool timed_out = false;
 
 	/* set band */
 	if (seek->rangelow || seek->rangehigh) {
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 22/46] [media] ene_ir: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (20 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 21/46] [media] radio: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 23/46] [media] au0828-dvb: " Mauro Carvalho Chehab
                   ` (23 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Maxim Levitsky

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index d16d9b496b92..e80f2c6c5f1a 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -979,7 +979,7 @@ static int ene_transmit(struct rc_dev *rdev, unsigned *buf, unsigned n)
 	dev->tx_reg = 0;
 	dev->tx_done = 0;
 	dev->tx_sample = 0;
-	dev->tx_sample_pulse = 0;
+	dev->tx_sample_pulse = false;
 
 	dbg("TX: %d samples", dev->tx_len);
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 23/46] [media] au0828-dvb: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (21 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 22/46] [media] ene_ir: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 24/46] [media] lmedm04: " Mauro Carvalho Chehab
                   ` (22 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Devin Heitmueller

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c
index 4bd9d687d2d6..00ab1563d142 100644
--- a/drivers/media/usb/au0828/au0828-dvb.c
+++ b/drivers/media/usb/au0828/au0828-dvb.c
@@ -630,7 +630,7 @@ void au0828_dvb_suspend(struct au0828_dev *dev)
 			stop_urb_transfer(dev);
 			au0828_stop_transport(dev, 1);
 			mutex_unlock(&dvb->lock);
-			dev->need_urb_start = 1;
+			dev->need_urb_start = true;
 		}
 		/* suspend frontend - does tuner and fe to sleep */
 		rc = dvb_frontend_suspend(dvb->frontend);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 24/46] [media] lmedm04: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (22 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 23/46] [media] au0828-dvb: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 25/46] [media] af9005: " Mauro Carvalho Chehab
                   ` (21 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Malcolm Priestley

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index e332af731187..9f2c5459b73a 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -1252,7 +1252,7 @@ static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
 
 	/* Turn PID filter on the fly by module option */
 	if (pid_filter == 2) {
-		adap->pid_filtering  = 1;
+		adap->pid_filtering  = true;
 		adap->max_feed_count = 15;
 	}
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 25/46] [media] af9005: use true/false for boolean vars
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (23 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 24/46] [media] lmedm04: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 26/46] [media] msi2500: simplify boolean tests Mauro Carvalho Chehab
                   ` (20 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of using 0 or 1 for boolean, use the true/false
defines.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
index af176b6ce738..3f4361e48a32 100644
--- a/drivers/media/usb/dvb-usb/af9005.c
+++ b/drivers/media/usb/dvb-usb/af9005.c
@@ -30,7 +30,7 @@ MODULE_PARM_DESC(debug,
 		 "set debugging level (1=info,xfer=2,rc=4,reg=8,i2c=16,fw=32 (or-able))."
 		 DVB_USB_DEBUG_STATUS);
 /* enable obnoxious led */
-bool dvb_usb_af9005_led = 1;
+bool dvb_usb_af9005_led = true;
 module_param_named(led, dvb_usb_af9005_led, bool, 0644);
 MODULE_PARM_DESC(led, "enable led (default: 1).");
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 26/46] [media] msi2500: simplify boolean tests
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (24 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 25/46] [media] af9005: " Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 27/46] [media] drxk_hard: simplify test logic Mauro Carvalho Chehab
                   ` (19 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Antti Palosaari

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the
code.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c
index 71e0960b46c0..e980aaa47b7c 100644
--- a/drivers/media/usb/msi2500/msi2500.c
+++ b/drivers/media/usb/msi2500/msi2500.c
@@ -1212,7 +1212,7 @@ static int msi2500_probe(struct usb_interface *intf,
 	s->pixelformat = formats[0].pixelformat;
 	s->buffersize = formats[0].buffersize;
 	s->num_formats = NUM_FORMATS;
-	if (msi2500_emulated_fmt == false)
+	if (!msi2500_emulated_fmt)
 		s->num_formats -= 2;
 
 	/* Init videobuf2 queue structure */
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 27/46] [media] drxk_hard: simplify test logic
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (25 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 26/46] [media] msi2500: simplify boolean tests Mauro Carvalho Chehab
@ 2014-09-03 20:32 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 28/46] [media] lm3560: simplify boolean tests Mauro Carvalho Chehab
                   ` (18 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:32 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

instead of testing if it is false or true, just use
if (!foo) or if (foo). That makes the code easier to
read and shorter.

Also, properly initialize booleans with true or false.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index cce94a75b2e1..88182c18e186 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -1028,7 +1028,7 @@ static int hi_command(struct drxk_state *state, u16 cmd, u16 *p_result)
 		    ((state->m_hi_cfg_ctrl) &
 		     SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__M) ==
 		    SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ);
-	if (powerdown_cmd == false) {
+	if (!powerdown_cmd) {
 		/* Wait until command rdy */
 		u32 retry_count = 0;
 		u16 wait_cmd;
@@ -1129,7 +1129,7 @@ static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable)
 	if (status < 0)
 		goto error;
 
-	if (mpeg_enable == false) {
+	if (!mpeg_enable) {
 		/*  Set MPEG TS pads to inputmode */
 		status = write16(state, SIO_PDR_MSTRT_CFG__A, 0x0000);
 		if (status < 0)
@@ -1190,7 +1190,7 @@ static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable)
 		if (status < 0)
 			goto error;
 
-		if (state->m_enable_parallel == true) {
+		if (state->m_enable_parallel) {
 			/* parallel -> enable MD1 to MD7 */
 			status = write16(state, SIO_PDR_MD1_CFG__A,
 					 sio_pdr_mdx_cfg);
@@ -1392,7 +1392,7 @@ static int dvbt_enable_ofdm_token_ring(struct drxk_state *state, bool enable)
 
 	dprintk(1, "\n");
 
-	if (enable == false) {
+	if (!enable) {
 		desired_ctrl = SIO_OFDM_SH_OFDM_RING_ENABLE_OFF;
 		desired_status = SIO_OFDM_SH_OFDM_RING_STATUS_DOWN;
 	}
@@ -2012,7 +2012,7 @@ static int mpegts_dto_setup(struct drxk_state *state,
 		goto error;
 	fec_oc_reg_mode &= (~FEC_OC_MODE_PARITY__M);
 	fec_oc_reg_ipr_mode &= (~FEC_OC_IPR_MODE_MVAL_DIS_PAR__M);
-	if (state->m_insert_rs_byte == true) {
+	if (state->m_insert_rs_byte) {
 		/* enable parity symbol forward */
 		fec_oc_reg_mode |= FEC_OC_MODE_PARITY__M;
 		/* MVAL disable during parity bytes */
@@ -2023,7 +2023,7 @@ static int mpegts_dto_setup(struct drxk_state *state,
 
 	/* Check serial or parallel output */
 	fec_oc_reg_ipr_mode &= (~(FEC_OC_IPR_MODE_SERIAL__M));
-	if (state->m_enable_parallel == false) {
+	if (!state->m_enable_parallel) {
 		/* MPEG data output is serial -> set ipr_mode[0] */
 		fec_oc_reg_ipr_mode |= FEC_OC_IPR_MODE_SERIAL__M;
 	}
@@ -2136,19 +2136,19 @@ static int mpegts_configure_polarity(struct drxk_state *state)
 
 	/* Control selective inversion of output bits */
 	fec_oc_reg_ipr_invert &= (~(invert_data_mask));
-	if (state->m_invert_data == true)
+	if (state->m_invert_data)
 		fec_oc_reg_ipr_invert |= invert_data_mask;
 	fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MERR__M));
-	if (state->m_invert_err == true)
+	if (state->m_invert_err)
 		fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MERR__M;
 	fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MSTRT__M));
-	if (state->m_invert_str == true)
+	if (state->m_invert_str)
 		fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MSTRT__M;
 	fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MVAL__M));
-	if (state->m_invert_val == true)
+	if (state->m_invert_val)
 		fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MVAL__M;
 	fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MCLK__M));
-	if (state->m_invert_clk == true)
+	if (state->m_invert_clk)
 		fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MCLK__M;
 
 	return write16(state, FEC_OC_IPR_INVERT__A, fec_oc_reg_ipr_invert);
@@ -3352,7 +3352,7 @@ static int dvbt_ctrl_set_inc_enable(struct drxk_state *state, bool *enabled)
 	int status;
 
 	dprintk(1, "\n");
-	if (*enabled == true)
+	if (*enabled)
 		status = write16(state, IQM_CF_BYPASSDET__A, 0);
 	else
 		status = write16(state, IQM_CF_BYPASSDET__A, 1);
@@ -3368,7 +3368,7 @@ static int dvbt_ctrl_set_fr_enable(struct drxk_state *state, bool *enabled)
 	int status;
 
 	dprintk(1, "\n");
-	if (*enabled == true) {
+	if (*enabled) {
 		/* write mask to 1 */
 		status = write16(state, OFDM_SC_RA_RAM_FR_THRES_8K__A,
 				   DEFAULT_FR_THRES_8K);
@@ -6794,11 +6794,11 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config,
 	state->enable_merr_cfg = config->enable_merr_cfg;
 
 	if (config->dynamic_clk) {
-		state->m_dvbt_static_clk = 0;
-		state->m_dvbc_static_clk = 0;
+		state->m_dvbt_static_clk = false;
+		state->m_dvbc_static_clk = false;
 	} else {
-		state->m_dvbt_static_clk = 1;
-		state->m_dvbc_static_clk = 1;
+		state->m_dvbt_static_clk = true;
+		state->m_dvbc_static_clk = true;
 	}
 
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 28/46] [media] lm3560: simplify boolean tests
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (26 preceding siblings ...)
  2014-09-03 20:32 ` [PATCH 27/46] [media] drxk_hard: simplify test logic Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-04  7:08   ` Sakari Ailus
  2014-09-03 20:33 ` [PATCH 29/46] [media] lm3560: simplify a boolean test Mauro Carvalho Chehab
                   ` (17 subsequent siblings)
  45 siblings, 1 reply; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Sakari Ailus, Andy Shevchenko,
	Wei Yongjun, Daniel Jeong

Instead of using if (on == true), just use
if (on).

That allows a faster mental parsing when analyzing the
code.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index c23de593c17d..d9ece4b2d047 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -100,14 +100,14 @@ static int lm3560_enable_ctrl(struct lm3560_flash *flash,
 	int rval;
 
 	if (led_no == LM3560_LED0) {
-		if (on == true)
+		if (on)
 			rval = regmap_update_bits(flash->regmap,
 						  REG_ENABLE, 0x08, 0x08);
 		else
 			rval = regmap_update_bits(flash->regmap,
 						  REG_ENABLE, 0x08, 0x00);
 	} else {
-		if (on == true)
+		if (on)
 			rval = regmap_update_bits(flash->regmap,
 						  REG_ENABLE, 0x10, 0x10);
 		else
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 29/46] [media] lm3560: simplify a boolean test
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (27 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 28/46] [media] lm3560: simplify boolean tests Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 30/46] [media] omap: simplify test logic Mauro Carvalho Chehab
                   ` (16 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Hans Verkuil

lml33dpatch is boolean. So, the possible values are
true or false.

Instead of using if (lml33dpath), just use
if (!lml33dpath).

That allows a faster mental parsing when analyzing the
code.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/pci/zoran/zoran_device.c b/drivers/media/pci/zoran/zoran_device.c
index bf34b93f23ee..b6801e035ea4 100644
--- a/drivers/media/pci/zoran/zoran_device.c
+++ b/drivers/media/pci/zoran/zoran_device.c
@@ -682,7 +682,7 @@ set_videobus_dir (struct zoran *zr,
 	switch (zr->card.type) {
 	case LML33:
 	case LML33R10:
-		if (lml33dpath == 0)
+		if (!lml33dpath)
 			GPIO(zr, 5, val);
 		else
 			GPIO(zr, 5, 1);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 30/46] [media] omap: simplify test logic
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (28 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 29/46] [media] lm3560: simplify a boolean test Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 31/46] [media] via-camera: simplify boolean tests Mauro Carvalho Chehab
                   ` (15 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Laurent Pinchart, Tomi Valkeinen

instead of testing bools if they are false or true, just use
if (!foo) or if (foo). That makes the code easier to
read and shorter.

Also, properly initialize booleans with true or false.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
index d9258f3d0f8e..64ab6fb06b9c 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -989,7 +989,7 @@ static int omap_vout_release(struct file *file)
 		mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |
 			DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_VSYNC2;
 		omap_dispc_unregister_isr(omap_vout_isr, vout, mask);
-		vout->streaming = 0;
+		vout->streaming = false;
 
 		videobuf_streamoff(q);
 		videobuf_queue_cancel(q);
@@ -1644,7 +1644,7 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
 	vout->field_id = 0;
 
 	/* set flag here. Next QBUF will start DMA */
-	vout->streaming = 1;
+	vout->streaming = true;
 
 	vout->first_int = 1;
 
@@ -1704,7 +1704,7 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
 	if (!vout->streaming)
 		return -EINVAL;
 
-	vout->streaming = 0;
+	vout->streaming = false;
 	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD
 		| DISPC_IRQ_VSYNC2;
 
@@ -1912,7 +1912,7 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout)
 	control[0].id = V4L2_CID_ROTATE;
 	control[0].value = 0;
 	vout->rotation = 0;
-	vout->mirror = 0;
+	vout->mirror = false;
 	vout->control[2].id = V4L2_CID_HFLIP;
 	vout->control[2].value = 0;
 	if (vout->vid_info.rotation_type == VOUT_ROT_VRFB)
diff --git a/drivers/media/platform/omap/omap_vout_vrfb.c b/drivers/media/platform/omap/omap_vout_vrfb.c
index 62e7e5783ce8..aa39306afc73 100644
--- a/drivers/media/platform/omap/omap_vout_vrfb.c
+++ b/drivers/media/platform/omap/omap_vout_vrfb.c
@@ -148,7 +148,7 @@ int omap_vout_setup_vrfb_bufs(struct platform_device *pdev, int vid_num,
 			ret =  -ENOMEM;
 			goto release_vrfb_ctx;
 		}
-		vout->vrfb_static_allocation = 1;
+		vout->vrfb_static_allocation = true;
 	}
 	return 0;
 
@@ -336,7 +336,7 @@ void omap_vout_calculate_vrfb_offset(struct omap_vout_device *vout)
 		offset = vout->vrfb_context[0].yoffset *
 			vout->vrfb_context[0].bytespp;
 		temp_ps = ps / vr_ps;
-		if (mirroring == 0) {
+		if (!mirroring) {
 			*cropped_offset = offset + line_length *
 				temp_ps * cleft + crop->top * temp_ps;
 		} else {
@@ -350,7 +350,7 @@ void omap_vout_calculate_vrfb_offset(struct omap_vout_device *vout)
 			vout->vrfb_context[0].bytespp) +
 			(vout->vrfb_context[0].xoffset *
 			vout->vrfb_context[0].bytespp));
-		if (mirroring == 0) {
+		if (!mirroring) {
 			*cropped_offset = offset + (line_length * ps * ctop) +
 				(cleft / vr_ps) * ps;
 
@@ -364,7 +364,7 @@ void omap_vout_calculate_vrfb_offset(struct omap_vout_device *vout)
 		offset = MAX_PIXELS_PER_LINE * vout->vrfb_context[0].xoffset *
 			vout->vrfb_context[0].bytespp;
 		temp_ps = ps / vr_ps;
-		if (mirroring == 0) {
+		if (!mirroring) {
 			*cropped_offset = offset + line_length *
 			    temp_ps * crop->left + ctop * ps;
 		} else {
@@ -375,7 +375,7 @@ void omap_vout_calculate_vrfb_offset(struct omap_vout_device *vout)
 		}
 		break;
 	case dss_rotation_0_degree:
-		if (mirroring == 0) {
+		if (!mirroring) {
 			*cropped_offset = (line_length * ps) *
 				crop->top + (crop->left / vr_ps) * ps;
 		} else {
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 31/46] [media] via-camera: simplify boolean tests
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (29 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 30/46] [media] omap: simplify test logic Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 32/46] [media] e4000: " Mauro Carvalho Chehab
                   ` (14 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Hans Verkuil, Axel Lin

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the
code.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c
index 00d431293190..ae6870cb8339 100644
--- a/drivers/media/platform/via-camera.c
+++ b/drivers/media/platform/via-camera.c
@@ -1276,7 +1276,7 @@ static bool viacam_serial_is_enabled(void)
 			VIACAM_SERIAL_CREG, &cbyte);
 	if ((cbyte & VIACAM_SERIAL_BIT) == 0)
 		return false; /* Not enabled */
-	if (override_serial == 0) {
+	if (!override_serial) {
 		printk(KERN_NOTICE "Via camera: serial port is enabled, " \
 				"refusing to load.\n");
 		printk(KERN_NOTICE "Specify override_serial=1 to force " \
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 32/46] [media] e4000: simplify boolean tests
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (30 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 31/46] [media] via-camera: simplify boolean tests Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 23:56   ` Antti Palosaari
  2014-09-03 20:33   ` Mauro Carvalho Chehab
                   ` (13 subsequent siblings)
  45 siblings, 1 reply; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Antti Palosaari

Instead of using if (foo == false), just use
if (!foo).

That allows a faster mental parsing when analyzing the
code.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 90d93348f20c..cd9cf643f602 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
 	int ret;
 
-	if (s->active == false)
+	if (!s->active)
 		return 0;
 
 	switch (ctrl->id) {
@@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	int ret;
 
-	if (s->active == false)
+	if (!s->active)
 		return 0;
 
 	switch (ctrl->id) {
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 33/46] [media] s5p-tv: Simplify the return logic
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
@ 2014-09-03 20:33   ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 02/46] [media] marvel-ccic: don't initialize static vars with 0 Mauro Carvalho Chehab
                     ` (44 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Kyungmin Park, Tomasz Stanislawski,
	linux-arm-kernel

Make sure pm_runtime_* calls does not use unnecessary
IS_ERR_VALUE().

Reported by scripts/coccinelle/api/pm_runtime.cocci script.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c b/drivers/media/platform/s5p-tv/hdmi_drv.c
index 754740f4b671..37c8bd694c5f 100644
--- a/drivers/media/platform/s5p-tv/hdmi_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmi_drv.c
@@ -615,7 +615,7 @@ static int hdmi_s_power(struct v4l2_subdev *sd, int on)
 	else
 		ret = pm_runtime_put_sync(hdev->dev);
 	/* only values < 0 indicate errors */
-	return IS_ERR_VALUE(ret) ? ret : 0;
+	return ret < 0 ? ret : 0;
 }
 
 static int hdmi_s_dv_timings(struct v4l2_subdev *sd,
diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c b/drivers/media/platform/s5p-tv/sdo_drv.c
index 5a7c3796f22e..72cf892dd008 100644
--- a/drivers/media/platform/s5p-tv/sdo_drv.c
+++ b/drivers/media/platform/s5p-tv/sdo_drv.c
@@ -190,7 +190,7 @@ static int sdo_s_power(struct v4l2_subdev *sd, int on)
 		ret = pm_runtime_put_sync(dev);
 
 	/* only values < 0 indicate errors */
-	return IS_ERR_VALUE(ret) ? ret : 0;
+	return ret < 0 ? ret : 0;
 }
 
 static int sdo_streamon(struct sdo_device *sdev)
diff --git a/drivers/media/platform/s5p-tv/sii9234_drv.c b/drivers/media/platform/s5p-tv/sii9234_drv.c
index 3dd762e5b67e..db8c17bb4aaa 100644
--- a/drivers/media/platform/s5p-tv/sii9234_drv.c
+++ b/drivers/media/platform/s5p-tv/sii9234_drv.c
@@ -289,7 +289,7 @@ static int sii9234_s_power(struct v4l2_subdev *sd, int on)
 	else
 		ret = pm_runtime_put(&ctx->client->dev);
 	/* only values < 0 indicate errors */
-	return IS_ERR_VALUE(ret) ? ret : 0;
+	return ret < 0 ? ret : 0;
 }
 
 static int sii9234_s_stream(struct v4l2_subdev *sd, int enable)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 33/46] [media] s5p-tv: Simplify the return logic
@ 2014-09-03 20:33   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  To: linux-arm-kernel

Make sure pm_runtime_* calls does not use unnecessary
IS_ERR_VALUE().

Reported by scripts/coccinelle/api/pm_runtime.cocci script.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/s5p-tv/hdmi_drv.c b/drivers/media/platform/s5p-tv/hdmi_drv.c
index 754740f4b671..37c8bd694c5f 100644
--- a/drivers/media/platform/s5p-tv/hdmi_drv.c
+++ b/drivers/media/platform/s5p-tv/hdmi_drv.c
@@ -615,7 +615,7 @@ static int hdmi_s_power(struct v4l2_subdev *sd, int on)
 	else
 		ret = pm_runtime_put_sync(hdev->dev);
 	/* only values < 0 indicate errors */
-	return IS_ERR_VALUE(ret) ? ret : 0;
+	return ret < 0 ? ret : 0;
 }
 
 static int hdmi_s_dv_timings(struct v4l2_subdev *sd,
diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c b/drivers/media/platform/s5p-tv/sdo_drv.c
index 5a7c3796f22e..72cf892dd008 100644
--- a/drivers/media/platform/s5p-tv/sdo_drv.c
+++ b/drivers/media/platform/s5p-tv/sdo_drv.c
@@ -190,7 +190,7 @@ static int sdo_s_power(struct v4l2_subdev *sd, int on)
 		ret = pm_runtime_put_sync(dev);
 
 	/* only values < 0 indicate errors */
-	return IS_ERR_VALUE(ret) ? ret : 0;
+	return ret < 0 ? ret : 0;
 }
 
 static int sdo_streamon(struct sdo_device *sdev)
diff --git a/drivers/media/platform/s5p-tv/sii9234_drv.c b/drivers/media/platform/s5p-tv/sii9234_drv.c
index 3dd762e5b67e..db8c17bb4aaa 100644
--- a/drivers/media/platform/s5p-tv/sii9234_drv.c
+++ b/drivers/media/platform/s5p-tv/sii9234_drv.c
@@ -289,7 +289,7 @@ static int sii9234_s_power(struct v4l2_subdev *sd, int on)
 	else
 		ret = pm_runtime_put(&ctx->client->dev);
 	/* only values < 0 indicate errors */
-	return IS_ERR_VALUE(ret) ? ret : 0;
+	return ret < 0 ? ret : 0;
 }
 
 static int sii9234_s_stream(struct v4l2_subdev *sd, int enable)
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 34/46] [media] siano: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (32 preceding siblings ...)
  2014-09-03 20:33   ` Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 35/46] [media] stv0367: " Mauro Carvalho Chehab
                   ` (11 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
index 050984c5b1e3..a3677438205e 100644
--- a/drivers/media/common/siano/smscoreapi.c
+++ b/drivers/media/common/siano/smscoreapi.c
@@ -2129,8 +2129,6 @@ int smscore_gpio_get_level(struct smscore_device_t *coredev, u8 pin_num,
 
 static int __init smscore_module_init(void)
 {
-	int rc = 0;
-
 	INIT_LIST_HEAD(&g_smscore_notifyees);
 	INIT_LIST_HEAD(&g_smscore_devices);
 	kmutex_init(&g_smscore_deviceslock);
@@ -2138,7 +2136,7 @@ static int __init smscore_module_init(void)
 	INIT_LIST_HEAD(&g_smscore_registry);
 	kmutex_init(&g_smscore_registrylock);
 
-	return rc;
+	return 0;
 }
 
 static void __exit smscore_module_exit(void)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 35/46] [media] stv0367: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (33 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 34/46] [media] siano: just return 0 instead of using a var Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 36/46] [media] media-devnode: " Mauro Carvalho Chehab
                   ` (10 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Emil Goode

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c
index 764577218974..59f622ae80e8 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -1935,8 +1935,6 @@ static int stv0367ter_get_frontend(struct dvb_frontend *fe)
 	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
 	struct stv0367_state *state = fe->demodulator_priv;
 	struct stv0367ter_state *ter_state = state->ter_state;
-
-	int error = 0;
 	enum stv0367_ter_mode mode;
 	int constell = 0,/* snr = 0,*/ Data = 0;
 
@@ -2020,7 +2018,7 @@ static int stv0367ter_get_frontend(struct dvb_frontend *fe)
 
 	p->guard_interval = stv0367_readbits(state, F367TER_SYR_GUARD);
 
-	return error;
+	return 0;
 }
 
 static int stv0367ter_read_snr(struct dvb_frontend *fe, u16 *snr)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 36/46] [media] media-devnode: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (34 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 35/46] [media] stv0367: " Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 37/46] [media] bt8xx: " Mauro Carvalho Chehab
                   ` (9 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c
index 7acd19c881de..ebf9626e5ae5 100644
--- a/drivers/media/media-devnode.c
+++ b/drivers/media/media-devnode.c
@@ -192,7 +192,6 @@ static int media_open(struct inode *inode, struct file *filp)
 static int media_release(struct inode *inode, struct file *filp)
 {
 	struct media_devnode *mdev = media_devnode_data(filp);
-	int ret = 0;
 
 	if (mdev->fops->release)
 		mdev->fops->release(filp);
@@ -201,7 +200,7 @@ static int media_release(struct inode *inode, struct file *filp)
 	   return value is ignored. */
 	put_device(&mdev->dev);
 	filp->private_data = NULL;
-	return ret;
+	return 0;
 }
 
 static const struct file_operations media_devnode_fops = {
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 37/46] [media] bt8xx: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (35 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 36/46] [media] media-devnode: " Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 38/46] [media] saa7164: " Mauro Carvalho Chehab
                   ` (8 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Hans Verkuil

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 750bdab8aacb..4a8176c09fc9 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -1531,7 +1531,6 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
 {
 	struct bttv_buffer *old;
 	unsigned long flags;
-	int retval = 0;
 
 	dprintk("switch_overlay: enter [new=%p]\n", new);
 	if (new)
@@ -1551,7 +1550,7 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
 	if (NULL == new)
 		free_btres_lock(btv,fh,RESOURCE_OVERLAY);
 	dprintk("switch_overlay: done\n");
-	return retval;
+	return 0;
 }
 
 /* ----------------------------------------------------------------------- */
diff --git a/drivers/media/pci/bt8xx/dst_ca.c b/drivers/media/pci/bt8xx/dst_ca.c
index 0e788fca992c..c22c4ae06844 100644
--- a/drivers/media/pci/bt8xx/dst_ca.c
+++ b/drivers/media/pci/bt8xx/dst_ca.c
@@ -674,11 +674,9 @@ static int dst_ca_release(struct inode *inode, struct file *file)
 
 static ssize_t dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset)
 {
-	ssize_t bytes_read = 0;
-
 	dprintk(verbose, DST_CA_DEBUG, 1, " Device read.");
 
-	return bytes_read;
+	return 0;
 }
 
 static ssize_t dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 38/46] [media] saa7164: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (36 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 37/46] [media] bt8xx: " Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 39/46] [media] davinci: " Mauro Carvalho Chehab
                   ` (7 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/pci/saa7164/saa7164-api.c b/drivers/media/pci/saa7164/saa7164-api.c
index e042963d377d..4f3b1dd18ba4 100644
--- a/drivers/media/pci/saa7164/saa7164-api.c
+++ b/drivers/media/pci/saa7164/saa7164-api.c
@@ -680,7 +680,6 @@ static int saa7164_api_set_dif(struct saa7164_port *port, u8 reg, u8 val)
 int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
 {
 	struct saa7164_dev *dev = port->dev;
-	int ret = 0;
 	u8 agc_disable;
 
 	dprintk(DBGLVL_API, "%s(nr=%d, 0x%x)\n", __func__, port->nr, std);
@@ -733,7 +732,7 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
 	saa7164_api_set_dif(port, 0x04, 0x00); /* Active (again) */
 	msleep(100);
 
-	return ret;
+	return 0;
 }
 
 /* Ensure the dif is in the correct state for the operating mode
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 39/46] [media] davinci: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (37 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 38/46] [media] saa7164: " Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:43   ` Prabhakar Lad
  2014-09-03 20:33   ` Mauro Carvalho Chehab
                   ` (6 subsequent siblings)
  45 siblings, 1 reply; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Prabhakar Lad, davinci-linux-open-source

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
index ed9dd27e3c63..c557eb5ebf6b 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -943,12 +943,11 @@ static int vpfe_g_fmt_vid_cap(struct file *file, void *priv,
 				struct v4l2_format *fmt)
 {
 	struct vpfe_device *vpfe_dev = video_drvdata(file);
-	int ret = 0;
 
 	v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_fmt_vid_cap\n");
 	/* Fill in the information about format */
 	*fmt = vpfe_dev->fmt;
-	return ret;
+	return 0;
 }
 
 static int vpfe_enum_fmt_vid_cap(struct file *file, void  *priv,
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 40/46] [media] marvel-ccic: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 01/46] [media] dmxdev: don't use before checking file->private_data Mauro Carvalho Chehab
@ 2014-09-03 20:33   ` Mauro Carvalho Chehab
  2014-09-03 20:32 ` [PATCH 03/46] [media] soc_camera: use kmemdup() Mauro Carvalho Chehab
                     ` (43 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Kyungmin Park, Sylwester Nawrocki,
	Kukjin Kim, linux-arm-kernel, linux-samsung-soc

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
index 93f9cf2ebcd6..9d8d885558e5 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
@@ -313,7 +313,6 @@ static int isp_video_release(struct file *file)
 	struct fimc_is_video *ivc = &isp->video_capture;
 	struct media_entity *entity = &ivc->ve.vdev.entity;
 	struct media_device *mdev = entity->parent;
-	int ret = 0;
 
 	mutex_lock(&isp->video_lock);
 
@@ -335,7 +334,7 @@ static int isp_video_release(struct file *file)
 	pm_runtime_put(&isp->pdev->dev);
 	mutex_unlock(&isp->video_lock);
 
-	return ret;
+	return 0;
 }
 
 static const struct v4l2_file_operations isp_video_fops = {
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 40/46] [media] marvel-ccic: just return 0 instead of using a var
@ 2014-09-03 20:33   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Kukjin Kim, Mauro Carvalho Chehab, Kyungmin Park,
	linux-samsung-soc, Sylwester Nawrocki, Mauro Carvalho Chehab,
	linux-arm-kernel, Linux Media Mailing List

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
index 93f9cf2ebcd6..9d8d885558e5 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
@@ -313,7 +313,6 @@ static int isp_video_release(struct file *file)
 	struct fimc_is_video *ivc = &isp->video_capture;
 	struct media_entity *entity = &ivc->ve.vdev.entity;
 	struct media_device *mdev = entity->parent;
-	int ret = 0;
 
 	mutex_lock(&isp->video_lock);
 
@@ -335,7 +334,7 @@ static int isp_video_release(struct file *file)
 	pm_runtime_put(&isp->pdev->dev);
 	mutex_unlock(&isp->video_lock);
 
-	return ret;
+	return 0;
 }
 
 static const struct v4l2_file_operations isp_video_fops = {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 40/46] [media] marvel-ccic: just return 0 instead of using a var
@ 2014-09-03 20:33   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  To: linux-arm-kernel

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
index 93f9cf2ebcd6..9d8d885558e5 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
@@ -313,7 +313,6 @@ static int isp_video_release(struct file *file)
 	struct fimc_is_video *ivc = &isp->video_capture;
 	struct media_entity *entity = &ivc->ve.vdev.entity;
 	struct media_device *mdev = entity->parent;
-	int ret = 0;
 
 	mutex_lock(&isp->video_lock);
 
@@ -335,7 +334,7 @@ static int isp_video_release(struct file *file)
 	pm_runtime_put(&isp->pdev->dev);
 	mutex_unlock(&isp->video_lock);
 
-	return ret;
+	return 0;
 }
 
 static const struct v4l2_file_operations isp_video_fops = {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 41/46] [media] fintek-cir: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (39 preceding siblings ...)
  2014-09-03 20:33   ` Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 42/46] [media] ite-cir: " Mauro Carvalho Chehab
                   ` (4 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, David Härdeman,
	Antti Seppälä,
	James Hogan

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index f0a1f7d31ee6..b5167573240e 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -148,7 +148,6 @@ static int fintek_hw_detect(struct fintek_dev *fintek)
 	u8 vendor_major, vendor_minor;
 	u8 portsel, ir_class;
 	u16 vendor, chip;
-	int ret = 0;
 
 	fintek_config_mode_enable(fintek);
 
@@ -208,7 +207,7 @@ static int fintek_hw_detect(struct fintek_dev *fintek)
 
 	spin_unlock_irqrestore(&fintek->fintek_lock, flags);
 
-	return ret;
+	return 0;
 }
 
 static void fintek_cir_ldev_init(struct fintek_dev *fintek)
@@ -644,7 +643,6 @@ static int fintek_suspend(struct pnp_dev *pdev, pm_message_t state)
 
 static int fintek_resume(struct pnp_dev *pdev)
 {
-	int ret = 0;
 	struct fintek_dev *fintek = pnp_get_drvdata(pdev);
 
 	fit_dbg("%s called", __func__);
@@ -661,7 +659,7 @@ static int fintek_resume(struct pnp_dev *pdev)
 
 	fintek_cir_regs_init(fintek);
 
-	return ret;
+	return 0;
 }
 
 static void fintek_shutdown(struct pnp_dev *pdev)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 42/46] [media] ite-cir: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (40 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 41/46] [media] fintek-cir: " Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 43/46] [media] nuvoton-cir: " Mauro Carvalho Chehab
                   ` (3 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, David Härdeman, James Hogan,
	Antti Seppälä

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 447fe35862dc..56abf9120cc2 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -1666,7 +1666,6 @@ static int ite_suspend(struct pnp_dev *pdev, pm_message_t state)
 
 static int ite_resume(struct pnp_dev *pdev)
 {
-	int ret = 0;
 	struct ite_dev *dev = pnp_get_drvdata(pdev);
 	unsigned long flags;
 
@@ -1681,7 +1680,7 @@ static int ite_resume(struct pnp_dev *pdev)
 
 	spin_unlock_irqrestore(&dev->lock, flags);
 
-	return ret;
+	return 0;
 }
 
 static void ite_shutdown(struct pnp_dev *pdev)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 43/46] [media] nuvoton-cir: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (41 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 42/46] [media] ite-cir: " Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 44/46] [media] mt2060: " Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Antti Seppälä,
	David Härdeman, James Hogan, Jarod Wilson

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 7f4fd859bba5..9c2c8635ff33 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -229,7 +229,6 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
 {
 	unsigned long flags;
 	u8 chip_major, chip_minor;
-	int ret = 0;
 	char chip_id[12];
 	bool chip_unknown = false;
 
@@ -285,7 +284,7 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
 	nvt->chip_minor = chip_minor;
 	spin_unlock_irqrestore(&nvt->nvt_lock, flags);
 
-	return ret;
+	return 0;
 }
 
 static void nvt_cir_ldev_init(struct nvt_dev *nvt)
@@ -1177,7 +1176,6 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
 
 static int nvt_resume(struct pnp_dev *pdev)
 {
-	int ret = 0;
 	struct nvt_dev *nvt = pnp_get_drvdata(pdev);
 
 	nvt_dbg("%s called", __func__);
@@ -1195,7 +1193,7 @@ static int nvt_resume(struct pnp_dev *pdev)
 	nvt_cir_regs_init(nvt);
 	nvt_cir_wake_regs_init(nvt);
 
-	return ret;
+	return 0;
 }
 
 static void nvt_shutdown(struct pnp_dev *pdev)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 44/46] [media] mt2060: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (42 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 43/46] [media] nuvoton-cir: " Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 45/46] [media] mxl5005s: " Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 46/46] [media] cx231xx: " Mauro Carvalho Chehab
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/tuners/mt2060.c b/drivers/media/tuners/mt2060.c
index 13381de58a84..b87b2549d58d 100644
--- a/drivers/media/tuners/mt2060.c
+++ b/drivers/media/tuners/mt2060.c
@@ -157,7 +157,6 @@ static int mt2060_set_params(struct dvb_frontend *fe)
 {
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	struct mt2060_priv *priv;
-	int ret=0;
 	int i=0;
 	u32 freq;
 	u8  lnaband;
@@ -240,7 +239,7 @@ static int mt2060_set_params(struct dvb_frontend *fe)
 	if (fe->ops.i2c_gate_ctrl)
 		fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */
 
-	return ret;
+	return 0;
 }
 
 static void mt2060_calibrate(struct mt2060_priv *priv)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 45/46] [media] mxl5005s: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (43 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 44/46] [media] mt2060: " Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  2014-09-03 20:33 ` [PATCH 46/46] [media] cx231xx: " Mauro Carvalho Chehab
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/tuners/mxl5005s.c b/drivers/media/tuners/mxl5005s.c
index b473b76cb278..92a3be4fde87 100644
--- a/drivers/media/tuners/mxl5005s.c
+++ b/drivers/media/tuners/mxl5005s.c
@@ -1692,7 +1692,6 @@ static u16 MXL5005_TunerConfig(struct dvb_frontend *fe,
 	)
 {
 	struct mxl5005s_state *state = fe->tuner_priv;
-	u16 status = 0;
 
 	state->Mode = Mode;
 	state->IF_Mode = IF_mode;
@@ -1715,7 +1714,7 @@ static u16 MXL5005_TunerConfig(struct dvb_frontend *fe,
 	/* Synthesizer LO frequency calculation */
 	MXL_SynthIFLO_Calc(fe);
 
-	return status;
+	return 0;
 }
 
 static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* [PATCH 46/46] [media] cx231xx: just return 0 instead of using a var
  2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
                   ` (44 preceding siblings ...)
  2014-09-03 20:33 ` [PATCH 45/46] [media] mxl5005s: " Mauro Carvalho Chehab
@ 2014-09-03 20:33 ` Mauro Carvalho Chehab
  45 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:33 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, Mauro Carvalho Chehab

Instead of allocating a var to store 0 and just return it,
change the code to return 0 directly.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 2adfecf70236..6c7b5e250eed 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -403,8 +403,6 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev)
 
 int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq)
 {
-	int status = 0;
-
 	if ((dev->dvb != NULL) && (dev->dvb->frontend != NULL)) {
 
 		struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops;
@@ -423,7 +421,7 @@ int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq)
 
 	}
 
-	return status;
+	return 0;
 }
 
 int cx231xx_reset_analog_tuner(struct cx231xx *dev)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 64+ messages in thread

* Re: [PATCH 39/46] [media] davinci: just return 0 instead of using a var
  2014-09-03 20:33 ` [PATCH 39/46] [media] davinci: " Mauro Carvalho Chehab
@ 2014-09-03 20:43   ` Prabhakar Lad
  0 siblings, 0 replies; 64+ messages in thread
From: Prabhakar Lad @ 2014-09-03 20:43 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, dlos

On Wed, Sep 3, 2014 at 9:33 PM, Mauro Carvalho Chehab
<m.chehab@samsung.com> wrote:
> Instead of allocating a var to store 0 and just return it,
> change the code to return 0 directly.
>

Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Regards,
--Prabhakar Lad

> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
>
> diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
> index ed9dd27e3c63..c557eb5ebf6b 100644
> --- a/drivers/media/platform/davinci/vpfe_capture.c
> +++ b/drivers/media/platform/davinci/vpfe_capture.c
> @@ -943,12 +943,11 @@ static int vpfe_g_fmt_vid_cap(struct file *file, void *priv,
>                                 struct v4l2_format *fmt)
>  {
>         struct vpfe_device *vpfe_dev = video_drvdata(file);
> -       int ret = 0;
>
>         v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_fmt_vid_cap\n");
>         /* Fill in the information about format */
>         *fmt = vpfe_dev->fmt;
> -       return ret;
> +       return 0;
>  }
>
>  static int vpfe_enum_fmt_vid_cap(struct file *file, void  *priv,
> --
> 1.9.3
>

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 03/46] [media] soc_camera: use kmemdup()
  2014-09-03 20:32 ` [PATCH 03/46] [media] soc_camera: use kmemdup() Mauro Carvalho Chehab
@ 2014-09-03 20:44   ` Guennadi Liakhovetski
  2014-09-03 20:54     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 64+ messages in thread
From: Guennadi Liakhovetski @ 2014-09-03 20:44 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Hi Mauro,

On Wed, 3 Sep 2014, Mauro Carvalho Chehab wrote:

> Instead of calling kzalloc and then copying, use kmemdup(). That
> avoids zeroing the data structure before copying.
> 
> Found by coccinelle.
> 
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index f4308fed5431..ee8cdc95a9f9 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -1347,13 +1347,11 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
>  		return -ENODEV;
>  	}
>  
> -	ssdd = kzalloc(sizeof(*ssdd), GFP_KERNEL);
> +	ssdd = kmemdup(&sdesc->subdev_desc, sizeof(*ssdd), GFP_KERNEL);
>  	if (!ssdd) {
>  		ret = -ENOMEM;
>  		goto ealloc;
>  	}
> -
> -	memcpy(ssdd, &sdesc->subdev_desc, sizeof(*ssdd));

Hm, wow... that seems  to be a particularly silly one... Even if not 
memdup, why did I use kZalloc() to immediately overwrite it completely?.. 
Thanks for catching! This and the other two (so far) patches - would you 
like me to pull-push them or just use my

Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>

for all 3 of them?

Thanks
Guennadi

>  	/*
>  	 * In synchronous case we request regulators ourselves in
>  	 * soc_camera_pdrv_probe(), make sure the subdevice driver doesn't try
> -- 
> 1.9.3
> 

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 04/46] [media] vivid-vid-out: use memdup_user()
  2014-09-03 20:32 ` [PATCH 04/46] [media] vivid-vid-out: use memdup_user() Mauro Carvalho Chehab
@ 2014-09-03 20:49   ` Hans Verkuil
  2014-09-03 20:57     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 64+ messages in thread
From: Hans Verkuil @ 2014-09-03 20:49 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

On 09/03/2014 10:32 PM, Mauro Carvalho Chehab wrote:
> Instead of allocating and coping from __user, do it using
> one atomic call. That makes the code simpler. Also,

Also what?

Anyway, looks good to me:

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Regards,

	Hans

> 
> Found by coccinelle.
> 
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> 
> diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
> index c983461f29d5..8ed9f6d9f505 100644
> --- a/drivers/media/platform/vivid/vivid-vid-out.c
> +++ b/drivers/media/platform/vivid/vivid-vid-out.c
> @@ -897,14 +897,10 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv,
>  		return ret;
>  
>  	if (win->bitmap) {
> -		new_bitmap = kzalloc(bitmap_size, GFP_KERNEL);
> +		new_bitmap = memdup_user(win->bitmap, bitmap_size);
>  
> -		if (new_bitmap == NULL)
> -			return -ENOMEM;
> -		if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) {
> -			kfree(new_bitmap);
> -			return -EFAULT;
> -		}
> +		if (IS_ERR(new_bitmap))
> +			return PTR_ERR(new_bitmap);
>  	}
>  
>  	dev->overlay_out_top = win->w.top;
> 


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 03/46] [media] soc_camera: use kmemdup()
  2014-09-03 20:44   ` Guennadi Liakhovetski
@ 2014-09-03 20:54     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:54 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Em Wed, 3 Sep 2014 22:44:02 +0200 (CEST)
Guennadi Liakhovetski <g.liakhovetski@gmx.de> escreveu:

> Hi Mauro,
> 
> On Wed, 3 Sep 2014, Mauro Carvalho Chehab wrote:
> 
> > Instead of calling kzalloc and then copying, use kmemdup(). That
> > avoids zeroing the data structure before copying.
> > 
> > Found by coccinelle.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> > 
> > diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> > index f4308fed5431..ee8cdc95a9f9 100644
> > --- a/drivers/media/platform/soc_camera/soc_camera.c
> > +++ b/drivers/media/platform/soc_camera/soc_camera.c
> > @@ -1347,13 +1347,11 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
> >  		return -ENODEV;
> >  	}
> >  
> > -	ssdd = kzalloc(sizeof(*ssdd), GFP_KERNEL);
> > +	ssdd = kmemdup(&sdesc->subdev_desc, sizeof(*ssdd), GFP_KERNEL);
> >  	if (!ssdd) {
> >  		ret = -ENOMEM;
> >  		goto ealloc;
> >  	}
> > -
> > -	memcpy(ssdd, &sdesc->subdev_desc, sizeof(*ssdd));
> 
> Hm, wow... that seems  to be a particularly silly one... Even if not 
> memdup, why did I use kZalloc() to immediately overwrite it completely?.. 

Maybe this pattern happened due to some incremental change.

> Thanks for catching! This and the other two (so far) patches - would you 
> like me to pull-push them or just use my
> 
> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> 
> for all 3 of them?

Just the acked-by is enough.

Thanks!
Mauro

> 
> Thanks
> Guennadi
> 
> >  	/*
> >  	 * In synchronous case we request regulators ourselves in
> >  	 * soc_camera_pdrv_probe(), make sure the subdevice driver doesn't try
> > -- 
> > 1.9.3
> > 

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 04/46] [media] vivid-vid-out: use memdup_user()
  2014-09-03 20:49   ` Hans Verkuil
@ 2014-09-03 20:57     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-03 20:57 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Em Wed, 03 Sep 2014 22:49:47 +0200
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> On 09/03/2014 10:32 PM, Mauro Carvalho Chehab wrote:
> > Instead of allocating and coping from __user, do it using
> > one atomic call. That makes the code simpler. Also,
> 
> Also what?

I added a comment about IS_ERR(new_bitmap), and returning
the error, but then I realized that the above is good enough,
but I forgot the "Also, " at the above line. Thanks for
pointing it.

> 
> Anyway, looks good to me:
> 
> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Thanks!
Mauro
> 
> Regards,
> 
> 	Hans
> 
> > 
> > Found by coccinelle.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> > 
> > diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
> > index c983461f29d5..8ed9f6d9f505 100644
> > --- a/drivers/media/platform/vivid/vivid-vid-out.c
> > +++ b/drivers/media/platform/vivid/vivid-vid-out.c
> > @@ -897,14 +897,10 @@ int vidioc_s_fmt_vid_out_overlay(struct file *file, void *priv,
> >  		return ret;
> >  
> >  	if (win->bitmap) {
> > -		new_bitmap = kzalloc(bitmap_size, GFP_KERNEL);
> > +		new_bitmap = memdup_user(win->bitmap, bitmap_size);
> >  
> > -		if (new_bitmap == NULL)
> > -			return -ENOMEM;
> > -		if (copy_from_user(new_bitmap, win->bitmap, bitmap_size)) {
> > -			kfree(new_bitmap);
> > -			return -EFAULT;
> > -		}
> > +		if (IS_ERR(new_bitmap))
> > +			return PTR_ERR(new_bitmap);
> >  	}
> >  
> >  	dev->overlay_out_top = win->w.top;
> > 
> 

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 32/46] [media] e4000: simplify boolean tests
  2014-09-03 20:33 ` [PATCH 32/46] [media] e4000: " Mauro Carvalho Chehab
@ 2014-09-03 23:56   ` Antti Palosaari
  2014-09-04  1:12     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 64+ messages in thread
From: Antti Palosaari @ 2014-09-03 23:56 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Which is static analyzer you are referring to fix these?

Using true/false for boolean datatype sounds OK, but personally I 
dislike use of negation operator. For my eyes (foo = 0) / (foo == false) 
is better and I have changed all the time negate operators to equal 
operators from my drivers.

regards
Antti

On 09/03/2014 11:33 PM, Mauro Carvalho Chehab wrote:
> Instead of using if (foo == false), just use
> if (!foo).
>
> That allows a faster mental parsing when analyzing the
> code.
>
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
>
> diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
> index 90d93348f20c..cd9cf643f602 100644
> --- a/drivers/media/tuners/e4000.c
> +++ b/drivers/media/tuners/e4000.c
> @@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
>   	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
>   	int ret;
>
> -	if (s->active == false)
> +	if (!s->active)
>   		return 0;
>
>   	switch (ctrl->id) {
> @@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
>   	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
>   	int ret;
>
> -	if (s->active == false)
> +	if (!s->active)
>   		return 0;
>
>   	switch (ctrl->id) {
>

-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 32/46] [media] e4000: simplify boolean tests
  2014-09-03 23:56   ` Antti Palosaari
@ 2014-09-04  1:12     ` Mauro Carvalho Chehab
  2014-09-04  1:27       ` Antti Palosaari
  0 siblings, 1 reply; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-04  1:12 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Em Thu, 04 Sep 2014 02:56:19 +0300
Antti Palosaari <crope@iki.fi> escreveu:

> Which is static analyzer you are referring to fix these?

Coccinelle. See: scripts/coccinelle/misc/boolinit.cocci

> Using true/false for boolean datatype sounds OK, but personally I 
> dislike use of negation operator. For my eyes (foo = 0) / (foo == false) 
> is better and I have changed all the time negate operators to equal 
> operators from my drivers.

The usage of the negation operator on such tests is there since
the beginning of C.

By being shorter, a reviewer can read it faster and, at least for
me, it is a non-brain to understand !foo. On the other hand,
"false" is not part of standard C. So, it takes more time for my
brain to parse it.

Anyway, from my side, the real reasone for using it is not due to
that. It is that I (and other Kernel developers) run from time to
time static analyzers like smatch and coccinelle, in order to identify
real errors. Having a less-polluted log helps to identify the newer
errors/warnings.

Regards,
Mauro
> 
> regards
> Antti
> 
> On 09/03/2014 11:33 PM, Mauro Carvalho Chehab wrote:
> > Instead of using if (foo == false), just use
> > if (!foo).
> >
> > That allows a faster mental parsing when analyzing the
> > code.
> >
> > Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> >
> > diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
> > index 90d93348f20c..cd9cf643f602 100644
> > --- a/drivers/media/tuners/e4000.c
> > +++ b/drivers/media/tuners/e4000.c
> > @@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
> >   	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
> >   	int ret;
> >
> > -	if (s->active == false)
> > +	if (!s->active)
> >   		return 0;
> >
> >   	switch (ctrl->id) {
> > @@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
> >   	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
> >   	int ret;
> >
> > -	if (s->active == false)
> > +	if (!s->active)
> >   		return 0;
> >
> >   	switch (ctrl->id) {
> >
> 

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 32/46] [media] e4000: simplify boolean tests
  2014-09-04  1:12     ` Mauro Carvalho Chehab
@ 2014-09-04  1:27       ` Antti Palosaari
  2014-09-04  2:30         ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 64+ messages in thread
From: Antti Palosaari @ 2014-09-04  1:27 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab



On 09/04/2014 04:12 AM, Mauro Carvalho Chehab wrote:
> Em Thu, 04 Sep 2014 02:56:19 +0300
> Antti Palosaari <crope@iki.fi> escreveu:
>
>> Which is static analyzer you are referring to fix these?
>
> Coccinelle. See: scripts/coccinelle/misc/boolinit.cocci
>
>> Using true/false for boolean datatype sounds OK, but personally I
>> dislike use of negation operator. For my eyes (foo = 0) / (foo == false)
>> is better and I have changed all the time negate operators to equal
>> operators from my drivers.
>
> The usage of the negation operator on such tests is there since
> the beginning of C.

ugh! :(

>
> By being shorter, a reviewer can read it faster and, at least for
> me, it is a non-brain to understand !foo. On the other hand,
> "false" is not part of standard C. So, it takes more time for my
> brain to parse it.

No, it just opposite for me and many others.

>
> Anyway, from my side, the real reasone for using it is not due to
> that. It is that I (and other Kernel developers) run from time to
> time static analyzers like smatch and coccinelle, in order to identify
> real errors. Having a less-polluted log helps to identify the newer
> errors/warnings.

Have you ever looked Documentation/CodingStyle ?
How about that example, from CodingStyle:
int fun(int a)
{
	int result = 0;
	char *buffer = kmalloc(SIZE);

	if (buffer == NULL)
		return -ENOMEM;

	if (condition1) {
		while (loop1) {
			...
		}
		result = 1;
		goto out;
	}
	...
out:
	kfree(buffer);
	return result;
}

As it shows, it is (buffer == NULL) *not* (!buffer). And if you like to 
do it differently then update CodingStyle first! Add clear mention that 
it should be (!buffer) and change given example to match your style. 
Otherwise, I am happy to do as CodingStyle shows!

Antti

>
> Regards,
> Mauro
>>
>> regards
>> Antti
>>
>> On 09/03/2014 11:33 PM, Mauro Carvalho Chehab wrote:
>>> Instead of using if (foo == false), just use
>>> if (!foo).
>>>
>>> That allows a faster mental parsing when analyzing the
>>> code.
>>>
>>> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
>>>
>>> diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
>>> index 90d93348f20c..cd9cf643f602 100644
>>> --- a/drivers/media/tuners/e4000.c
>>> +++ b/drivers/media/tuners/e4000.c
>>> @@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
>>>    	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
>>>    	int ret;
>>>
>>> -	if (s->active == false)
>>> +	if (!s->active)
>>>    		return 0;
>>>
>>>    	switch (ctrl->id) {
>>> @@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
>>>    	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
>>>    	int ret;
>>>
>>> -	if (s->active == false)
>>> +	if (!s->active)
>>>    		return 0;
>>>
>>>    	switch (ctrl->id) {
>>>
>>

-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 32/46] [media] e4000: simplify boolean tests
  2014-09-04  1:27       ` Antti Palosaari
@ 2014-09-04  2:30         ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-04  2:30 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Em Thu, 04 Sep 2014 04:27:57 +0300
Antti Palosaari <crope@iki.fi> escreveu:

> > By being shorter, a reviewer can read it faster and, at least for
> > me, it is a non-brain to understand !foo. On the other hand,
> > "false" is not part of standard C. So, it takes more time for my
> > brain to parse it.
> 
> No, it just opposite for me and many others.

Yeah, this is subjective, so different people have different views.

Yet, if you take a look on the numbers inside the Kernel, this
is what we have:

$ git grep "== false" |wc -l
622
$ git grep "false ==" |wc -l
41
$ git grep 'if (!' |wc -l
153125

Being 249 occurrences inside Documentation:

$ git grep 'if (!' |grep Docum|wc -l
249

$ git grep "false ==" |grep Docum |wc -l
0
$ git grep "== false" |grep Docum |wc -l
1

Where the only Documentation with == false is this one (at
Documentation/thermal/sysfs-api.txt):
    .no_hwmon: a boolean to indicate if the thermal to hwmon sysfs interface
               is required. when no_hwmon == false, a hwmon sysfs interface
               will be created. when no_hwmon == true, nothing will be done.
               In case the thermal_zone_params is NULL, the hwmon interface
               will be created (for backward compatibility).

Yet, at the only place where this is tested, the syntax is !foo:

drivers/thermal/thermal_core.c: if (!tz->tzp || !tz->tzp->no_hwmon) {

So, clearly, the vast majority of Kernel developers are using !foo.

> > Anyway, from my side, the real reasone for using it is not due to
> > that. It is that I (and other Kernel developers) run from time to
> > time static analyzers like smatch and coccinelle, in order to identify
> > real errors. Having a less-polluted log helps to identify the newer
> > errors/warnings.
> 
> Have you ever looked Documentation/CodingStyle ?
> How about that example, from CodingStyle:
> int fun(int a)
> {
> 	int result = 0;
> 	char *buffer = kmalloc(SIZE);
> 
> 	if (buffer == NULL)
> 		return -ENOMEM;

Well, buffer is not a boolean operator.

I would code myself with if (!buffer), but I accept patches with both ways,
and I've seen a mix of both usages inside the Kernel.

> 
> 	if (condition1) {
> 		while (loop1) {
> 			...
> 		}
> 		result = 1;
> 		goto out;
> 	}
> 	...
> out:
> 	kfree(buffer);
> 	return result;
> }
> 
> As it shows, it is (buffer == NULL) *not* (!buffer). And if you like to 
> do it differently then update CodingStyle first! Add clear mention that 
> it should be (!buffer) and change given example to match your style. 
> Otherwise, I am happy to do as CodingStyle shows!

It is not me opting for it. Someone's else added the coccinelle patch
upstream, and it got at least 2 different reviewers besides its author:

commit 8991058171f3536c0a8fbb50ad311689b8b74979
Author: Julia Lawall <Julia.Lawall@lip6.fr>
Date:   Fri Feb 10 22:05:18 2012 +0100

    coccinelle: semantic patch for bool issues
    
    Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
    Reviewed-by: Rusty Russell <rusty@rustcorp.com.au>
    Signed-off-by: Michal Marek <mmarek@suse.cz>


Anyway, as I said, my main interest is to just shut up the in-Kernel
tests, as this helps to better identify real problems.

I don't care if this is done by someone sending a patch to remove
or modify the coccinelle script to accept both ways or to use the
approach taken by this patch.


> 
> Antti
> 
> >
> > Regards,
> > Mauro
> >>
> >> regards
> >> Antti
> >>
> >> On 09/03/2014 11:33 PM, Mauro Carvalho Chehab wrote:
> >>> Instead of using if (foo == false), just use
> >>> if (!foo).
> >>>
> >>> That allows a faster mental parsing when analyzing the
> >>> code.
> >>>
> >>> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> >>>
> >>> diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
> >>> index 90d93348f20c..cd9cf643f602 100644
> >>> --- a/drivers/media/tuners/e4000.c
> >>> +++ b/drivers/media/tuners/e4000.c
> >>> @@ -400,7 +400,7 @@ static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
> >>>    	struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
> >>>    	int ret;
> >>>
> >>> -	if (s->active == false)
> >>> +	if (!s->active)
> >>>    		return 0;
> >>>
> >>>    	switch (ctrl->id) {
> >>> @@ -423,7 +423,7 @@ static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
> >>>    	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
> >>>    	int ret;
> >>>
> >>> -	if (s->active == false)
> >>> +	if (!s->active)
> >>>    		return 0;
> >>>
> >>>    	switch (ctrl->id) {
> >>>
> >>
> 

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 16/46] [media] smiapp-core: use true/false for boolean vars
  2014-09-03 20:32 ` [PATCH 16/46] [media] smiapp-core: " Mauro Carvalho Chehab
@ 2014-09-04  7:03   ` Sakari Ailus
  2014-09-04 12:58     ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 64+ messages in thread
From: Sakari Ailus @ 2014-09-04  7:03 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

On Wed, Sep 03, 2014 at 05:32:48PM -0300, Mauro Carvalho Chehab wrote:
> Instead of using 0 or 1 for boolean, use the true/false
> defines.
> 
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

Thanks!

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

Would you like me to pick this patch to my tree, or would you like to apply
it directly? I'm fine with either.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 28/46] [media] lm3560: simplify boolean tests
  2014-09-03 20:33 ` [PATCH 28/46] [media] lm3560: simplify boolean tests Mauro Carvalho Chehab
@ 2014-09-04  7:08   ` Sakari Ailus
  2014-09-05  5:30     ` Daniel Jeong
  0 siblings, 1 reply; 64+ messages in thread
From: Sakari Ailus @ 2014-09-04  7:08 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Linux Media Mailing List, Mauro Carvalho Chehab, Andy Shevchenko,
	Wei Yongjun, Daniel Jeong

On Wed, Sep 03, 2014 at 05:33:00PM -0300, Mauro Carvalho Chehab wrote:
> Instead of using if (on == true), just use
> if (on).
> 
> That allows a faster mental parsing when analyzing the
> code.
> 
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 16/46] [media] smiapp-core: use true/false for boolean vars
  2014-09-04  7:03   ` Sakari Ailus
@ 2014-09-04 12:58     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 64+ messages in thread
From: Mauro Carvalho Chehab @ 2014-09-04 12:58 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Em Thu, 04 Sep 2014 10:03:40 +0300
Sakari Ailus <sakari.ailus@iki.fi> escreveu:

> On Wed, Sep 03, 2014 at 05:32:48PM -0300, Mauro Carvalho Chehab wrote:
> > Instead of using 0 or 1 for boolean, use the true/false
> > defines.
> > 
> > Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> 
> Thanks!
> 
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> 
> Would you like me to pick this patch to my tree, or would you like to apply
> it directly? I'm fine with either.

I'll pick it myself.

Regards,
Mauro

^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 18/46] [media] omap3isp: use true/false for boolean vars
  2014-09-03 20:32 ` [PATCH 18/46] [media] omap3isp: " Mauro Carvalho Chehab
@ 2014-09-04 20:24   ` Laurent Pinchart
  0 siblings, 0 replies; 64+ messages in thread
From: Laurent Pinchart @ 2014-09-04 20:24 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab

Hi Mauro,

Thank you for the patch.

On Wednesday 03 September 2014 17:32:50 Mauro Carvalho Chehab wrote:
> Instead of using 0 or 1 for boolean, use the true/false
> defines.
> 
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> diff --git a/drivers/media/platform/omap3isp/ispccdc.c
> b/drivers/media/platform/omap3isp/ispccdc.c index
> cabf46b4b645..81a9dc053d58 100644
> --- a/drivers/media/platform/omap3isp/ispccdc.c
> +++ b/drivers/media/platform/omap3isp/ispccdc.c
> @@ -1806,7 +1806,7 @@ static int ccdc_video_queue(struct isp_video *video,
> struct isp_buffer *buffer) spin_lock_irqsave(&ccdc->lock, flags);
>  	if (ccdc->state == ISP_PIPELINE_STREAM_CONTINUOUS && !ccdc->running &&
>  	    ccdc->bt656)
> -		restart = 1;
> +		restart = true;
>  	else
>  		ccdc->underrun = 1;
>  	spin_unlock_irqrestore(&ccdc->lock, flags);

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 64+ messages in thread

* Re: [PATCH 28/46] [media] lm3560: simplify boolean tests
  2014-09-04  7:08   ` Sakari Ailus
@ 2014-09-05  5:30     ` Daniel Jeong
  0 siblings, 0 replies; 64+ messages in thread
From: Daniel Jeong @ 2014-09-05  5:30 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List,
	Mauro Carvalho Chehab, Andy Shevchenko, Wei Yongjun

Hi.

> On Wed, Sep 03, 2014 at 05:33:00PM -0300, Mauro Carvalho Chehab wrote:
>> Instead of using if (on == true), just use
>> if (on).
>>
>> That allows a faster mental parsing when analyzing the
>> code.
>>
>> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>
I will keep it in my mind for my next patch files.

Thank you.

Acked-by: Daniel Jeong <gshark.jeong@gmail.com>


^ permalink raw reply	[flat|nested] 64+ messages in thread

end of thread, other threads:[~2014-09-05  5:30 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-03 20:27 [PATCH 00/46] Several static analizer fixes Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 01/46] [media] dmxdev: don't use before checking file->private_data Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 02/46] [media] marvel-ccic: don't initialize static vars with 0 Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 03/46] [media] soc_camera: use kmemdup() Mauro Carvalho Chehab
2014-09-03 20:44   ` Guennadi Liakhovetski
2014-09-03 20:54     ` Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 04/46] [media] vivid-vid-out: use memdup_user() Mauro Carvalho Chehab
2014-09-03 20:49   ` Hans Verkuil
2014-09-03 20:57     ` Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 05/46] [media] s5k5baf: remove an uneeded semicolon Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 06/46] [media] bttv-driver: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 07/46] [media] soc_camera: remove uneeded semicolons Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 08/46] [media] stv0900_core: don't allocate a temporary var Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 09/46] [media] em28xx: use true/false for boolean vars Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 10/46] [media] tuner-core: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 11/46] [media] af9013: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 12/46] [media] cxd2820r: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 13/46] [media] m88ds3103: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 14/46] [media] af9013: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 15/46] [media] tda10071: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 16/46] [media] smiapp-core: " Mauro Carvalho Chehab
2014-09-04  7:03   ` Sakari Ailus
2014-09-04 12:58     ` Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 17/46] [media] ov9740: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 18/46] [media] omap3isp: " Mauro Carvalho Chehab
2014-09-04 20:24   ` Laurent Pinchart
2014-09-03 20:32 ` [PATCH 19/46] [media] ti-vpe: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 20/46] [media] vivid-tpg: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 21/46] [media] radio: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 22/46] [media] ene_ir: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 23/46] [media] au0828-dvb: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 24/46] [media] lmedm04: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 25/46] [media] af9005: " Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 26/46] [media] msi2500: simplify boolean tests Mauro Carvalho Chehab
2014-09-03 20:32 ` [PATCH 27/46] [media] drxk_hard: simplify test logic Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 28/46] [media] lm3560: simplify boolean tests Mauro Carvalho Chehab
2014-09-04  7:08   ` Sakari Ailus
2014-09-05  5:30     ` Daniel Jeong
2014-09-03 20:33 ` [PATCH 29/46] [media] lm3560: simplify a boolean test Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 30/46] [media] omap: simplify test logic Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 31/46] [media] via-camera: simplify boolean tests Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 32/46] [media] e4000: " Mauro Carvalho Chehab
2014-09-03 23:56   ` Antti Palosaari
2014-09-04  1:12     ` Mauro Carvalho Chehab
2014-09-04  1:27       ` Antti Palosaari
2014-09-04  2:30         ` Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 33/46] [media] s5p-tv: Simplify the return logic Mauro Carvalho Chehab
2014-09-03 20:33   ` Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 34/46] [media] siano: just return 0 instead of using a var Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 35/46] [media] stv0367: " Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 36/46] [media] media-devnode: " Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 37/46] [media] bt8xx: " Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 38/46] [media] saa7164: " Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 39/46] [media] davinci: " Mauro Carvalho Chehab
2014-09-03 20:43   ` Prabhakar Lad
2014-09-03 20:33 ` [PATCH 40/46] [media] marvel-ccic: " Mauro Carvalho Chehab
2014-09-03 20:33   ` Mauro Carvalho Chehab
2014-09-03 20:33   ` Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 41/46] [media] fintek-cir: " Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 42/46] [media] ite-cir: " Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 43/46] [media] nuvoton-cir: " Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 44/46] [media] mt2060: " Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 45/46] [media] mxl5005s: " Mauro Carvalho Chehab
2014-09-03 20:33 ` [PATCH 46/46] [media] cx231xx: " Mauro Carvalho Chehab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.