All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
@ 2011-01-25 20:54 ` Peter Huewe
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Huewe @ 2011-01-25 20:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel, kernel-janitors, Steven Toth,
	Tejun Heo, Dan Carpenter, Peter Huewe

This patch fixes the warning "Using plain integer as NULL pointer",
generated by sparse, by replacing the offending 0s with NULL.

KernelVersion: linus' tree-c723fdab

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/media/video/saa7164/saa7164-api.c     |    8 ++++----
 drivers/media/video/saa7164/saa7164-buffer.c  |   14 +++++++-------
 drivers/media/video/saa7164/saa7164-bus.c     |    8 ++++----
 drivers/media/video/saa7164/saa7164-cmd.c     |   10 +++++-----
 drivers/media/video/saa7164/saa7164-core.c    |    8 ++++----
 drivers/media/video/saa7164/saa7164-dvb.c     |    4 ++--
 drivers/media/video/saa7164/saa7164-encoder.c |    6 +++---
 drivers/media/video/saa7164/saa7164-fw.c      |    2 +-
 drivers/media/video/saa7164/saa7164-vbi.c     |    6 +++---
 9 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c
index bd86d97..c49dcad 100644
--- a/drivers/media/video/saa7164/saa7164-api.c
+++ b/drivers/media/video/saa7164/saa7164-api.c
@@ -743,7 +743,7 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
 int saa7164_api_initialize_dif(struct saa7164_port *port)
 {
 	struct saa7164_dev *dev = port->dev;
-	struct saa7164_port *p = 0;
+	struct saa7164_port *p = NULL;
 	int ret = -EINVAL;
 	u32 std = 0;
 
@@ -926,9 +926,9 @@ int saa7164_api_configure_port_mpeg2ps(struct saa7164_dev *dev,
 
 int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
 {
-	struct saa7164_port *tsport = 0;
-	struct saa7164_port *encport = 0;
-	struct saa7164_port *vbiport = 0;
+	struct saa7164_port *tsport = NULL;
+	struct saa7164_port *encport = NULL;
+	struct saa7164_port *vbiport = NULL;
 	u32 idx, next_offset;
 	int i;
 	struct tmComResDescrHeader *hdr, *t;
diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c
index ddd2521..977062f 100644
--- a/drivers/media/video/saa7164/saa7164-buffer.c
+++ b/drivers/media/video/saa7164/saa7164-buffer.c
@@ -93,7 +93,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
 	u32 len)
 {
 	struct tmHWStreamParameters *params = &port->hw_streamingparams;
-	struct saa7164_buffer *buf = 0;
+	struct saa7164_buffer *buf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	int i;
 
@@ -157,7 +157,7 @@ fail2:
 fail1:
 	kfree(buf);
 
-	buf = 0;
+	buf = NULL;
 ret:
 	return buf;
 }
@@ -289,14 +289,14 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
 	struct saa7164_user_buffer *buf;
 
 	buf = kzalloc(sizeof(struct saa7164_user_buffer), GFP_KERNEL);
-	if (buf == 0)
-		return 0;
+	if (buf == NULL)
+		return NULL;
 
 	buf->data = kzalloc(len, GFP_KERNEL);
 
-	if (buf->data == 0) {
+	if (buf->data == NULL) {
 		kfree(buf);
-		return 0;
+		return NULL;
 	}
 
 	buf->actual_size = len;
@@ -315,7 +315,7 @@ void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf)
 		return;
 
 	kfree(buf->data);
-	buf->data = 0;
+	buf->data = NULL;
 
 	kfree(buf);
 }
diff --git a/drivers/media/video/saa7164/saa7164-bus.c b/drivers/media/video/saa7164/saa7164-bus.c
index b2b0d97..466e1b0 100644
--- a/drivers/media/video/saa7164/saa7164-bus.c
+++ b/drivers/media/video/saa7164/saa7164-bus.c
@@ -158,7 +158,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg,
 		return SAA_ERR_BAD_PARAMETER;
 	}
 
-	if ((msg->size > 0) && (buf == 0)) {
+	if ((msg->size > 0) && (buf == NULL)) {
 		printk(KERN_ERR "%s() Missing message buffer\n", __func__);
 		return SAA_ERR_BAD_PARAMETER;
 	}
@@ -315,7 +315,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 
 	saa7164_bus_verify(dev);
 
-	if (msg == 0)
+	if (msg == NULL)
 		return ret;
 
 	if (msg->size > dev->bus.m_wMaxReqSize) {
@@ -324,7 +324,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 		return ret;
 	}
 
-	if ((peekonly == 0) && (msg->size > 0) && (buf == 0)) {
+	if ((peekonly == 0) && (msg->size > 0) && (buf == NULL)) {
 		printk(KERN_ERR
 			"%s() Missing msg buf, size should be %d bytes\n",
 			__func__, msg->size);
@@ -392,7 +392,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 
 		printk(KERN_ERR "%s() Unexpected msg miss-match\n", __func__);
 		saa7164_bus_dumpmsg(dev, msg, buf);
-		saa7164_bus_dumpmsg(dev, &msg_tmp, 0);
+		saa7164_bus_dumpmsg(dev, &msg_tmp, NULL);
 		ret = SAA_ERR_INVALID_COMMAND;
 		goto out;
 	}
diff --git a/drivers/media/video/saa7164/saa7164-cmd.c b/drivers/media/video/saa7164/saa7164-cmd.c
index a97ae17..6a4c217 100644
--- a/drivers/media/video/saa7164/saa7164-cmd.c
+++ b/drivers/media/video/saa7164/saa7164-cmd.c
@@ -84,7 +84,7 @@ int saa7164_irq_dequeue(struct saa7164_dev *dev)
 {
 	int ret = SAA_OK, i = 0;
 	u32 timeout;
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	u8 tmp[512];
 	dprintk(DBGLVL_CMD, "%s()\n", __func__);
 
@@ -137,7 +137,7 @@ int saa7164_cmd_dequeue(struct saa7164_dev *dev)
 	int loop = 1;
 	int ret;
 	u32 timeout;
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	u8 tmp[512];
 	dprintk(DBGLVL_CMD, "%s()\n", __func__);
 
@@ -261,7 +261,7 @@ out:
  */
 int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
 {
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	int ret = SAA_BUS_TIMEOUT;
 	unsigned long stamp;
 	int r;
@@ -357,7 +357,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
 		"sel = 0x%x)\n", __func__, saa7164_unitid_name(dev, id), id,
 		command, controlselector);
 
-	if ((size == 0) || (buf == 0)) {
+	if ((size == 0) || (buf == NULL)) {
 		printk(KERN_ERR "%s() Invalid param\n", __func__);
 		return SAA_ERR_BAD_PARAMETER;
 	}
@@ -538,7 +538,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
 
 			/* Invalid */
 			dprintk(DBGLVL_CMD, "%s() Invalid\n", __func__);
-			ret = saa7164_bus_get(dev, presponse_t, 0, 0);
+			ret = saa7164_bus_get(dev, presponse_t, NULL, 0);
 			if (ret != SAA_OK) {
 				printk(KERN_ERR "get failed\n");
 				return ret;
diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c
index 58af67f..b813aec 100644
--- a/drivers/media/video/saa7164/saa7164-core.c
+++ b/drivers/media/video/saa7164/saa7164-core.c
@@ -277,8 +277,8 @@ static void saa7164_histogram_print(struct saa7164_port *port,
 static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr)
 {
 	struct saa7164_dev *dev = port->dev;
-	struct saa7164_buffer *buf = 0;
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_buffer *buf = NULL;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct list_head *c, *n;
 	int i = 0;
 	u8 __iomem *p;
@@ -649,7 +649,7 @@ static irqreturn_t saa7164_irq(int irq, void *dev_id)
 	u32 intid, intstat[INT_SIZE/4];
 	int i, handled = 0, bit;
 
-	if (dev == 0) {
+	if (dev == NULL) {
 		printk(KERN_ERR "%s() No device specified\n", __func__);
 		handled = 0;
 		goto out;
@@ -945,7 +945,7 @@ static int get_resources(struct saa7164_dev *dev)
 
 static int saa7164_port_init(struct saa7164_dev *dev, int portnr)
 {
-	struct saa7164_port *port = 0;
+	struct saa7164_port *port = NULL;
 
 	if ((portnr < 0) || (portnr >= SAA7164_MAX_PORTS))
 		BUG();
diff --git a/drivers/media/video/saa7164/saa7164-dvb.c b/drivers/media/video/saa7164/saa7164-dvb.c
index b305a01..f65eab6 100644
--- a/drivers/media/video/saa7164/saa7164-dvb.c
+++ b/drivers/media/video/saa7164/saa7164-dvb.c
@@ -309,8 +309,8 @@ static int dvb_register(struct saa7164_port *port)
 
 	port->hw_streamingparams.pitch = 188;
 	port->hw_streamingparams.linethreshold = 0;
-	port->hw_streamingparams.pagetablelistvirt = 0;
-	port->hw_streamingparams.pagetablelistphys = 0;
+	port->hw_streamingparams.pagetablelistvirt = NULL;
+	port->hw_streamingparams.pagetablelistphys = NULL;
 	port->hw_streamingparams.numpagetables = 2 +
 		((SAA7164_TS_NUMBER_OF_LINES * 188) / PAGE_SIZE);
 
diff --git a/drivers/media/video/saa7164/saa7164-encoder.c b/drivers/media/video/saa7164/saa7164-encoder.c
index 1838408..560a107 100644
--- a/drivers/media/video/saa7164/saa7164-encoder.c
+++ b/drivers/media/video/saa7164/saa7164-encoder.c
@@ -152,8 +152,8 @@ static int saa7164_encoder_buffers_alloc(struct saa7164_port *port)
 	/* Init and establish defaults */
 	params->bitspersample = 8;
 	params->linethreshold = 0;
-	params->pagetablelistvirt = 0;
-	params->pagetablelistphys = 0;
+	params->pagetablelistvirt = NULL;
+	params->pagetablelistphys = NULL;
 	params->numpagetableentries = port->hwcfg.buffercount;
 
 	/* Allocate the PCI resources, buffers (hard) */
@@ -1108,7 +1108,7 @@ static int fops_release(struct file *file)
 
 struct saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port)
 {
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	u32 crc;
 
diff --git a/drivers/media/video/saa7164/saa7164-fw.c b/drivers/media/video/saa7164/saa7164-fw.c
index ebed6f7..b369300 100644
--- a/drivers/media/video/saa7164/saa7164-fw.c
+++ b/drivers/media/video/saa7164/saa7164-fw.c
@@ -88,7 +88,7 @@ int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize,
 		"%s(image=%p, size=%d, flags=0x%x, dst=%p, dstsize=0x%x)\n",
 		__func__, src, srcsize, dlflags, dst, dstsize);
 
-	if ((src == 0) || (dst == 0)) {
+	if ((src == NULL) || (dst == NULL)) {
 		ret = -EIO;
 		goto out;
 	}
diff --git a/drivers/media/video/saa7164/saa7164-vbi.c b/drivers/media/video/saa7164/saa7164-vbi.c
index 8abbe6d..a659d3c 100644
--- a/drivers/media/video/saa7164/saa7164-vbi.c
+++ b/drivers/media/video/saa7164/saa7164-vbi.c
@@ -123,8 +123,8 @@ static int saa7164_vbi_buffers_alloc(struct saa7164_port *port)
 		((params->numberoflines * params->pitch) / PAGE_SIZE);
 	params->bitspersample = 8;
 	params->linethreshold = 0;
-	params->pagetablelistvirt = 0;
-	params->pagetablelistphys = 0;
+	params->pagetablelistvirt = NULL;
+	params->pagetablelistphys = NULL;
 	params->numpagetableentries = port->hwcfg.buffercount;
 
 	/* Allocate the PCI resources, buffers (hard) */
@@ -1054,7 +1054,7 @@ static int fops_release(struct file *file)
 
 struct saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port)
 {
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	u32 crc;
 
-- 
1.7.2.2


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

* [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
@ 2011-01-25 20:54 ` Peter Huewe
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Huewe @ 2011-01-25 20:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-media, linux-kernel, kernel-janitors, Steven Toth,
	Tejun Heo, Dan Carpenter, Peter Huewe

This patch fixes the warning "Using plain integer as NULL pointer",
generated by sparse, by replacing the offending 0s with NULL.

KernelVersion: linus' tree-c723fdab

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/media/video/saa7164/saa7164-api.c     |    8 ++++----
 drivers/media/video/saa7164/saa7164-buffer.c  |   14 +++++++-------
 drivers/media/video/saa7164/saa7164-bus.c     |    8 ++++----
 drivers/media/video/saa7164/saa7164-cmd.c     |   10 +++++-----
 drivers/media/video/saa7164/saa7164-core.c    |    8 ++++----
 drivers/media/video/saa7164/saa7164-dvb.c     |    4 ++--
 drivers/media/video/saa7164/saa7164-encoder.c |    6 +++---
 drivers/media/video/saa7164/saa7164-fw.c      |    2 +-
 drivers/media/video/saa7164/saa7164-vbi.c     |    6 +++---
 9 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c
index bd86d97..c49dcad 100644
--- a/drivers/media/video/saa7164/saa7164-api.c
+++ b/drivers/media/video/saa7164/saa7164-api.c
@@ -743,7 +743,7 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
 int saa7164_api_initialize_dif(struct saa7164_port *port)
 {
 	struct saa7164_dev *dev = port->dev;
-	struct saa7164_port *p = 0;
+	struct saa7164_port *p = NULL;
 	int ret = -EINVAL;
 	u32 std = 0;
 
@@ -926,9 +926,9 @@ int saa7164_api_configure_port_mpeg2ps(struct saa7164_dev *dev,
 
 int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
 {
-	struct saa7164_port *tsport = 0;
-	struct saa7164_port *encport = 0;
-	struct saa7164_port *vbiport = 0;
+	struct saa7164_port *tsport = NULL;
+	struct saa7164_port *encport = NULL;
+	struct saa7164_port *vbiport = NULL;
 	u32 idx, next_offset;
 	int i;
 	struct tmComResDescrHeader *hdr, *t;
diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c
index ddd2521..977062f 100644
--- a/drivers/media/video/saa7164/saa7164-buffer.c
+++ b/drivers/media/video/saa7164/saa7164-buffer.c
@@ -93,7 +93,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
 	u32 len)
 {
 	struct tmHWStreamParameters *params = &port->hw_streamingparams;
-	struct saa7164_buffer *buf = 0;
+	struct saa7164_buffer *buf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	int i;
 
@@ -157,7 +157,7 @@ fail2:
 fail1:
 	kfree(buf);
 
-	buf = 0;
+	buf = NULL;
 ret:
 	return buf;
 }
@@ -289,14 +289,14 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
 	struct saa7164_user_buffer *buf;
 
 	buf = kzalloc(sizeof(struct saa7164_user_buffer), GFP_KERNEL);
-	if (buf = 0)
-		return 0;
+	if (buf = NULL)
+		return NULL;
 
 	buf->data = kzalloc(len, GFP_KERNEL);
 
-	if (buf->data = 0) {
+	if (buf->data = NULL) {
 		kfree(buf);
-		return 0;
+		return NULL;
 	}
 
 	buf->actual_size = len;
@@ -315,7 +315,7 @@ void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf)
 		return;
 
 	kfree(buf->data);
-	buf->data = 0;
+	buf->data = NULL;
 
 	kfree(buf);
 }
diff --git a/drivers/media/video/saa7164/saa7164-bus.c b/drivers/media/video/saa7164/saa7164-bus.c
index b2b0d97..466e1b0 100644
--- a/drivers/media/video/saa7164/saa7164-bus.c
+++ b/drivers/media/video/saa7164/saa7164-bus.c
@@ -158,7 +158,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg,
 		return SAA_ERR_BAD_PARAMETER;
 	}
 
-	if ((msg->size > 0) && (buf = 0)) {
+	if ((msg->size > 0) && (buf = NULL)) {
 		printk(KERN_ERR "%s() Missing message buffer\n", __func__);
 		return SAA_ERR_BAD_PARAMETER;
 	}
@@ -315,7 +315,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 
 	saa7164_bus_verify(dev);
 
-	if (msg = 0)
+	if (msg = NULL)
 		return ret;
 
 	if (msg->size > dev->bus.m_wMaxReqSize) {
@@ -324,7 +324,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 		return ret;
 	}
 
-	if ((peekonly = 0) && (msg->size > 0) && (buf = 0)) {
+	if ((peekonly = 0) && (msg->size > 0) && (buf = NULL)) {
 		printk(KERN_ERR
 			"%s() Missing msg buf, size should be %d bytes\n",
 			__func__, msg->size);
@@ -392,7 +392,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 
 		printk(KERN_ERR "%s() Unexpected msg miss-match\n", __func__);
 		saa7164_bus_dumpmsg(dev, msg, buf);
-		saa7164_bus_dumpmsg(dev, &msg_tmp, 0);
+		saa7164_bus_dumpmsg(dev, &msg_tmp, NULL);
 		ret = SAA_ERR_INVALID_COMMAND;
 		goto out;
 	}
diff --git a/drivers/media/video/saa7164/saa7164-cmd.c b/drivers/media/video/saa7164/saa7164-cmd.c
index a97ae17..6a4c217 100644
--- a/drivers/media/video/saa7164/saa7164-cmd.c
+++ b/drivers/media/video/saa7164/saa7164-cmd.c
@@ -84,7 +84,7 @@ int saa7164_irq_dequeue(struct saa7164_dev *dev)
 {
 	int ret = SAA_OK, i = 0;
 	u32 timeout;
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	u8 tmp[512];
 	dprintk(DBGLVL_CMD, "%s()\n", __func__);
 
@@ -137,7 +137,7 @@ int saa7164_cmd_dequeue(struct saa7164_dev *dev)
 	int loop = 1;
 	int ret;
 	u32 timeout;
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	u8 tmp[512];
 	dprintk(DBGLVL_CMD, "%s()\n", __func__);
 
@@ -261,7 +261,7 @@ out:
  */
 int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
 {
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	int ret = SAA_BUS_TIMEOUT;
 	unsigned long stamp;
 	int r;
@@ -357,7 +357,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
 		"sel = 0x%x)\n", __func__, saa7164_unitid_name(dev, id), id,
 		command, controlselector);
 
-	if ((size = 0) || (buf = 0)) {
+	if ((size = 0) || (buf = NULL)) {
 		printk(KERN_ERR "%s() Invalid param\n", __func__);
 		return SAA_ERR_BAD_PARAMETER;
 	}
@@ -538,7 +538,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
 
 			/* Invalid */
 			dprintk(DBGLVL_CMD, "%s() Invalid\n", __func__);
-			ret = saa7164_bus_get(dev, presponse_t, 0, 0);
+			ret = saa7164_bus_get(dev, presponse_t, NULL, 0);
 			if (ret != SAA_OK) {
 				printk(KERN_ERR "get failed\n");
 				return ret;
diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c
index 58af67f..b813aec 100644
--- a/drivers/media/video/saa7164/saa7164-core.c
+++ b/drivers/media/video/saa7164/saa7164-core.c
@@ -277,8 +277,8 @@ static void saa7164_histogram_print(struct saa7164_port *port,
 static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr)
 {
 	struct saa7164_dev *dev = port->dev;
-	struct saa7164_buffer *buf = 0;
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_buffer *buf = NULL;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct list_head *c, *n;
 	int i = 0;
 	u8 __iomem *p;
@@ -649,7 +649,7 @@ static irqreturn_t saa7164_irq(int irq, void *dev_id)
 	u32 intid, intstat[INT_SIZE/4];
 	int i, handled = 0, bit;
 
-	if (dev = 0) {
+	if (dev = NULL) {
 		printk(KERN_ERR "%s() No device specified\n", __func__);
 		handled = 0;
 		goto out;
@@ -945,7 +945,7 @@ static int get_resources(struct saa7164_dev *dev)
 
 static int saa7164_port_init(struct saa7164_dev *dev, int portnr)
 {
-	struct saa7164_port *port = 0;
+	struct saa7164_port *port = NULL;
 
 	if ((portnr < 0) || (portnr >= SAA7164_MAX_PORTS))
 		BUG();
diff --git a/drivers/media/video/saa7164/saa7164-dvb.c b/drivers/media/video/saa7164/saa7164-dvb.c
index b305a01..f65eab6 100644
--- a/drivers/media/video/saa7164/saa7164-dvb.c
+++ b/drivers/media/video/saa7164/saa7164-dvb.c
@@ -309,8 +309,8 @@ static int dvb_register(struct saa7164_port *port)
 
 	port->hw_streamingparams.pitch = 188;
 	port->hw_streamingparams.linethreshold = 0;
-	port->hw_streamingparams.pagetablelistvirt = 0;
-	port->hw_streamingparams.pagetablelistphys = 0;
+	port->hw_streamingparams.pagetablelistvirt = NULL;
+	port->hw_streamingparams.pagetablelistphys = NULL;
 	port->hw_streamingparams.numpagetables = 2 +
 		((SAA7164_TS_NUMBER_OF_LINES * 188) / PAGE_SIZE);
 
diff --git a/drivers/media/video/saa7164/saa7164-encoder.c b/drivers/media/video/saa7164/saa7164-encoder.c
index 1838408..560a107 100644
--- a/drivers/media/video/saa7164/saa7164-encoder.c
+++ b/drivers/media/video/saa7164/saa7164-encoder.c
@@ -152,8 +152,8 @@ static int saa7164_encoder_buffers_alloc(struct saa7164_port *port)
 	/* Init and establish defaults */
 	params->bitspersample = 8;
 	params->linethreshold = 0;
-	params->pagetablelistvirt = 0;
-	params->pagetablelistphys = 0;
+	params->pagetablelistvirt = NULL;
+	params->pagetablelistphys = NULL;
 	params->numpagetableentries = port->hwcfg.buffercount;
 
 	/* Allocate the PCI resources, buffers (hard) */
@@ -1108,7 +1108,7 @@ static int fops_release(struct file *file)
 
 struct saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port)
 {
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	u32 crc;
 
diff --git a/drivers/media/video/saa7164/saa7164-fw.c b/drivers/media/video/saa7164/saa7164-fw.c
index ebed6f7..b369300 100644
--- a/drivers/media/video/saa7164/saa7164-fw.c
+++ b/drivers/media/video/saa7164/saa7164-fw.c
@@ -88,7 +88,7 @@ int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize,
 		"%s(image=%p, size=%d, flags=0x%x, dst=%p, dstsize=0x%x)\n",
 		__func__, src, srcsize, dlflags, dst, dstsize);
 
-	if ((src = 0) || (dst = 0)) {
+	if ((src = NULL) || (dst = NULL)) {
 		ret = -EIO;
 		goto out;
 	}
diff --git a/drivers/media/video/saa7164/saa7164-vbi.c b/drivers/media/video/saa7164/saa7164-vbi.c
index 8abbe6d..a659d3c 100644
--- a/drivers/media/video/saa7164/saa7164-vbi.c
+++ b/drivers/media/video/saa7164/saa7164-vbi.c
@@ -123,8 +123,8 @@ static int saa7164_vbi_buffers_alloc(struct saa7164_port *port)
 		((params->numberoflines * params->pitch) / PAGE_SIZE);
 	params->bitspersample = 8;
 	params->linethreshold = 0;
-	params->pagetablelistvirt = 0;
-	params->pagetablelistphys = 0;
+	params->pagetablelistvirt = NULL;
+	params->pagetablelistphys = NULL;
 	params->numpagetableentries = port->hwcfg.buffercount;
 
 	/* Allocate the PCI resources, buffers (hard) */
@@ -1054,7 +1054,7 @@ static int fops_release(struct file *file)
 
 struct saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port)
 {
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	u32 crc;
 
-- 
1.7.2.2


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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
  2011-01-25 20:54 ` Peter Huewe
@ 2011-01-25 22:20   ` Julia Lawall
  -1 siblings, 0 replies; 20+ messages in thread
From: Julia Lawall @ 2011-01-25 22:20 UTC (permalink / raw)
  To: Peter Huewe
  Cc: Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

On Tue, 25 Jan 2011, Peter Huewe wrote:

> This patch fixes the warning "Using plain integer as NULL pointer",
> generated by sparse, by replacing the offending 0s with NULL.
I recall (a number of years ago) being told that for things like kmalloc, 
the proper test was !x, not x == NULL.

julia


> KernelVersion: linus' tree-c723fdab
> 
> Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
> ---
>  drivers/media/video/saa7164/saa7164-api.c     |    8 ++++----
>  drivers/media/video/saa7164/saa7164-buffer.c  |   14 +++++++-------
>  drivers/media/video/saa7164/saa7164-bus.c     |    8 ++++----
>  drivers/media/video/saa7164/saa7164-cmd.c     |   10 +++++-----
>  drivers/media/video/saa7164/saa7164-core.c    |    8 ++++----
>  drivers/media/video/saa7164/saa7164-dvb.c     |    4 ++--
>  drivers/media/video/saa7164/saa7164-encoder.c |    6 +++---
>  drivers/media/video/saa7164/saa7164-fw.c      |    2 +-
>  drivers/media/video/saa7164/saa7164-vbi.c     |    6 +++---
>  9 files changed, 33 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c
> index bd86d97..c49dcad 100644
> --- a/drivers/media/video/saa7164/saa7164-api.c
> +++ b/drivers/media/video/saa7164/saa7164-api.c
> @@ -743,7 +743,7 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
>  int saa7164_api_initialize_dif(struct saa7164_port *port)
>  {
>  	struct saa7164_dev *dev = port->dev;
> -	struct saa7164_port *p = 0;
> +	struct saa7164_port *p = NULL;
>  	int ret = -EINVAL;
>  	u32 std = 0;
>  
> @@ -926,9 +926,9 @@ int saa7164_api_configure_port_mpeg2ps(struct saa7164_dev *dev,
>  
>  int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
>  {
> -	struct saa7164_port *tsport = 0;
> -	struct saa7164_port *encport = 0;
> -	struct saa7164_port *vbiport = 0;
> +	struct saa7164_port *tsport = NULL;
> +	struct saa7164_port *encport = NULL;
> +	struct saa7164_port *vbiport = NULL;
>  	u32 idx, next_offset;
>  	int i;
>  	struct tmComResDescrHeader *hdr, *t;
> diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c
> index ddd2521..977062f 100644
> --- a/drivers/media/video/saa7164/saa7164-buffer.c
> +++ b/drivers/media/video/saa7164/saa7164-buffer.c
> @@ -93,7 +93,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
>  	u32 len)
>  {
>  	struct tmHWStreamParameters *params = &port->hw_streamingparams;
> -	struct saa7164_buffer *buf = 0;
> +	struct saa7164_buffer *buf = NULL;
>  	struct saa7164_dev *dev = port->dev;
>  	int i;
>  
> @@ -157,7 +157,7 @@ fail2:
>  fail1:
>  	kfree(buf);
>  
> -	buf = 0;
> +	buf = NULL;
>  ret:
>  	return buf;
>  }
> @@ -289,14 +289,14 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
>  	struct saa7164_user_buffer *buf;
>  
>  	buf = kzalloc(sizeof(struct saa7164_user_buffer), GFP_KERNEL);
> -	if (buf == 0)
> -		return 0;
> +	if (buf == NULL)
> +		return NULL;
>  
>  	buf->data = kzalloc(len, GFP_KERNEL);
>  
> -	if (buf->data == 0) {
> +	if (buf->data == NULL) {
>  		kfree(buf);
> -		return 0;
> +		return NULL;
>  	}
>  
>  	buf->actual_size = len;
> @@ -315,7 +315,7 @@ void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf)
>  		return;
>  
>  	kfree(buf->data);
> -	buf->data = 0;
> +	buf->data = NULL;
>  
>  	kfree(buf);
>  }
> diff --git a/drivers/media/video/saa7164/saa7164-bus.c b/drivers/media/video/saa7164/saa7164-bus.c
> index b2b0d97..466e1b0 100644
> --- a/drivers/media/video/saa7164/saa7164-bus.c
> +++ b/drivers/media/video/saa7164/saa7164-bus.c
> @@ -158,7 +158,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg,
>  		return SAA_ERR_BAD_PARAMETER;
>  	}
>  
> -	if ((msg->size > 0) && (buf == 0)) {
> +	if ((msg->size > 0) && (buf == NULL)) {
>  		printk(KERN_ERR "%s() Missing message buffer\n", __func__);
>  		return SAA_ERR_BAD_PARAMETER;
>  	}
> @@ -315,7 +315,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
>  
>  	saa7164_bus_verify(dev);
>  
> -	if (msg == 0)
> +	if (msg == NULL)
>  		return ret;
>  
>  	if (msg->size > dev->bus.m_wMaxReqSize) {
> @@ -324,7 +324,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
>  		return ret;
>  	}
>  
> -	if ((peekonly == 0) && (msg->size > 0) && (buf == 0)) {
> +	if ((peekonly == 0) && (msg->size > 0) && (buf == NULL)) {
>  		printk(KERN_ERR
>  			"%s() Missing msg buf, size should be %d bytes\n",
>  			__func__, msg->size);
> @@ -392,7 +392,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
>  
>  		printk(KERN_ERR "%s() Unexpected msg miss-match\n", __func__);
>  		saa7164_bus_dumpmsg(dev, msg, buf);
> -		saa7164_bus_dumpmsg(dev, &msg_tmp, 0);
> +		saa7164_bus_dumpmsg(dev, &msg_tmp, NULL);
>  		ret = SAA_ERR_INVALID_COMMAND;
>  		goto out;
>  	}
> diff --git a/drivers/media/video/saa7164/saa7164-cmd.c b/drivers/media/video/saa7164/saa7164-cmd.c
> index a97ae17..6a4c217 100644
> --- a/drivers/media/video/saa7164/saa7164-cmd.c
> +++ b/drivers/media/video/saa7164/saa7164-cmd.c
> @@ -84,7 +84,7 @@ int saa7164_irq_dequeue(struct saa7164_dev *dev)
>  {
>  	int ret = SAA_OK, i = 0;
>  	u32 timeout;
> -	wait_queue_head_t *q = 0;
> +	wait_queue_head_t *q = NULL;
>  	u8 tmp[512];
>  	dprintk(DBGLVL_CMD, "%s()\n", __func__);
>  
> @@ -137,7 +137,7 @@ int saa7164_cmd_dequeue(struct saa7164_dev *dev)
>  	int loop = 1;
>  	int ret;
>  	u32 timeout;
> -	wait_queue_head_t *q = 0;
> +	wait_queue_head_t *q = NULL;
>  	u8 tmp[512];
>  	dprintk(DBGLVL_CMD, "%s()\n", __func__);
>  
> @@ -261,7 +261,7 @@ out:
>   */
>  int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
>  {
> -	wait_queue_head_t *q = 0;
> +	wait_queue_head_t *q = NULL;
>  	int ret = SAA_BUS_TIMEOUT;
>  	unsigned long stamp;
>  	int r;
> @@ -357,7 +357,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
>  		"sel = 0x%x)\n", __func__, saa7164_unitid_name(dev, id), id,
>  		command, controlselector);
>  
> -	if ((size == 0) || (buf == 0)) {
> +	if ((size == 0) || (buf == NULL)) {
>  		printk(KERN_ERR "%s() Invalid param\n", __func__);
>  		return SAA_ERR_BAD_PARAMETER;
>  	}
> @@ -538,7 +538,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
>  
>  			/* Invalid */
>  			dprintk(DBGLVL_CMD, "%s() Invalid\n", __func__);
> -			ret = saa7164_bus_get(dev, presponse_t, 0, 0);
> +			ret = saa7164_bus_get(dev, presponse_t, NULL, 0);
>  			if (ret != SAA_OK) {
>  				printk(KERN_ERR "get failed\n");
>  				return ret;
> diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c
> index 58af67f..b813aec 100644
> --- a/drivers/media/video/saa7164/saa7164-core.c
> +++ b/drivers/media/video/saa7164/saa7164-core.c
> @@ -277,8 +277,8 @@ static void saa7164_histogram_print(struct saa7164_port *port,
>  static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr)
>  {
>  	struct saa7164_dev *dev = port->dev;
> -	struct saa7164_buffer *buf = 0;
> -	struct saa7164_user_buffer *ubuf = 0;
> +	struct saa7164_buffer *buf = NULL;
> +	struct saa7164_user_buffer *ubuf = NULL;
>  	struct list_head *c, *n;
>  	int i = 0;
>  	u8 __iomem *p;
> @@ -649,7 +649,7 @@ static irqreturn_t saa7164_irq(int irq, void *dev_id)
>  	u32 intid, intstat[INT_SIZE/4];
>  	int i, handled = 0, bit;
>  
> -	if (dev == 0) {
> +	if (dev == NULL) {
>  		printk(KERN_ERR "%s() No device specified\n", __func__);
>  		handled = 0;
>  		goto out;
> @@ -945,7 +945,7 @@ static int get_resources(struct saa7164_dev *dev)
>  
>  static int saa7164_port_init(struct saa7164_dev *dev, int portnr)
>  {
> -	struct saa7164_port *port = 0;
> +	struct saa7164_port *port = NULL;
>  
>  	if ((portnr < 0) || (portnr >= SAA7164_MAX_PORTS))
>  		BUG();
> diff --git a/drivers/media/video/saa7164/saa7164-dvb.c b/drivers/media/video/saa7164/saa7164-dvb.c
> index b305a01..f65eab6 100644
> --- a/drivers/media/video/saa7164/saa7164-dvb.c
> +++ b/drivers/media/video/saa7164/saa7164-dvb.c
> @@ -309,8 +309,8 @@ static int dvb_register(struct saa7164_port *port)
>  
>  	port->hw_streamingparams.pitch = 188;
>  	port->hw_streamingparams.linethreshold = 0;
> -	port->hw_streamingparams.pagetablelistvirt = 0;
> -	port->hw_streamingparams.pagetablelistphys = 0;
> +	port->hw_streamingparams.pagetablelistvirt = NULL;
> +	port->hw_streamingparams.pagetablelistphys = NULL;
>  	port->hw_streamingparams.numpagetables = 2 +
>  		((SAA7164_TS_NUMBER_OF_LINES * 188) / PAGE_SIZE);
>  
> diff --git a/drivers/media/video/saa7164/saa7164-encoder.c b/drivers/media/video/saa7164/saa7164-encoder.c
> index 1838408..560a107 100644
> --- a/drivers/media/video/saa7164/saa7164-encoder.c
> +++ b/drivers/media/video/saa7164/saa7164-encoder.c
> @@ -152,8 +152,8 @@ static int saa7164_encoder_buffers_alloc(struct saa7164_port *port)
>  	/* Init and establish defaults */
>  	params->bitspersample = 8;
>  	params->linethreshold = 0;
> -	params->pagetablelistvirt = 0;
> -	params->pagetablelistphys = 0;
> +	params->pagetablelistvirt = NULL;
> +	params->pagetablelistphys = NULL;
>  	params->numpagetableentries = port->hwcfg.buffercount;
>  
>  	/* Allocate the PCI resources, buffers (hard) */
> @@ -1108,7 +1108,7 @@ static int fops_release(struct file *file)
>  
>  struct saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port)
>  {
> -	struct saa7164_user_buffer *ubuf = 0;
> +	struct saa7164_user_buffer *ubuf = NULL;
>  	struct saa7164_dev *dev = port->dev;
>  	u32 crc;
>  
> diff --git a/drivers/media/video/saa7164/saa7164-fw.c b/drivers/media/video/saa7164/saa7164-fw.c
> index ebed6f7..b369300 100644
> --- a/drivers/media/video/saa7164/saa7164-fw.c
> +++ b/drivers/media/video/saa7164/saa7164-fw.c
> @@ -88,7 +88,7 @@ int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize,
>  		"%s(image=%p, size=%d, flags=0x%x, dst=%p, dstsize=0x%x)\n",
>  		__func__, src, srcsize, dlflags, dst, dstsize);
>  
> -	if ((src == 0) || (dst == 0)) {
> +	if ((src == NULL) || (dst == NULL)) {
>  		ret = -EIO;
>  		goto out;
>  	}
> diff --git a/drivers/media/video/saa7164/saa7164-vbi.c b/drivers/media/video/saa7164/saa7164-vbi.c
> index 8abbe6d..a659d3c 100644
> --- a/drivers/media/video/saa7164/saa7164-vbi.c
> +++ b/drivers/media/video/saa7164/saa7164-vbi.c
> @@ -123,8 +123,8 @@ static int saa7164_vbi_buffers_alloc(struct saa7164_port *port)
>  		((params->numberoflines * params->pitch) / PAGE_SIZE);
>  	params->bitspersample = 8;
>  	params->linethreshold = 0;
> -	params->pagetablelistvirt = 0;
> -	params->pagetablelistphys = 0;
> +	params->pagetablelistvirt = NULL;
> +	params->pagetablelistphys = NULL;
>  	params->numpagetableentries = port->hwcfg.buffercount;
>  
>  	/* Allocate the PCI resources, buffers (hard) */
> @@ -1054,7 +1054,7 @@ static int fops_release(struct file *file)
>  
>  struct saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port)
>  {
> -	struct saa7164_user_buffer *ubuf = 0;
> +	struct saa7164_user_buffer *ubuf = NULL;
>  	struct saa7164_dev *dev = port->dev;
>  	u32 crc;
>  
> -- 
> 1.7.2.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer
@ 2011-01-25 22:20   ` Julia Lawall
  0 siblings, 0 replies; 20+ messages in thread
From: Julia Lawall @ 2011-01-25 22:20 UTC (permalink / raw)
  To: Peter Huewe
  Cc: Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

On Tue, 25 Jan 2011, Peter Huewe wrote:

> This patch fixes the warning "Using plain integer as NULL pointer",
> generated by sparse, by replacing the offending 0s with NULL.
I recall (a number of years ago) being told that for things like kmalloc, 
the proper test was !x, not x = NULL.

julia


> KernelVersion: linus' tree-c723fdab
> 
> Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
> ---
>  drivers/media/video/saa7164/saa7164-api.c     |    8 ++++----
>  drivers/media/video/saa7164/saa7164-buffer.c  |   14 +++++++-------
>  drivers/media/video/saa7164/saa7164-bus.c     |    8 ++++----
>  drivers/media/video/saa7164/saa7164-cmd.c     |   10 +++++-----
>  drivers/media/video/saa7164/saa7164-core.c    |    8 ++++----
>  drivers/media/video/saa7164/saa7164-dvb.c     |    4 ++--
>  drivers/media/video/saa7164/saa7164-encoder.c |    6 +++---
>  drivers/media/video/saa7164/saa7164-fw.c      |    2 +-
>  drivers/media/video/saa7164/saa7164-vbi.c     |    6 +++---
>  9 files changed, 33 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c
> index bd86d97..c49dcad 100644
> --- a/drivers/media/video/saa7164/saa7164-api.c
> +++ b/drivers/media/video/saa7164/saa7164-api.c
> @@ -743,7 +743,7 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
>  int saa7164_api_initialize_dif(struct saa7164_port *port)
>  {
>  	struct saa7164_dev *dev = port->dev;
> -	struct saa7164_port *p = 0;
> +	struct saa7164_port *p = NULL;
>  	int ret = -EINVAL;
>  	u32 std = 0;
>  
> @@ -926,9 +926,9 @@ int saa7164_api_configure_port_mpeg2ps(struct saa7164_dev *dev,
>  
>  int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
>  {
> -	struct saa7164_port *tsport = 0;
> -	struct saa7164_port *encport = 0;
> -	struct saa7164_port *vbiport = 0;
> +	struct saa7164_port *tsport = NULL;
> +	struct saa7164_port *encport = NULL;
> +	struct saa7164_port *vbiport = NULL;
>  	u32 idx, next_offset;
>  	int i;
>  	struct tmComResDescrHeader *hdr, *t;
> diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c
> index ddd2521..977062f 100644
> --- a/drivers/media/video/saa7164/saa7164-buffer.c
> +++ b/drivers/media/video/saa7164/saa7164-buffer.c
> @@ -93,7 +93,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
>  	u32 len)
>  {
>  	struct tmHWStreamParameters *params = &port->hw_streamingparams;
> -	struct saa7164_buffer *buf = 0;
> +	struct saa7164_buffer *buf = NULL;
>  	struct saa7164_dev *dev = port->dev;
>  	int i;
>  
> @@ -157,7 +157,7 @@ fail2:
>  fail1:
>  	kfree(buf);
>  
> -	buf = 0;
> +	buf = NULL;
>  ret:
>  	return buf;
>  }
> @@ -289,14 +289,14 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
>  	struct saa7164_user_buffer *buf;
>  
>  	buf = kzalloc(sizeof(struct saa7164_user_buffer), GFP_KERNEL);
> -	if (buf = 0)
> -		return 0;
> +	if (buf = NULL)
> +		return NULL;
>  
>  	buf->data = kzalloc(len, GFP_KERNEL);
>  
> -	if (buf->data = 0) {
> +	if (buf->data = NULL) {
>  		kfree(buf);
> -		return 0;
> +		return NULL;
>  	}
>  
>  	buf->actual_size = len;
> @@ -315,7 +315,7 @@ void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf)
>  		return;
>  
>  	kfree(buf->data);
> -	buf->data = 0;
> +	buf->data = NULL;
>  
>  	kfree(buf);
>  }
> diff --git a/drivers/media/video/saa7164/saa7164-bus.c b/drivers/media/video/saa7164/saa7164-bus.c
> index b2b0d97..466e1b0 100644
> --- a/drivers/media/video/saa7164/saa7164-bus.c
> +++ b/drivers/media/video/saa7164/saa7164-bus.c
> @@ -158,7 +158,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg,
>  		return SAA_ERR_BAD_PARAMETER;
>  	}
>  
> -	if ((msg->size > 0) && (buf = 0)) {
> +	if ((msg->size > 0) && (buf = NULL)) {
>  		printk(KERN_ERR "%s() Missing message buffer\n", __func__);
>  		return SAA_ERR_BAD_PARAMETER;
>  	}
> @@ -315,7 +315,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
>  
>  	saa7164_bus_verify(dev);
>  
> -	if (msg = 0)
> +	if (msg = NULL)
>  		return ret;
>  
>  	if (msg->size > dev->bus.m_wMaxReqSize) {
> @@ -324,7 +324,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
>  		return ret;
>  	}
>  
> -	if ((peekonly = 0) && (msg->size > 0) && (buf = 0)) {
> +	if ((peekonly = 0) && (msg->size > 0) && (buf = NULL)) {
>  		printk(KERN_ERR
>  			"%s() Missing msg buf, size should be %d bytes\n",
>  			__func__, msg->size);
> @@ -392,7 +392,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
>  
>  		printk(KERN_ERR "%s() Unexpected msg miss-match\n", __func__);
>  		saa7164_bus_dumpmsg(dev, msg, buf);
> -		saa7164_bus_dumpmsg(dev, &msg_tmp, 0);
> +		saa7164_bus_dumpmsg(dev, &msg_tmp, NULL);
>  		ret = SAA_ERR_INVALID_COMMAND;
>  		goto out;
>  	}
> diff --git a/drivers/media/video/saa7164/saa7164-cmd.c b/drivers/media/video/saa7164/saa7164-cmd.c
> index a97ae17..6a4c217 100644
> --- a/drivers/media/video/saa7164/saa7164-cmd.c
> +++ b/drivers/media/video/saa7164/saa7164-cmd.c
> @@ -84,7 +84,7 @@ int saa7164_irq_dequeue(struct saa7164_dev *dev)
>  {
>  	int ret = SAA_OK, i = 0;
>  	u32 timeout;
> -	wait_queue_head_t *q = 0;
> +	wait_queue_head_t *q = NULL;
>  	u8 tmp[512];
>  	dprintk(DBGLVL_CMD, "%s()\n", __func__);
>  
> @@ -137,7 +137,7 @@ int saa7164_cmd_dequeue(struct saa7164_dev *dev)
>  	int loop = 1;
>  	int ret;
>  	u32 timeout;
> -	wait_queue_head_t *q = 0;
> +	wait_queue_head_t *q = NULL;
>  	u8 tmp[512];
>  	dprintk(DBGLVL_CMD, "%s()\n", __func__);
>  
> @@ -261,7 +261,7 @@ out:
>   */
>  int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
>  {
> -	wait_queue_head_t *q = 0;
> +	wait_queue_head_t *q = NULL;
>  	int ret = SAA_BUS_TIMEOUT;
>  	unsigned long stamp;
>  	int r;
> @@ -357,7 +357,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
>  		"sel = 0x%x)\n", __func__, saa7164_unitid_name(dev, id), id,
>  		command, controlselector);
>  
> -	if ((size = 0) || (buf = 0)) {
> +	if ((size = 0) || (buf = NULL)) {
>  		printk(KERN_ERR "%s() Invalid param\n", __func__);
>  		return SAA_ERR_BAD_PARAMETER;
>  	}
> @@ -538,7 +538,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
>  
>  			/* Invalid */
>  			dprintk(DBGLVL_CMD, "%s() Invalid\n", __func__);
> -			ret = saa7164_bus_get(dev, presponse_t, 0, 0);
> +			ret = saa7164_bus_get(dev, presponse_t, NULL, 0);
>  			if (ret != SAA_OK) {
>  				printk(KERN_ERR "get failed\n");
>  				return ret;
> diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c
> index 58af67f..b813aec 100644
> --- a/drivers/media/video/saa7164/saa7164-core.c
> +++ b/drivers/media/video/saa7164/saa7164-core.c
> @@ -277,8 +277,8 @@ static void saa7164_histogram_print(struct saa7164_port *port,
>  static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr)
>  {
>  	struct saa7164_dev *dev = port->dev;
> -	struct saa7164_buffer *buf = 0;
> -	struct saa7164_user_buffer *ubuf = 0;
> +	struct saa7164_buffer *buf = NULL;
> +	struct saa7164_user_buffer *ubuf = NULL;
>  	struct list_head *c, *n;
>  	int i = 0;
>  	u8 __iomem *p;
> @@ -649,7 +649,7 @@ static irqreturn_t saa7164_irq(int irq, void *dev_id)
>  	u32 intid, intstat[INT_SIZE/4];
>  	int i, handled = 0, bit;
>  
> -	if (dev = 0) {
> +	if (dev = NULL) {
>  		printk(KERN_ERR "%s() No device specified\n", __func__);
>  		handled = 0;
>  		goto out;
> @@ -945,7 +945,7 @@ static int get_resources(struct saa7164_dev *dev)
>  
>  static int saa7164_port_init(struct saa7164_dev *dev, int portnr)
>  {
> -	struct saa7164_port *port = 0;
> +	struct saa7164_port *port = NULL;
>  
>  	if ((portnr < 0) || (portnr >= SAA7164_MAX_PORTS))
>  		BUG();
> diff --git a/drivers/media/video/saa7164/saa7164-dvb.c b/drivers/media/video/saa7164/saa7164-dvb.c
> index b305a01..f65eab6 100644
> --- a/drivers/media/video/saa7164/saa7164-dvb.c
> +++ b/drivers/media/video/saa7164/saa7164-dvb.c
> @@ -309,8 +309,8 @@ static int dvb_register(struct saa7164_port *port)
>  
>  	port->hw_streamingparams.pitch = 188;
>  	port->hw_streamingparams.linethreshold = 0;
> -	port->hw_streamingparams.pagetablelistvirt = 0;
> -	port->hw_streamingparams.pagetablelistphys = 0;
> +	port->hw_streamingparams.pagetablelistvirt = NULL;
> +	port->hw_streamingparams.pagetablelistphys = NULL;
>  	port->hw_streamingparams.numpagetables = 2 +
>  		((SAA7164_TS_NUMBER_OF_LINES * 188) / PAGE_SIZE);
>  
> diff --git a/drivers/media/video/saa7164/saa7164-encoder.c b/drivers/media/video/saa7164/saa7164-encoder.c
> index 1838408..560a107 100644
> --- a/drivers/media/video/saa7164/saa7164-encoder.c
> +++ b/drivers/media/video/saa7164/saa7164-encoder.c
> @@ -152,8 +152,8 @@ static int saa7164_encoder_buffers_alloc(struct saa7164_port *port)
>  	/* Init and establish defaults */
>  	params->bitspersample = 8;
>  	params->linethreshold = 0;
> -	params->pagetablelistvirt = 0;
> -	params->pagetablelistphys = 0;
> +	params->pagetablelistvirt = NULL;
> +	params->pagetablelistphys = NULL;
>  	params->numpagetableentries = port->hwcfg.buffercount;
>  
>  	/* Allocate the PCI resources, buffers (hard) */
> @@ -1108,7 +1108,7 @@ static int fops_release(struct file *file)
>  
>  struct saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port)
>  {
> -	struct saa7164_user_buffer *ubuf = 0;
> +	struct saa7164_user_buffer *ubuf = NULL;
>  	struct saa7164_dev *dev = port->dev;
>  	u32 crc;
>  
> diff --git a/drivers/media/video/saa7164/saa7164-fw.c b/drivers/media/video/saa7164/saa7164-fw.c
> index ebed6f7..b369300 100644
> --- a/drivers/media/video/saa7164/saa7164-fw.c
> +++ b/drivers/media/video/saa7164/saa7164-fw.c
> @@ -88,7 +88,7 @@ int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize,
>  		"%s(image=%p, size=%d, flags=0x%x, dst=%p, dstsize=0x%x)\n",
>  		__func__, src, srcsize, dlflags, dst, dstsize);
>  
> -	if ((src = 0) || (dst = 0)) {
> +	if ((src = NULL) || (dst = NULL)) {
>  		ret = -EIO;
>  		goto out;
>  	}
> diff --git a/drivers/media/video/saa7164/saa7164-vbi.c b/drivers/media/video/saa7164/saa7164-vbi.c
> index 8abbe6d..a659d3c 100644
> --- a/drivers/media/video/saa7164/saa7164-vbi.c
> +++ b/drivers/media/video/saa7164/saa7164-vbi.c
> @@ -123,8 +123,8 @@ static int saa7164_vbi_buffers_alloc(struct saa7164_port *port)
>  		((params->numberoflines * params->pitch) / PAGE_SIZE);
>  	params->bitspersample = 8;
>  	params->linethreshold = 0;
> -	params->pagetablelistvirt = 0;
> -	params->pagetablelistphys = 0;
> +	params->pagetablelistvirt = NULL;
> +	params->pagetablelistphys = NULL;
>  	params->numpagetableentries = port->hwcfg.buffercount;
>  
>  	/* Allocate the PCI resources, buffers (hard) */
> @@ -1054,7 +1054,7 @@ static int fops_release(struct file *file)
>  
>  struct saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port)
>  {
> -	struct saa7164_user_buffer *ubuf = 0;
> +	struct saa7164_user_buffer *ubuf = NULL;
>  	struct saa7164_dev *dev = port->dev;
>  	u32 crc;
>  
> -- 
> 1.7.2.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
  2011-01-25 22:20   ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer Julia Lawall
@ 2011-01-25 22:54     ` Peter Hüwe
  -1 siblings, 0 replies; 20+ messages in thread
From: Peter Hüwe @ 2011-01-25 22:54 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

Am Dienstag 25 Januar 2011, 23:20:44 schrieb Julia Lawall:
> On Tue, 25 Jan 2011, Peter Huewe wrote:
> > This patch fixes the warning "Using plain integer as NULL pointer",
> > generated by sparse, by replacing the offending 0s with NULL.
> 
> I recall (a number of years ago) being told that for things like kmalloc,
> the proper test was !x, not x == NULL.
> 
> julia
> 


Hi Julia,

thanks for your input.
So do I understand you correctly if I say
if(!x) is better than if(x==NULL) in any case?

Or only for the kmalloc family?

Do you remember the reason why !x should be preferred?

In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions 
there is a function fun with looks like this:
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;
}


-->  So   if (buffer == NULL) is in the official CodingStyle - maybe we should 
add a paragraph there as well ;)


Don't get me wrong, I just want to learn ;)


Thanks,
Peter


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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
@ 2011-01-25 22:54     ` Peter Hüwe
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Hüwe @ 2011-01-25 22:54 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

Am Dienstag 25 Januar 2011, 23:20:44 schrieb Julia Lawall:
> On Tue, 25 Jan 2011, Peter Huewe wrote:
> > This patch fixes the warning "Using plain integer as NULL pointer",
> > generated by sparse, by replacing the offending 0s with NULL.
> 
> I recall (a number of years ago) being told that for things like kmalloc,
> the proper test was !x, not x = NULL.
> 
> julia
> 


Hi Julia,

thanks for your input.
So do I understand you correctly if I say
if(!x) is better than if(x=NULL) in any case?

Or only for the kmalloc family?

Do you remember the reason why !x should be preferred?

In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions 
there is a function fun with looks like this:
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;
}


-->  So   if (buffer = NULL) is in the official CodingStyle - maybe we should 
add a paragraph there as well ;)


Don't get me wrong, I just want to learn ;)


Thanks,
Peter


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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
  2011-01-25 22:54     ` Peter Hüwe
@ 2011-01-25 23:05       ` Devin Heitmueller
  -1 siblings, 0 replies; 20+ messages in thread
From: Devin Heitmueller @ 2011-01-25 23:05 UTC (permalink / raw)
  To: Peter Hüwe
  Cc: Julia Lawall, Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

On Tue, Jan 25, 2011 at 5:54 PM, Peter Hüwe <PeterHuewe@gmx.de> wrote:
> Hi Julia,
>
> thanks for your input.
> So do I understand you correctly if I say
> if(!x) is better than if(x==NULL) in any case?
>
> Or only for the kmalloc family?
>
> Do you remember the reason why !x should be preferred?
>
> In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions
> there is a function fun with looks like this:
> 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;
> }
>
>
> -->  So   if (buffer == NULL) is in the official CodingStyle - maybe we should
> add a paragraph there as well ;)
>
>
> Don't get me wrong, I just want to learn ;)

To my knowledge, the current CodingStyle doesn't enforce a particular
standard in this regard, leaving it at the discretion of the author.

Whether to do (!foo) or (foo == NULL) is one of those debates people
have similar to whether to use tabs as whitespace.  People have
differing opinions and there is no clearly "right" answer.  Personally
I strongly prefer (foo == NULL) as it makes it blindingly obvious that
it's a pointer comparison, whereas (!foo) leaves you wondering whether
it's an integer or pointer comparison.

All that said, you shouldn't submit patches which arbitrarily change
from one format to the other.  With regards to the proposed patch, you
should follow whatever style the author employed in the rest of the
file.

Cheers,

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com

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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as
@ 2011-01-25 23:05       ` Devin Heitmueller
  0 siblings, 0 replies; 20+ messages in thread
From: Devin Heitmueller @ 2011-01-25 23:05 UTC (permalink / raw)
  To: Peter Hüwe
  Cc: Julia Lawall, Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

On Tue, Jan 25, 2011 at 5:54 PM, Peter Hüwe <PeterHuewe@gmx.de> wrote:
> Hi Julia,
>
> thanks for your input.
> So do I understand you correctly if I say
> if(!x) is better than if(x=NULL) in any case?
>
> Or only for the kmalloc family?
>
> Do you remember the reason why !x should be preferred?
>
> In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions
> there is a function fun with looks like this:
> 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;
> }
>
>
> -->  So   if (buffer = NULL) is in the official CodingStyle - maybe we should
> add a paragraph there as well ;)
>
>
> Don't get me wrong, I just want to learn ;)

To my knowledge, the current CodingStyle doesn't enforce a particular
standard in this regard, leaving it at the discretion of the author.

Whether to do (!foo) or (foo = NULL) is one of those debates people
have similar to whether to use tabs as whitespace.  People have
differing opinions and there is no clearly "right" answer.  Personally
I strongly prefer (foo = NULL) as it makes it blindingly obvious that
it's a pointer comparison, whereas (!foo) leaves you wondering whether
it's an integer or pointer comparison.

All that said, you shouldn't submit patches which arbitrarily change
from one format to the other.  With regards to the proposed patch, you
should follow whatever style the author employed in the rest of the
file.

Cheers,

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
  2011-01-25 23:05       ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer as Devin Heitmueller
@ 2011-01-26  0:30         ` Andy Walls
  -1 siblings, 0 replies; 20+ messages in thread
From: Andy Walls @ 2011-01-26  0:30 UTC (permalink / raw)
  To: Devin Heitmueller
  Cc: Peter Hüwe, Julia Lawall, Mauro Carvalho Chehab,
	linux-media, linux-kernel, kernel-janitors, Steven Toth,
	Tejun Heo, Dan Carpenter

On Tue, 2011-01-25 at 18:05 -0500, Devin Heitmueller wrote:
> On Tue, Jan 25, 2011 at 5:54 PM, Peter Hüwe <PeterHuewe@gmx.de> wrote:
> > Hi Julia,
> >
> > thanks for your input.
> > So do I understand you correctly if I say
> > if(!x) is better than if(x==NULL) in any case?

The machine code should be equivalent in size and speed.


> > Or only for the kmalloc family?
> >
> > Do you remember the reason why !x should be preferred?
> >
> > In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions
> > there is a function fun with looks like this:
> > int fun(int a)
> > {
> >    int result = 0;
> >    char *buffer = kmalloc(SIZE);
> >
> >    if (buffer == NULL)
> >        return -ENOMEM;

> >
> > -->  So   if (buffer == NULL) is in the official CodingStyle - maybe we should
> > add a paragraph there as well ;)


CodingStyle shouldn't specify anything on the matter.  There is no
overall, optimal choice for all contexts.   Arguing either way is as
pointless as the Lilliputians' little-end vs. big-end dispute.


> To my knowledge, the current CodingStyle doesn't enforce a particular
> standard in this regard, leaving it at the discretion of the author.

Correct, it does not.  I just checked CodingStyle and checkpatch
yesterday.


> Whether to do (!foo) or (foo == NULL) is one of those debates people
> have similar to whether to use tabs as whitespace.  People have
> differing opinions and there is no clearly "right" answer.

It depends on one's measurement criteria for "optimizing" the written
form of source code.

I prefer more explicit statement of action is taking place over
statements with fewer characters.  It usually saves me time when
revisiting code.

More genrally I prefer any coding practice that saves me time when
revisiting code.  (Note the word "me" carries a lot of context with it.)

Ambiguity and implicit behaviors ultimately waste my time.


>   Personally
> I strongly prefer (foo == NULL) as it makes it blindingly obvious that
> it's a pointer comparison, whereas (!foo) leaves you wondering whether
> it's an integer or pointer comparison.

<usenet>
Me too.
</usenet>


> All that said, you shouldn't submit patches which arbitrarily change
> from one format to the other.  With regards to the proposed patch, you
> should follow whatever style the author employed in the rest of the
> file.

That is another reasonable critereon in "optimizing" the written form of
the source code.  I tend to give it less weight though.


Regards,
Andy


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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer
@ 2011-01-26  0:30         ` Andy Walls
  0 siblings, 0 replies; 20+ messages in thread
From: Andy Walls @ 2011-01-26  0:30 UTC (permalink / raw)
  To: Devin Heitmueller
  Cc: Peter Hüwe, Julia Lawall, Mauro Carvalho Chehab,
	linux-media, linux-kernel, kernel-janitors, Steven Toth,
	Tejun Heo, Dan Carpenter

On Tue, 2011-01-25 at 18:05 -0500, Devin Heitmueller wrote:
> On Tue, Jan 25, 2011 at 5:54 PM, Peter Hüwe <PeterHuewe@gmx.de> wrote:
> > Hi Julia,
> >
> > thanks for your input.
> > So do I understand you correctly if I say
> > if(!x) is better than if(x=NULL) in any case?

The machine code should be equivalent in size and speed.


> > Or only for the kmalloc family?
> >
> > Do you remember the reason why !x should be preferred?
> >
> > In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions
> > there is a function fun with looks like this:
> > int fun(int a)
> > {
> >    int result = 0;
> >    char *buffer = kmalloc(SIZE);
> >
> >    if (buffer = NULL)
> >        return -ENOMEM;

> >
> > -->  So   if (buffer = NULL) is in the official CodingStyle - maybe we should
> > add a paragraph there as well ;)


CodingStyle shouldn't specify anything on the matter.  There is no
overall, optimal choice for all contexts.   Arguing either way is as
pointless as the Lilliputians' little-end vs. big-end dispute.


> To my knowledge, the current CodingStyle doesn't enforce a particular
> standard in this regard, leaving it at the discretion of the author.

Correct, it does not.  I just checked CodingStyle and checkpatch
yesterday.


> Whether to do (!foo) or (foo = NULL) is one of those debates people
> have similar to whether to use tabs as whitespace.  People have
> differing opinions and there is no clearly "right" answer.

It depends on one's measurement criteria for "optimizing" the written
form of source code.

I prefer more explicit statement of action is taking place over
statements with fewer characters.  It usually saves me time when
revisiting code.

More genrally I prefer any coding practice that saves me time when
revisiting code.  (Note the word "me" carries a lot of context with it.)

Ambiguity and implicit behaviors ultimately waste my time.


>   Personally
> I strongly prefer (foo = NULL) as it makes it blindingly obvious that
> it's a pointer comparison, whereas (!foo) leaves you wondering whether
> it's an integer or pointer comparison.

<usenet>
Me too.
</usenet>


> All that said, you shouldn't submit patches which arbitrarily change
> from one format to the other.  With regards to the proposed patch, you
> should follow whatever style the author employed in the rest of the
> file.

That is another reasonable critereon in "optimizing" the written form of
the source code.  I tend to give it less weight though.


Regards,
Andy

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
  2011-01-25 22:20   ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer Julia Lawall
@ 2011-01-26  4:25     ` Dan Carpenter
  -1 siblings, 0 replies; 20+ messages in thread
From: Dan Carpenter @ 2011-01-26  4:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Peter Huewe, Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo

On Tue, Jan 25, 2011 at 11:20:44PM +0100, Julia Lawall wrote:
> On Tue, 25 Jan 2011, Peter Huewe wrote:
> 
> > This patch fixes the warning "Using plain integer as NULL pointer",
> > generated by sparse, by replacing the offending 0s with NULL.
> I recall (a number of years ago) being told that for things like kmalloc, 
> the proper test was !x, not x == NULL.
> 

It was Al Viro who said that.  Here's the link.

http://lwn.net/Articles/331593/

regards,
dan carpenter


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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer
@ 2011-01-26  4:25     ` Dan Carpenter
  0 siblings, 0 replies; 20+ messages in thread
From: Dan Carpenter @ 2011-01-26  4:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Peter Huewe, Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo

On Tue, Jan 25, 2011 at 11:20:44PM +0100, Julia Lawall wrote:
> On Tue, 25 Jan 2011, Peter Huewe wrote:
> 
> > This patch fixes the warning "Using plain integer as NULL pointer",
> > generated by sparse, by replacing the offending 0s with NULL.
> I recall (a number of years ago) being told that for things like kmalloc, 
> the proper test was !x, not x = NULL.
> 

It was Al Viro who said that.  Here's the link.

http://lwn.net/Articles/331593/

regards,
dan carpenter


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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
  2011-01-25 22:54     ` Peter Hüwe
@ 2011-01-26  5:59       ` Julia Lawall
  -1 siblings, 0 replies; 20+ messages in thread
From: Julia Lawall @ 2011-01-26  5:59 UTC (permalink / raw)
  To: Peter Hüwe
  Cc: Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1800 bytes --]

On Tue, 25 Jan 2011, Peter Hüwe wrote:

> Am Dienstag 25 Januar 2011, 23:20:44 schrieb Julia Lawall:
> > On Tue, 25 Jan 2011, Peter Huewe wrote:
> > > This patch fixes the warning "Using plain integer as NULL pointer",
> > > generated by sparse, by replacing the offending 0s with NULL.
> > 
> > I recall (a number of years ago) being told that for things like kmalloc,
> > the proper test was !x, not x == NULL.
> > 
> > julia
> > 
> 
> 
> Hi Julia,
> 
> thanks for your input.
> So do I understand you correctly if I say
> if(!x) is better than if(x==NULL) in any case?

No.

> Or only for the kmalloc family?
> 
> Do you remember the reason why !x should be preferred?

Because it is a function call, and NULL represents failure of that 
function, not an actual NULL value.

Here is an email that explains that:

http://lkml.org/lkml/2007/7/27/103

Here is the beginning of the thread:

http://lkml.org/lkml/2007/7/27/75

julia

> In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions 
> there is a function fun with looks like this:
> 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;
> }
> 
> 
> -->  So   if (buffer == NULL) is in the official CodingStyle - maybe we should 
> add a paragraph there as well ;)
> 
> 
> Don't get me wrong, I just want to learn ;)
> 
> 
> Thanks,
> Peter
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer
@ 2011-01-26  5:59       ` Julia Lawall
  0 siblings, 0 replies; 20+ messages in thread
From: Julia Lawall @ 2011-01-26  5:59 UTC (permalink / raw)
  To: Peter Hüwe
  Cc: Mauro Carvalho Chehab, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1877 bytes --]

On Tue, 25 Jan 2011, Peter Hüwe wrote:

> Am Dienstag 25 Januar 2011, 23:20:44 schrieb Julia Lawall:
> > On Tue, 25 Jan 2011, Peter Huewe wrote:
> > > This patch fixes the warning "Using plain integer as NULL pointer",
> > > generated by sparse, by replacing the offending 0s with NULL.
> > 
> > I recall (a number of years ago) being told that for things like kmalloc,
> > the proper test was !x, not x == NULL.
> > 
> > julia
> > 
> 
> 
> Hi Julia,
> 
> thanks for your input.
> So do I understand you correctly if I say
> if(!x) is better than if(x==NULL) in any case?

No.

> Or only for the kmalloc family?
> 
> Do you remember the reason why !x should be preferred?

Because it is a function call, and NULL represents failure of that 
function, not an actual NULL value.

Here is an email that explains that:

http://lkml.org/lkml/2007/7/27/103

Here is the beginning of the thread:

http://lkml.org/lkml/2007/7/27/75

julia

> In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions 
> there is a function fun with looks like this:
> 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;
> }
> 
> 
> -->  So   if (buffer == NULL) is in the official CodingStyle - maybe we should 
> add a paragraph there as well ;)
> 
> 
> Don't get me wrong, I just want to learn ;)
> 
> 
> Thanks,
> Peter
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
  2011-01-25 22:54     ` Peter Hüwe
@ 2011-01-26  9:29       ` Mauro Carvalho Chehab
  -1 siblings, 0 replies; 20+ messages in thread
From: Mauro Carvalho Chehab @ 2011-01-26  9:29 UTC (permalink / raw)
  To: Peter Hüwe
  Cc: Julia Lawall, linux-media, linux-kernel, kernel-janitors,
	Steven Toth, Tejun Heo, Dan Carpenter

Em 25-01-2011 20:54, Peter Hüwe escreveu:
> Am Dienstag 25 Januar 2011, 23:20:44 schrieb Julia Lawall:
>> On Tue, 25 Jan 2011, Peter Huewe wrote:
>>> This patch fixes the warning "Using plain integer as NULL pointer",
>>> generated by sparse, by replacing the offending 0s with NULL.
>>
>> I recall (a number of years ago) being told that for things like kmalloc,
>> the proper test was !x, not x == NULL.
>>
>> julia
>>
> 
> 
> Hi Julia,
> 
> thanks for your input.
> So do I understand you correctly if I say
> if(!x) is better than if(x==NULL) in any case?
> 
> Or only for the kmalloc family?
> 
> Do you remember the reason why !x should be preferred?
> 
> In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions 
> there is a function fun with looks like this:
> 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;
> }
> 
> 
> -->  So   if (buffer == NULL) is in the official CodingStyle - maybe we should 
> add a paragraph there as well ;)
> 
> 
> Don't get me wrong, I just want to learn ;)

Both ways are acceptable. But because C is a Spartan language, and because
I need to review lots of code, I prefer the more synthetic way:
	if (!buf)

That means less things to read, and saves me a few microsseconds of reading
and processing it on my mind. In general, such tests occur just after a malloc
or a malloc-like function, so it is really obvious that you're testing for
a pointer.

Cheers,
Mauro

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

* Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer
@ 2011-01-26  9:29       ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 20+ messages in thread
From: Mauro Carvalho Chehab @ 2011-01-26  9:29 UTC (permalink / raw)
  To: Peter Hüwe
  Cc: Julia Lawall, linux-media, linux-kernel, kernel-janitors,
	Steven Toth, Tejun Heo, Dan Carpenter

Em 25-01-2011 20:54, Peter Hüwe escreveu:
> Am Dienstag 25 Januar 2011, 23:20:44 schrieb Julia Lawall:
>> On Tue, 25 Jan 2011, Peter Huewe wrote:
>>> This patch fixes the warning "Using plain integer as NULL pointer",
>>> generated by sparse, by replacing the offending 0s with NULL.
>>
>> I recall (a number of years ago) being told that for things like kmalloc,
>> the proper test was !x, not x = NULL.
>>
>> julia
>>
> 
> 
> Hi Julia,
> 
> thanks for your input.
> So do I understand you correctly if I say
> if(!x) is better than if(x=NULL) in any case?
> 
> Or only for the kmalloc family?
> 
> Do you remember the reason why !x should be preferred?
> 
> In Documentation/CodingStyle ,  Chapter 7: Centralized exiting of functions 
> there is a function fun with looks like this:
> 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;
> }
> 
> 
> -->  So   if (buffer = NULL) is in the official CodingStyle - maybe we should 
> add a paragraph there as well ;)
> 
> 
> Don't get me wrong, I just want to learn ;)

Both ways are acceptable. But because C is a Spartan language, and because
I need to review lots of code, I prefer the more synthetic way:
	if (!buf)

That means less things to read, and saves me a few microsseconds of reading
and processing it on my mind. In general, such tests occur just after a malloc
or a malloc-like function, so it is really obvious that you're testing for
a pointer.

Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
  2011-01-26  9:29       ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer Mauro Carvalho Chehab
@ 2011-01-30 19:33         ` Peter Huewe
  -1 siblings, 0 replies; 20+ messages in thread
From: Peter Huewe @ 2011-01-30 19:33 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Julia Lawall, linux-media, linux-kernel, kernel-janitors,
	Steven Toth, Tejun Heo, Dan Carpenter

From: Peter Huewe <peterhuewe@gmx.de>

This patch fixes the warning "Using plain integer as NULL pointer",
generated by sparse, by replacing
	if(var == 0)
with
	if (!var)
after an allocation
and all other offending 0s with NULL.

KernelVersion: linus' tree-1f0324c

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
v2: I changed the patch according to Julia's hints. 
i.e. using if(!buf) instead of if(buf==NULL) after the kmalloc family,
and other allocations.

 drivers/media/video/saa7164/saa7164-api.c     |   10 +++++-----
 drivers/media/video/saa7164/saa7164-buffer.c  |   16 ++++++++--------
 drivers/media/video/saa7164/saa7164-bus.c     |    8 ++++----
 drivers/media/video/saa7164/saa7164-cmd.c     |   10 +++++-----
 drivers/media/video/saa7164/saa7164-core.c    |    8 ++++----
 drivers/media/video/saa7164/saa7164-dvb.c     |    4 ++--
 drivers/media/video/saa7164/saa7164-encoder.c |    8 ++++----
 drivers/media/video/saa7164/saa7164-fw.c      |    2 +-
 drivers/media/video/saa7164/saa7164-vbi.c     |    8 ++++----
 9 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c
index bd86d97..8a98ab6 100644
--- a/drivers/media/video/saa7164/saa7164-api.c
+++ b/drivers/media/video/saa7164/saa7164-api.c
@@ -743,7 +743,7 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
 int saa7164_api_initialize_dif(struct saa7164_port *port)
 {
 	struct saa7164_dev *dev = port->dev;
-	struct saa7164_port *p = 0;
+	struct saa7164_port *p = NULL;
 	int ret = -EINVAL;
 	u32 std = 0;
 
@@ -926,9 +926,9 @@ int saa7164_api_configure_port_mpeg2ps(struct saa7164_dev *dev,
 
 int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
 {
-	struct saa7164_port *tsport = 0;
-	struct saa7164_port *encport = 0;
-	struct saa7164_port *vbiport = 0;
+	struct saa7164_port *tsport = NULL;
+	struct saa7164_port *encport = NULL;
+	struct saa7164_port *vbiport = NULL;
 	u32 idx, next_offset;
 	int i;
 	struct tmComResDescrHeader *hdr, *t;
@@ -1340,7 +1340,7 @@ int saa7164_api_enum_subdevs(struct saa7164_dev *dev)
 
 	/* Allocate enough storage for all of the descs */
 	buf = kzalloc(buflen, GFP_KERNEL);
-	if (buf == NULL)
+	if (!buf)
 		return SAA_ERR_NO_RESOURCES;
 
 	/* Retrieve them */
diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c
index ddd2521..66696fa 100644
--- a/drivers/media/video/saa7164/saa7164-buffer.c
+++ b/drivers/media/video/saa7164/saa7164-buffer.c
@@ -93,7 +93,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
 	u32 len)
 {
 	struct tmHWStreamParameters *params = &port->hw_streamingparams;
-	struct saa7164_buffer *buf = 0;
+	struct saa7164_buffer *buf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	int i;
 
@@ -103,7 +103,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
 	}
 
 	buf = kzalloc(sizeof(struct saa7164_buffer), GFP_KERNEL);
-	if (buf == NULL) {
+	if (!buf) {
 		log_warn("%s() SAA_ERR_NO_RESOURCES\n", __func__);
 		goto ret;
 	}
@@ -157,7 +157,7 @@ fail2:
 fail1:
 	kfree(buf);
 
-	buf = 0;
+	buf = NULL;
 ret:
 	return buf;
 }
@@ -289,14 +289,14 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
 	struct saa7164_user_buffer *buf;
 
 	buf = kzalloc(sizeof(struct saa7164_user_buffer), GFP_KERNEL);
-	if (buf == 0)
-		return 0;
+	if (!buf)
+		return NULL;
 
 	buf->data = kzalloc(len, GFP_KERNEL);
 
-	if (buf->data == 0) {
+	if (!buf->data) {
 		kfree(buf);
-		return 0;
+		return NULL;
 	}
 
 	buf->actual_size = len;
@@ -315,7 +315,7 @@ void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf)
 		return;
 
 	kfree(buf->data);
-	buf->data = 0;
+	buf->data = NULL;
 
 	kfree(buf);
 }
diff --git a/drivers/media/video/saa7164/saa7164-bus.c b/drivers/media/video/saa7164/saa7164-bus.c
index b2b0d97..466e1b0 100644
--- a/drivers/media/video/saa7164/saa7164-bus.c
+++ b/drivers/media/video/saa7164/saa7164-bus.c
@@ -158,7 +158,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg,
 		return SAA_ERR_BAD_PARAMETER;
 	}
 
-	if ((msg->size > 0) && (buf == 0)) {
+	if ((msg->size > 0) && (buf == NULL)) {
 		printk(KERN_ERR "%s() Missing message buffer\n", __func__);
 		return SAA_ERR_BAD_PARAMETER;
 	}
@@ -315,7 +315,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 
 	saa7164_bus_verify(dev);
 
-	if (msg == 0)
+	if (msg == NULL)
 		return ret;
 
 	if (msg->size > dev->bus.m_wMaxReqSize) {
@@ -324,7 +324,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 		return ret;
 	}
 
-	if ((peekonly == 0) && (msg->size > 0) && (buf == 0)) {
+	if ((peekonly == 0) && (msg->size > 0) && (buf == NULL)) {
 		printk(KERN_ERR
 			"%s() Missing msg buf, size should be %d bytes\n",
 			__func__, msg->size);
@@ -392,7 +392,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 
 		printk(KERN_ERR "%s() Unexpected msg miss-match\n", __func__);
 		saa7164_bus_dumpmsg(dev, msg, buf);
-		saa7164_bus_dumpmsg(dev, &msg_tmp, 0);
+		saa7164_bus_dumpmsg(dev, &msg_tmp, NULL);
 		ret = SAA_ERR_INVALID_COMMAND;
 		goto out;
 	}
diff --git a/drivers/media/video/saa7164/saa7164-cmd.c b/drivers/media/video/saa7164/saa7164-cmd.c
index a97ae17..6a4c217 100644
--- a/drivers/media/video/saa7164/saa7164-cmd.c
+++ b/drivers/media/video/saa7164/saa7164-cmd.c
@@ -84,7 +84,7 @@ int saa7164_irq_dequeue(struct saa7164_dev *dev)
 {
 	int ret = SAA_OK, i = 0;
 	u32 timeout;
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	u8 tmp[512];
 	dprintk(DBGLVL_CMD, "%s()\n", __func__);
 
@@ -137,7 +137,7 @@ int saa7164_cmd_dequeue(struct saa7164_dev *dev)
 	int loop = 1;
 	int ret;
 	u32 timeout;
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	u8 tmp[512];
 	dprintk(DBGLVL_CMD, "%s()\n", __func__);
 
@@ -261,7 +261,7 @@ out:
  */
 int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
 {
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	int ret = SAA_BUS_TIMEOUT;
 	unsigned long stamp;
 	int r;
@@ -357,7 +357,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
 		"sel = 0x%x)\n", __func__, saa7164_unitid_name(dev, id), id,
 		command, controlselector);
 
-	if ((size == 0) || (buf == 0)) {
+	if ((size == 0) || (buf == NULL)) {
 		printk(KERN_ERR "%s() Invalid param\n", __func__);
 		return SAA_ERR_BAD_PARAMETER;
 	}
@@ -538,7 +538,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
 
 			/* Invalid */
 			dprintk(DBGLVL_CMD, "%s() Invalid\n", __func__);
-			ret = saa7164_bus_get(dev, presponse_t, 0, 0);
+			ret = saa7164_bus_get(dev, presponse_t, NULL, 0);
 			if (ret != SAA_OK) {
 				printk(KERN_ERR "get failed\n");
 				return ret;
diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c
index 58af67f..b813aec 100644
--- a/drivers/media/video/saa7164/saa7164-core.c
+++ b/drivers/media/video/saa7164/saa7164-core.c
@@ -277,8 +277,8 @@ static void saa7164_histogram_print(struct saa7164_port *port,
 static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr)
 {
 	struct saa7164_dev *dev = port->dev;
-	struct saa7164_buffer *buf = 0;
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_buffer *buf = NULL;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct list_head *c, *n;
 	int i = 0;
 	u8 __iomem *p;
@@ -649,7 +649,7 @@ static irqreturn_t saa7164_irq(int irq, void *dev_id)
 	u32 intid, intstat[INT_SIZE/4];
 	int i, handled = 0, bit;
 
-	if (dev == 0) {
+	if (dev == NULL) {
 		printk(KERN_ERR "%s() No device specified\n", __func__);
 		handled = 0;
 		goto out;
@@ -945,7 +945,7 @@ static int get_resources(struct saa7164_dev *dev)
 
 static int saa7164_port_init(struct saa7164_dev *dev, int portnr)
 {
-	struct saa7164_port *port = 0;
+	struct saa7164_port *port = NULL;
 
 	if ((portnr < 0) || (portnr >= SAA7164_MAX_PORTS))
 		BUG();
diff --git a/drivers/media/video/saa7164/saa7164-dvb.c b/drivers/media/video/saa7164/saa7164-dvb.c
index b305a01..f65eab6 100644
--- a/drivers/media/video/saa7164/saa7164-dvb.c
+++ b/drivers/media/video/saa7164/saa7164-dvb.c
@@ -309,8 +309,8 @@ static int dvb_register(struct saa7164_port *port)
 
 	port->hw_streamingparams.pitch = 188;
 	port->hw_streamingparams.linethreshold = 0;
-	port->hw_streamingparams.pagetablelistvirt = 0;
-	port->hw_streamingparams.pagetablelistphys = 0;
+	port->hw_streamingparams.pagetablelistvirt = NULL;
+	port->hw_streamingparams.pagetablelistphys = NULL;
 	port->hw_streamingparams.numpagetables = 2 +
 		((SAA7164_TS_NUMBER_OF_LINES * 188) / PAGE_SIZE);
 
diff --git a/drivers/media/video/saa7164/saa7164-encoder.c b/drivers/media/video/saa7164/saa7164-encoder.c
index 1838408..f9d5946 100644
--- a/drivers/media/video/saa7164/saa7164-encoder.c
+++ b/drivers/media/video/saa7164/saa7164-encoder.c
@@ -152,8 +152,8 @@ static int saa7164_encoder_buffers_alloc(struct saa7164_port *port)
 	/* Init and establish defaults */
 	params->bitspersample = 8;
 	params->linethreshold = 0;
-	params->pagetablelistvirt = 0;
-	params->pagetablelistphys = 0;
+	params->pagetablelistvirt = NULL;
+	params->pagetablelistphys = NULL;
 	params->numpagetableentries = port->hwcfg.buffercount;
 
 	/* Allocate the PCI resources, buffers (hard) */
@@ -1108,7 +1108,7 @@ static int fops_release(struct file *file)
 
 struct saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port)
 {
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	u32 crc;
 
@@ -1443,7 +1443,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
 	port->v4l_device = saa7164_encoder_alloc(port,
 		dev->pci, &saa7164_mpeg_template, "mpeg");
 
-	if (port->v4l_device == NULL) {
+	if (!port->v4l_device) {
 		printk(KERN_INFO "%s: can't allocate mpeg device\n",
 			dev->name);
 		result = -ENOMEM;
diff --git a/drivers/media/video/saa7164/saa7164-fw.c b/drivers/media/video/saa7164/saa7164-fw.c
index ebed6f7..b369300 100644
--- a/drivers/media/video/saa7164/saa7164-fw.c
+++ b/drivers/media/video/saa7164/saa7164-fw.c
@@ -88,7 +88,7 @@ int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize,
 		"%s(image=%p, size=%d, flags=0x%x, dst=%p, dstsize=0x%x)\n",
 		__func__, src, srcsize, dlflags, dst, dstsize);
 
-	if ((src == 0) || (dst == 0)) {
+	if ((src == NULL) || (dst == NULL)) {
 		ret = -EIO;
 		goto out;
 	}
diff --git a/drivers/media/video/saa7164/saa7164-vbi.c b/drivers/media/video/saa7164/saa7164-vbi.c
index 8abbe6d..9e5b01c 100644
--- a/drivers/media/video/saa7164/saa7164-vbi.c
+++ b/drivers/media/video/saa7164/saa7164-vbi.c
@@ -123,8 +123,8 @@ static int saa7164_vbi_buffers_alloc(struct saa7164_port *port)
 		((params->numberoflines * params->pitch) / PAGE_SIZE);
 	params->bitspersample = 8;
 	params->linethreshold = 0;
-	params->pagetablelistvirt = 0;
-	params->pagetablelistphys = 0;
+	params->pagetablelistvirt = NULL;
+	params->pagetablelistphys = NULL;
 	params->numpagetableentries = port->hwcfg.buffercount;
 
 	/* Allocate the PCI resources, buffers (hard) */
@@ -1054,7 +1054,7 @@ static int fops_release(struct file *file)
 
 struct saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port)
 {
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	u32 crc;
 
@@ -1334,7 +1334,7 @@ int saa7164_vbi_register(struct saa7164_port *port)
 	port->v4l_device = saa7164_vbi_alloc(port,
 		dev->pci, &saa7164_vbi_template, "vbi");
 
-	if (port->v4l_device == NULL) {
+	if (!port->v4l_device) {
 		printk(KERN_INFO "%s: can't allocate vbi device\n",
 			dev->name);
 		result = -ENOMEM;
-- 
1.7.2.2



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

* [PATCH v2] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
@ 2011-01-30 19:33         ` Peter Huewe
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Huewe @ 2011-01-30 19:33 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Julia Lawall, linux-media, linux-kernel, kernel-janitors,
	Steven Toth, Tejun Heo, Dan Carpenter

From: Peter Huewe <peterhuewe@gmx.de>

This patch fixes the warning "Using plain integer as NULL pointer",
generated by sparse, by replacing
	if(var = 0)
with
	if (!var)
after an allocation
and all other offending 0s with NULL.

KernelVersion: linus' tree-1f0324c

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
v2: I changed the patch according to Julia's hints. 
i.e. using if(!buf) instead of if(buf=NULL) after the kmalloc family,
and other allocations.

 drivers/media/video/saa7164/saa7164-api.c     |   10 +++++-----
 drivers/media/video/saa7164/saa7164-buffer.c  |   16 ++++++++--------
 drivers/media/video/saa7164/saa7164-bus.c     |    8 ++++----
 drivers/media/video/saa7164/saa7164-cmd.c     |   10 +++++-----
 drivers/media/video/saa7164/saa7164-core.c    |    8 ++++----
 drivers/media/video/saa7164/saa7164-dvb.c     |    4 ++--
 drivers/media/video/saa7164/saa7164-encoder.c |    8 ++++----
 drivers/media/video/saa7164/saa7164-fw.c      |    2 +-
 drivers/media/video/saa7164/saa7164-vbi.c     |    8 ++++----
 9 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c
index bd86d97..8a98ab6 100644
--- a/drivers/media/video/saa7164/saa7164-api.c
+++ b/drivers/media/video/saa7164/saa7164-api.c
@@ -743,7 +743,7 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
 int saa7164_api_initialize_dif(struct saa7164_port *port)
 {
 	struct saa7164_dev *dev = port->dev;
-	struct saa7164_port *p = 0;
+	struct saa7164_port *p = NULL;
 	int ret = -EINVAL;
 	u32 std = 0;
 
@@ -926,9 +926,9 @@ int saa7164_api_configure_port_mpeg2ps(struct saa7164_dev *dev,
 
 int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
 {
-	struct saa7164_port *tsport = 0;
-	struct saa7164_port *encport = 0;
-	struct saa7164_port *vbiport = 0;
+	struct saa7164_port *tsport = NULL;
+	struct saa7164_port *encport = NULL;
+	struct saa7164_port *vbiport = NULL;
 	u32 idx, next_offset;
 	int i;
 	struct tmComResDescrHeader *hdr, *t;
@@ -1340,7 +1340,7 @@ int saa7164_api_enum_subdevs(struct saa7164_dev *dev)
 
 	/* Allocate enough storage for all of the descs */
 	buf = kzalloc(buflen, GFP_KERNEL);
-	if (buf = NULL)
+	if (!buf)
 		return SAA_ERR_NO_RESOURCES;
 
 	/* Retrieve them */
diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c
index ddd2521..66696fa 100644
--- a/drivers/media/video/saa7164/saa7164-buffer.c
+++ b/drivers/media/video/saa7164/saa7164-buffer.c
@@ -93,7 +93,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
 	u32 len)
 {
 	struct tmHWStreamParameters *params = &port->hw_streamingparams;
-	struct saa7164_buffer *buf = 0;
+	struct saa7164_buffer *buf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	int i;
 
@@ -103,7 +103,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
 	}
 
 	buf = kzalloc(sizeof(struct saa7164_buffer), GFP_KERNEL);
-	if (buf = NULL) {
+	if (!buf) {
 		log_warn("%s() SAA_ERR_NO_RESOURCES\n", __func__);
 		goto ret;
 	}
@@ -157,7 +157,7 @@ fail2:
 fail1:
 	kfree(buf);
 
-	buf = 0;
+	buf = NULL;
 ret:
 	return buf;
 }
@@ -289,14 +289,14 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
 	struct saa7164_user_buffer *buf;
 
 	buf = kzalloc(sizeof(struct saa7164_user_buffer), GFP_KERNEL);
-	if (buf = 0)
-		return 0;
+	if (!buf)
+		return NULL;
 
 	buf->data = kzalloc(len, GFP_KERNEL);
 
-	if (buf->data = 0) {
+	if (!buf->data) {
 		kfree(buf);
-		return 0;
+		return NULL;
 	}
 
 	buf->actual_size = len;
@@ -315,7 +315,7 @@ void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf)
 		return;
 
 	kfree(buf->data);
-	buf->data = 0;
+	buf->data = NULL;
 
 	kfree(buf);
 }
diff --git a/drivers/media/video/saa7164/saa7164-bus.c b/drivers/media/video/saa7164/saa7164-bus.c
index b2b0d97..466e1b0 100644
--- a/drivers/media/video/saa7164/saa7164-bus.c
+++ b/drivers/media/video/saa7164/saa7164-bus.c
@@ -158,7 +158,7 @@ int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg,
 		return SAA_ERR_BAD_PARAMETER;
 	}
 
-	if ((msg->size > 0) && (buf = 0)) {
+	if ((msg->size > 0) && (buf = NULL)) {
 		printk(KERN_ERR "%s() Missing message buffer\n", __func__);
 		return SAA_ERR_BAD_PARAMETER;
 	}
@@ -315,7 +315,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 
 	saa7164_bus_verify(dev);
 
-	if (msg = 0)
+	if (msg = NULL)
 		return ret;
 
 	if (msg->size > dev->bus.m_wMaxReqSize) {
@@ -324,7 +324,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 		return ret;
 	}
 
-	if ((peekonly = 0) && (msg->size > 0) && (buf = 0)) {
+	if ((peekonly = 0) && (msg->size > 0) && (buf = NULL)) {
 		printk(KERN_ERR
 			"%s() Missing msg buf, size should be %d bytes\n",
 			__func__, msg->size);
@@ -392,7 +392,7 @@ int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
 
 		printk(KERN_ERR "%s() Unexpected msg miss-match\n", __func__);
 		saa7164_bus_dumpmsg(dev, msg, buf);
-		saa7164_bus_dumpmsg(dev, &msg_tmp, 0);
+		saa7164_bus_dumpmsg(dev, &msg_tmp, NULL);
 		ret = SAA_ERR_INVALID_COMMAND;
 		goto out;
 	}
diff --git a/drivers/media/video/saa7164/saa7164-cmd.c b/drivers/media/video/saa7164/saa7164-cmd.c
index a97ae17..6a4c217 100644
--- a/drivers/media/video/saa7164/saa7164-cmd.c
+++ b/drivers/media/video/saa7164/saa7164-cmd.c
@@ -84,7 +84,7 @@ int saa7164_irq_dequeue(struct saa7164_dev *dev)
 {
 	int ret = SAA_OK, i = 0;
 	u32 timeout;
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	u8 tmp[512];
 	dprintk(DBGLVL_CMD, "%s()\n", __func__);
 
@@ -137,7 +137,7 @@ int saa7164_cmd_dequeue(struct saa7164_dev *dev)
 	int loop = 1;
 	int ret;
 	u32 timeout;
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	u8 tmp[512];
 	dprintk(DBGLVL_CMD, "%s()\n", __func__);
 
@@ -261,7 +261,7 @@ out:
  */
 int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
 {
-	wait_queue_head_t *q = 0;
+	wait_queue_head_t *q = NULL;
 	int ret = SAA_BUS_TIMEOUT;
 	unsigned long stamp;
 	int r;
@@ -357,7 +357,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
 		"sel = 0x%x)\n", __func__, saa7164_unitid_name(dev, id), id,
 		command, controlselector);
 
-	if ((size = 0) || (buf = 0)) {
+	if ((size = 0) || (buf = NULL)) {
 		printk(KERN_ERR "%s() Invalid param\n", __func__);
 		return SAA_ERR_BAD_PARAMETER;
 	}
@@ -538,7 +538,7 @@ int saa7164_cmd_send(struct saa7164_dev *dev, u8 id, enum tmComResCmd command,
 
 			/* Invalid */
 			dprintk(DBGLVL_CMD, "%s() Invalid\n", __func__);
-			ret = saa7164_bus_get(dev, presponse_t, 0, 0);
+			ret = saa7164_bus_get(dev, presponse_t, NULL, 0);
 			if (ret != SAA_OK) {
 				printk(KERN_ERR "get failed\n");
 				return ret;
diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c
index 58af67f..b813aec 100644
--- a/drivers/media/video/saa7164/saa7164-core.c
+++ b/drivers/media/video/saa7164/saa7164-core.c
@@ -277,8 +277,8 @@ static void saa7164_histogram_print(struct saa7164_port *port,
 static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr)
 {
 	struct saa7164_dev *dev = port->dev;
-	struct saa7164_buffer *buf = 0;
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_buffer *buf = NULL;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct list_head *c, *n;
 	int i = 0;
 	u8 __iomem *p;
@@ -649,7 +649,7 @@ static irqreturn_t saa7164_irq(int irq, void *dev_id)
 	u32 intid, intstat[INT_SIZE/4];
 	int i, handled = 0, bit;
 
-	if (dev = 0) {
+	if (dev = NULL) {
 		printk(KERN_ERR "%s() No device specified\n", __func__);
 		handled = 0;
 		goto out;
@@ -945,7 +945,7 @@ static int get_resources(struct saa7164_dev *dev)
 
 static int saa7164_port_init(struct saa7164_dev *dev, int portnr)
 {
-	struct saa7164_port *port = 0;
+	struct saa7164_port *port = NULL;
 
 	if ((portnr < 0) || (portnr >= SAA7164_MAX_PORTS))
 		BUG();
diff --git a/drivers/media/video/saa7164/saa7164-dvb.c b/drivers/media/video/saa7164/saa7164-dvb.c
index b305a01..f65eab6 100644
--- a/drivers/media/video/saa7164/saa7164-dvb.c
+++ b/drivers/media/video/saa7164/saa7164-dvb.c
@@ -309,8 +309,8 @@ static int dvb_register(struct saa7164_port *port)
 
 	port->hw_streamingparams.pitch = 188;
 	port->hw_streamingparams.linethreshold = 0;
-	port->hw_streamingparams.pagetablelistvirt = 0;
-	port->hw_streamingparams.pagetablelistphys = 0;
+	port->hw_streamingparams.pagetablelistvirt = NULL;
+	port->hw_streamingparams.pagetablelistphys = NULL;
 	port->hw_streamingparams.numpagetables = 2 +
 		((SAA7164_TS_NUMBER_OF_LINES * 188) / PAGE_SIZE);
 
diff --git a/drivers/media/video/saa7164/saa7164-encoder.c b/drivers/media/video/saa7164/saa7164-encoder.c
index 1838408..f9d5946 100644
--- a/drivers/media/video/saa7164/saa7164-encoder.c
+++ b/drivers/media/video/saa7164/saa7164-encoder.c
@@ -152,8 +152,8 @@ static int saa7164_encoder_buffers_alloc(struct saa7164_port *port)
 	/* Init and establish defaults */
 	params->bitspersample = 8;
 	params->linethreshold = 0;
-	params->pagetablelistvirt = 0;
-	params->pagetablelistphys = 0;
+	params->pagetablelistvirt = NULL;
+	params->pagetablelistphys = NULL;
 	params->numpagetableentries = port->hwcfg.buffercount;
 
 	/* Allocate the PCI resources, buffers (hard) */
@@ -1108,7 +1108,7 @@ static int fops_release(struct file *file)
 
 struct saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port)
 {
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	u32 crc;
 
@@ -1443,7 +1443,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
 	port->v4l_device = saa7164_encoder_alloc(port,
 		dev->pci, &saa7164_mpeg_template, "mpeg");
 
-	if (port->v4l_device = NULL) {
+	if (!port->v4l_device) {
 		printk(KERN_INFO "%s: can't allocate mpeg device\n",
 			dev->name);
 		result = -ENOMEM;
diff --git a/drivers/media/video/saa7164/saa7164-fw.c b/drivers/media/video/saa7164/saa7164-fw.c
index ebed6f7..b369300 100644
--- a/drivers/media/video/saa7164/saa7164-fw.c
+++ b/drivers/media/video/saa7164/saa7164-fw.c
@@ -88,7 +88,7 @@ int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize,
 		"%s(image=%p, size=%d, flags=0x%x, dst=%p, dstsize=0x%x)\n",
 		__func__, src, srcsize, dlflags, dst, dstsize);
 
-	if ((src = 0) || (dst = 0)) {
+	if ((src = NULL) || (dst = NULL)) {
 		ret = -EIO;
 		goto out;
 	}
diff --git a/drivers/media/video/saa7164/saa7164-vbi.c b/drivers/media/video/saa7164/saa7164-vbi.c
index 8abbe6d..9e5b01c 100644
--- a/drivers/media/video/saa7164/saa7164-vbi.c
+++ b/drivers/media/video/saa7164/saa7164-vbi.c
@@ -123,8 +123,8 @@ static int saa7164_vbi_buffers_alloc(struct saa7164_port *port)
 		((params->numberoflines * params->pitch) / PAGE_SIZE);
 	params->bitspersample = 8;
 	params->linethreshold = 0;
-	params->pagetablelistvirt = 0;
-	params->pagetablelistphys = 0;
+	params->pagetablelistvirt = NULL;
+	params->pagetablelistphys = NULL;
 	params->numpagetableentries = port->hwcfg.buffercount;
 
 	/* Allocate the PCI resources, buffers (hard) */
@@ -1054,7 +1054,7 @@ static int fops_release(struct file *file)
 
 struct saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port)
 {
-	struct saa7164_user_buffer *ubuf = 0;
+	struct saa7164_user_buffer *ubuf = NULL;
 	struct saa7164_dev *dev = port->dev;
 	u32 crc;
 
@@ -1334,7 +1334,7 @@ int saa7164_vbi_register(struct saa7164_port *port)
 	port->v4l_device = saa7164_vbi_alloc(port,
 		dev->pci, &saa7164_vbi_template, "vbi");
 
-	if (port->v4l_device = NULL) {
+	if (!port->v4l_device) {
 		printk(KERN_INFO "%s: can't allocate vbi device\n",
 			dev->name);
 		result = -ENOMEM;
-- 
1.7.2.2



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

* Re: [PATCH v2] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer
  2011-01-30 19:33         ` Peter Huewe
@ 2011-01-30 20:02           ` Devin Heitmueller
  -1 siblings, 0 replies; 20+ messages in thread
From: Devin Heitmueller @ 2011-01-30 20:02 UTC (permalink / raw)
  To: Peter Huewe
  Cc: Mauro Carvalho Chehab, Julia Lawall, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

On Sun, Jan 30, 2011 at 2:33 PM, Peter Huewe <PeterHuewe@gmx.de> wrote:
> From: Peter Huewe <peterhuewe@gmx.de>
>
> This patch fixes the warning "Using plain integer as NULL pointer",
> generated by sparse, by replacing
>        if(var == 0)
> with
>        if (!var)
> after an allocation
> and all other offending 0s with NULL.
>
> KernelVersion: linus' tree-1f0324c
>
> Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
> ---
> v2: I changed the patch according to Julia's hints.
> i.e. using if(!buf) instead of if(buf==NULL) after the kmalloc family,
> and other allocations.

Ok, so now we've gone from "eliminating a couple of sparse warnings"
to "going through the rest of the code and jamming in some alternate
coding style when there was nothing wrong with it in the first place."

Don't get me wrong, I appreciate the role of the kernel janitors in
general, but this patch is crap.  It's changes like this that just
lower the signal/noise ratio on *real* work going on, and increasing
the likelihood that some well intentioned janitor screwed up one of
the conversions.

After all, it's not like the author of this patch actually tried the
resulting code.  He only has to mess up one of those two line changes
and we go from "driver that works perfectly well" to "driver that is
100% broken".

There are much better uses of the maintainer's time than going through
patches like this to make sure the submitter didn't screw up the a
conversion that provides no real value.

A change like this:

-       if (buf == NULL) {
+       if (!buf) {

is a worthless change, and there is is a higher chance that one of
them gets screwed up in the patch than what we had to start with.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com

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

* Re: [PATCH v2] video/saa7164: Fix sparse warning: Using plain integer
@ 2011-01-30 20:02           ` Devin Heitmueller
  0 siblings, 0 replies; 20+ messages in thread
From: Devin Heitmueller @ 2011-01-30 20:02 UTC (permalink / raw)
  To: Peter Huewe
  Cc: Mauro Carvalho Chehab, Julia Lawall, linux-media, linux-kernel,
	kernel-janitors, Steven Toth, Tejun Heo, Dan Carpenter

On Sun, Jan 30, 2011 at 2:33 PM, Peter Huewe <PeterHuewe@gmx.de> wrote:
> From: Peter Huewe <peterhuewe@gmx.de>
>
> This patch fixes the warning "Using plain integer as NULL pointer",
> generated by sparse, by replacing
>        if(var = 0)
> with
>        if (!var)
> after an allocation
> and all other offending 0s with NULL.
>
> KernelVersion: linus' tree-1f0324c
>
> Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
> ---
> v2: I changed the patch according to Julia's hints.
> i.e. using if(!buf) instead of if(buf=NULL) after the kmalloc family,
> and other allocations.

Ok, so now we've gone from "eliminating a couple of sparse warnings"
to "going through the rest of the code and jamming in some alternate
coding style when there was nothing wrong with it in the first place."

Don't get me wrong, I appreciate the role of the kernel janitors in
general, but this patch is crap.  It's changes like this that just
lower the signal/noise ratio on *real* work going on, and increasing
the likelihood that some well intentioned janitor screwed up one of
the conversions.

After all, it's not like the author of this patch actually tried the
resulting code.  He only has to mess up one of those two line changes
and we go from "driver that works perfectly well" to "driver that is
100% broken".

There are much better uses of the maintainer's time than going through
patches like this to make sure the submitter didn't screw up the a
conversion that provides no real value.

A change like this:

-       if (buf = NULL) {
+       if (!buf) {

is a worthless change, and there is is a higher chance that one of
them gets screwed up in the patch than what we had to start with.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2011-01-30 20:02 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-25 20:54 [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer Peter Huewe
2011-01-25 20:54 ` Peter Huewe
2011-01-25 22:20 ` Julia Lawall
2011-01-25 22:20   ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer Julia Lawall
2011-01-25 22:54   ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer Peter Hüwe
2011-01-25 22:54     ` Peter Hüwe
2011-01-25 23:05     ` Devin Heitmueller
2011-01-25 23:05       ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer as Devin Heitmueller
2011-01-26  0:30       ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer Andy Walls
2011-01-26  0:30         ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer Andy Walls
2011-01-26  5:59     ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer Julia Lawall
2011-01-26  5:59       ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer Julia Lawall
2011-01-26  9:29     ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer Mauro Carvalho Chehab
2011-01-26  9:29       ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer Mauro Carvalho Chehab
2011-01-30 19:33       ` [PATCH v2] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer Peter Huewe
2011-01-30 19:33         ` Peter Huewe
2011-01-30 20:02         ` Devin Heitmueller
2011-01-30 20:02           ` [PATCH v2] video/saa7164: Fix sparse warning: Using plain integer Devin Heitmueller
2011-01-26  4:25   ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer Dan Carpenter
2011-01-26  4:25     ` [PATCH] video/saa7164: Fix sparse warning: Using plain integer Dan Carpenter

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.