Skip to contentSkip to conversation

staging/sep: Fix sparse warning 'do-while statement is not a compound statement'

PATCH In review Peter Huewe 4 participants 11 messages Nov 29, 2010 – Dec 1, 2010 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 staging/sep: Fix sparse warning 'do-while statement is not a compound statement'

This patch fixes the warning generated by sparse: 'do-while statement is not a compound statement' by adding the necessary brackets around the do block

---
LinuxVersion: linux-next-20101129

 drivers/staging/sep/sep_dev.h    |    4 ++--
 drivers/staging/sep/sep_driver.c |   12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/sep/sep_dev.h +2 -2
index 7b4993b..0ffe68c 100644
@@ -147,9 +147,9 @@ static inline u32 sep_read_reg(struct sep_device *dev, int reg)
 static inline void sep_wait_sram_write(struct sep_device *dev)
 {
 	u32 reg_val;
-	do
+	do {
 		reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR);
-	while (!(reg_val & 1));
+	} while (!(reg_val & 1));
 }
 
 
drivers/staging/sep/sep_driver.c +6 -6
index ef36239..0c802dc 100644
@@ -2964,9 +2964,9 @@ static int sep_start_handler(struct sep_device *sep)
 	dev_dbg(&sep->pdev->dev, "sep_start_handler start\n");
 
 	/* wait in polling for message from SEP */
-	do
+	do {
 		reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
-	while (!reg_val);
+	} while (!reg_val);
 
 	/* check the value */
 	if (reg_val == 0x1)
@@ -3144,9 +3144,9 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 	/* wait for acknowledge */
 	dev_dbg(&sep->pdev->dev, "init; waiting for msg response\n");
 
-	do
+	do {
 		reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
-	while (!(reg_val & 0xFFFFFFFD));
+	} while (!(reg_val & 0xFFFFFFFD));
 
 	if (reg_val == 0x1) {
 
@@ -3167,9 +3167,9 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 	/* wait for response */
 	dev_dbg(&sep->pdev->dev, "init; waiting for zero set response\n");
 
-	do
+	do {
 		reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
-	while (reg_val != 0);
+	} while (reg_val != 0);
 
 
 end_function:
Signature · 1 line
1.7.2.2
#1 lore raw

PATCH 2/3 staging/sep: Fix sparse warning 'Using plain integer as NULL pointer'

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

---
LinuxVersion: linux-next-20101129

 drivers/staging/sep/sep_driver.c |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)
drivers/staging/sep/sep_driver.c +19 -19
index 0c802dc..cf5c897 100644
@@ -510,12 +510,12 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
 		}
 
 		/* reset all the values */
-		dma->in_page_array = 0;
-		dma->out_page_array = 0;
+		dma->in_page_array = NULL;
+		dma->out_page_array = NULL;
 		dma->in_num_pages = 0;
 		dma->out_num_pages = 0;
-		dma->in_map_array = 0;
-		dma->out_map_array = 0;
+		dma->in_map_array = NULL;
+		dma->out_map_array = NULL;
 		dma->in_map_num_entries = 0;
 		dma->out_map_num_entries = 0;
 
@@ -1298,13 +1298,13 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 	if (in_out_flag == SEP_DRIVER_IN_FLAG) {
 		*lli_array_ptr = lli_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages = 1;
-		sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
+		sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = NULL;
 		sep->dma_res_arr[sep->nr_dcb_creat].in_map_array = map_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].in_map_num_entries = 1;
 	} else {
 		*lli_array_ptr = lli_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].out_num_pages = 1;
-		sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = 0;
+		sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = NULL;
 		sep->dma_res_arr[sep->nr_dcb_creat].out_map_array = map_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].out_map_num_entries = 1;
 	}
@@ -1430,7 +1430,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
 	result = get_user_pages(current, current->mm, app_virt_addr,
 		num_pages,
 		((in_out_flag == SEP_DRIVER_IN_FLAG) ? 0 : 1),
-		0, page_array, 0);
+		0, page_array, NULL);
 
 	up_read(&current->mm->mmap_sem);
 
@@ -1993,7 +1993,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 		"block_size is %x\n", block_size);
 
 	/* initialize the pages pointers */
-	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
+	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = NULL;
 	sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages = 0;
 
 	/* set the kernel address for first table to be allocated */
@@ -2037,7 +2037,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages);
 
 	current_entry = 0;
-	info_entry_ptr = 0;
+	info_entry_ptr = NULL;
 
 	sep_lli_entries =
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages;
@@ -2088,7 +2088,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 			in_lli_table_ptr,
 			&current_entry, &num_entries_in_table, table_data_size);
 
-		if (info_entry_ptr == 0) {
+		if (info_entry_ptr == NULL) {
 
 			/* set the output parameters to physical addresses */
 			*lli_table_ptr = sep_shared_area_virt_to_bus(sep,
@@ -2185,16 +2185,16 @@ static int sep_construct_dma_tables_from_lli(
 	u32 lli_table_alloc_addr = 0;
 
 	/* input lli table */
-	struct sep_lli_entry *in_lli_table_ptr = 0;
+	struct sep_lli_entry *in_lli_table_ptr = NULL;
 
 	/* output lli table */
-	struct sep_lli_entry *out_lli_table_ptr = 0;
+	struct sep_lli_entry *out_lli_table_ptr = NULL;
 
 	/* pointer to the info entry of the table - the last entry */
-	struct sep_lli_entry *info_in_entry_ptr = 0;
+	struct sep_lli_entry *info_in_entry_ptr = NULL;
 
 	/* pointer to the info entry of the table - the last entry */
-	struct sep_lli_entry *info_out_entry_ptr = 0;
+	struct sep_lli_entry *info_out_entry_ptr = NULL;
 
 	/* points to the first entry to be processed in the lli_in_array */
 	u32 current_in_entry = 0;
@@ -2321,7 +2321,7 @@ static int sep_construct_dma_tables_from_lli(
 			table_data_size);
 
 		/* if info entry is null - this is the first table built */
-		if (info_in_entry_ptr == 0) {
+		if (info_in_entry_ptr == NULL) {
 			/* set the output parameters to physical addresses */
 			*lli_table_in_ptr =
 			sep_shared_area_virt_to_bus(sep, in_lli_table_ptr);
@@ -2464,8 +2464,8 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 	}
 
 	/* initialize the pages pointers */
-	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
-	sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = 0;
+	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = NULL;
+	sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = NULL;
 
 	/* lock the pages of the buffer and translate them to pages */
 	if (is_kva == true) {
@@ -2603,7 +2603,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 	u32 tail_size = 0;
 
 	/* address of the created dcb table */
-	struct sep_dcblock *dcb_table_ptr = 0;
+	struct sep_dcblock *dcb_table_ptr = NULL;
 
 	/* the physical address of the first input DMA table */
 	dma_addr_t in_first_mlli_address = 0;
@@ -2920,7 +2920,7 @@ static int sep_get_static_pool_addr_handler(struct sep_device *sep,
 {
 	struct stat_pool_addr_struct command_args;
 
-	u32 *static_pool_addr = 0;
+	u32 *static_pool_addr = NULL;
 
 	unsigned long addr_hold;
 
Signature · 1 line
1.7.2.2
#2 lore raw

PATCH 3/3 staging/sep: Fix sparse printk format warning

In reply to Peter Huewe

This patch fixes sparse's complaints about the wrong format string.

---
LinuxVersion: linux-next-20101129

 drivers/staging/sep/sep_driver.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
drivers/staging/sep/sep_driver.c +13 -13
index cf5c897..86e676d 100644
@@ -112,7 +112,7 @@ static int sep_load_firmware(struct sep_device *sep)
 		sep->resident_addr);
 	dev_dbg(&sep->pdev->dev, "residnet bus is %lx\n",
 		(unsigned long)sep->resident_bus);
-	dev_dbg(&sep->pdev->dev, "resident size is %08x\n",
+	dev_dbg(&sep->pdev->dev, "resident size is %08Zx\n",
 		sep->resident_size);
 
 	/* set addresses for dcache (no loading needed) */
@@ -146,7 +146,7 @@ static int sep_load_firmware(struct sep_device *sep)
 		sep->cache_addr);
 	dev_dbg(&sep->pdev->dev, "cache bus is %08lx\n",
 		(unsigned long)sep->cache_bus);
-	dev_dbg(&sep->pdev->dev, "cache size is %08x\n",
+	dev_dbg(&sep->pdev->dev, "cache size is %08Zx\n",
 		sep->cache_size);
 
 	/* set addresses and load extapp */
@@ -167,7 +167,7 @@ static int sep_load_firmware(struct sep_device *sep)
 		sep->extapp_addr);
 	dev_dbg(&sep->pdev->dev, "extapp bus is %08llx\n",
 		(unsigned long long)sep->extapp_bus);
-	dev_dbg(&sep->pdev->dev, "extapp size is %08x\n",
+	dev_dbg(&sep->pdev->dev, "extapp size is %08Zx\n",
 		sep->extapp_size);
 
 	return error;
@@ -210,7 +210,7 @@ static int sep_map_and_alloc_shared_area(struct sep_device *sep)
 		return -ENOMEM;
 	}
 	dev_dbg(&sep->pdev->dev,
-		"sep: shared_addr %x bytes @%p (bus %llx)\n",
+		"sep: shared_addr %Zx bytes @%p (bus %llx)\n",
 		sep->shared_size, sep->shared_addr,
 			(unsigned long long)sep->shared_bus);
 	return 0;
@@ -3395,25 +3395,25 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCSENDSEPCOMMAND is %x\n", SEP_IOCSENDSEPCOMMAND);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCALLOCDATAPOLL is %x\n", SEP_IOCALLOCDATAPOLL);
+		"SEP_IOCALLOCDATAPOLL is %lx\n", SEP_IOCALLOCDATAPOLL);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCCREATESYMDMATABLE is %x\n", SEP_IOCCREATESYMDMATABLE);
+		"SEP_IOCCREATESYMDMATABLE is %lx\n", SEP_IOCCREATESYMDMATABLE);
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCFREEDMATABLEDATA is %x\n", SEP_IOCFREEDMATABLEDATA);
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCSEPSTART is %x\n", SEP_IOCSEPSTART);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCSEPINIT is %x\n", SEP_IOCSEPINIT);
+		"SEP_IOCSEPINIT is %lx\n", SEP_IOCSEPINIT);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCGETSTATICPOOLADDR is %x\n", SEP_IOCGETSTATICPOOLADDR);
+		"SEP_IOCGETSTATICPOOLADDR is %lx\n", SEP_IOCGETSTATICPOOLADDR);
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCENDTRANSACTION is %x\n", SEP_IOCENDTRANSACTION);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCREALLOCEXTCACHE is %x\n", SEP_IOCREALLOCEXTCACHE);
+		"SEP_IOCREALLOCEXTCACHE is %lx\n", SEP_IOCREALLOCEXTCACHE);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCRARPREPAREMESSAGE is %x\n", SEP_IOCRARPREPAREMESSAGE);
+		"SEP_IOCRARPREPAREMESSAGE is %lx\n", SEP_IOCRARPREPAREMESSAGE);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCPREPAREDCB is %x\n", SEP_IOCPREPAREDCB);
+		"SEP_IOCPREPAREDCB is %lx\n", SEP_IOCPREPAREDCB);
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCFREEDCB is %x\n", SEP_IOCFREEDCB);
 
@@ -3736,7 +3736,7 @@ static int sep_callback(unsigned long sep_context_pointer)
 	}
 
 	dev_dbg(&sep->pdev->dev, "rar start is %p, phy is %llx,"
-		" size is %x\n",
+		" size is %Zx\n",
 		sep->rar_addr, (unsigned long long)sep->rar_bus,
 		sep->rar_size);
 
@@ -3864,7 +3864,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 		}
 
 		dev_dbg(&sep->pdev->dev, "rar start is %p, phy is %llx,"
-			" size is %x\n", sep->rar_addr,
+			" size is %Zx\n", sep->rar_addr,
 			(unsigned long long)sep->rar_bus,
 			sep->rar_size);
 	}
Signature · 1 line
1.7.2.2
#3 lore raw

Re: [PATCH 3/3] staging/sep: Fix sparse printk format warning

Quoted 1 line · On Mon, 29 Nov 2010 22:31:20 +0100 Peter Huewe wrote:

This patch fixes sparse's complaints about the wrong format string.

Are you sure? I'm used to these being gcc warnings, not sparse.

Also, this fixes the warnings on x86_64 but not on x86_32/i386:

linux-next-20101126/drivers/staging/sep/sep_driver.c: In function 'sep_ioctl':
linux-next-20101126/drivers/staging/sep/sep_driver.c:3397: warning: format '%lx' expects type 'long unsigned int', but argument 4 has type 'unsigned int' linux-next-20101126/drivers/staging/sep/sep_driver.c:3399: warning: format '%lx' expects type 'long unsigned int', but argument 4 has type 'unsigned int' linux-next-20101126/drivers/staging/sep/sep_driver.c:3405: warning: format '%lx' expects type 'long unsigned int', but argument 4 has type 'unsigned int' linux-next-20101126/drivers/staging/sep/sep_driver.c:3407: warning: format '%lx' expects type 'long unsigned int', but argument 4 has type 'unsigned int' linux-next-20101126/drivers/staging/sep/sep_driver.c:3411: warning: format '%lx' expects type 'long unsigned int', but argument 4 has type 'unsigned int' linux-next-20101126/drivers/staging/sep/sep_driver.c:3413: warning: format '%lx' expects type 'long unsigned int', but argument 4 has type 'unsigned int' linux-next-20101126/drivers/staging/sep/sep_driver.c:3415: warning: format '%lx' expects type 'long unsigned int', but argument 4 has type 'unsigned int'

Quoted 91 lines

---
LinuxVersion: linux-next-20101129

 drivers/staging/sep/sep_driver.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
drivers/staging/sep/sep_driver.c +12 -12
index cf5c897..86e676d 100644
@@ -112,7 +112,7 @@ static int sep_load_firmware(struct sep_device *sep)
 		sep->resident_addr);
 	dev_dbg(&sep->pdev->dev, "residnet bus is %lx\n",
 		(unsigned long)sep->resident_bus);
-	dev_dbg(&sep->pdev->dev, "resident size is %08x\n",
+	dev_dbg(&sep->pdev->dev, "resident size is %08Zx\n",
 		sep->resident_size);
 
 	/* set addresses for dcache (no loading needed) */
@@ -146,7 +146,7 @@ static int sep_load_firmware(struct sep_device *sep)
 		sep->cache_addr);
 	dev_dbg(&sep->pdev->dev, "cache bus is %08lx\n",
 		(unsigned long)sep->cache_bus);
-	dev_dbg(&sep->pdev->dev, "cache size is %08x\n",
+	dev_dbg(&sep->pdev->dev, "cache size is %08Zx\n",
 		sep->cache_size);
 
 	/* set addresses and load extapp */
@@ -167,7 +167,7 @@ static int sep_load_firmware(struct sep_device *sep)
 		sep->extapp_addr);
 	dev_dbg(&sep->pdev->dev, "extapp bus is %08llx\n",
 		(unsigned long long)sep->extapp_bus);
-	dev_dbg(&sep->pdev->dev, "extapp size is %08x\n",
+	dev_dbg(&sep->pdev->dev, "extapp size is %08Zx\n",
 		sep->extapp_size);
 
 	return error;
@@ -210,7 +210,7 @@ static int sep_map_and_alloc_shared_area(struct sep_device *sep)
 		return -ENOMEM;
 	}
 	dev_dbg(&sep->pdev->dev,
-		"sep: shared_addr %x bytes @%p (bus %llx)\n",
+		"sep: shared_addr %Zx bytes @%p (bus %llx)\n",
 		sep->shared_size, sep->shared_addr,
 			(unsigned long long)sep->shared_bus);
 	return 0;
@@ -3395,25 +3395,25 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCSENDSEPCOMMAND is %x\n", SEP_IOCSENDSEPCOMMAND);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCALLOCDATAPOLL is %x\n", SEP_IOCALLOCDATAPOLL);
+		"SEP_IOCALLOCDATAPOLL is %lx\n", SEP_IOCALLOCDATAPOLL);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCCREATESYMDMATABLE is %x\n", SEP_IOCCREATESYMDMATABLE);
+		"SEP_IOCCREATESYMDMATABLE is %lx\n", SEP_IOCCREATESYMDMATABLE);
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCFREEDMATABLEDATA is %x\n", SEP_IOCFREEDMATABLEDATA);
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCSEPSTART is %x\n", SEP_IOCSEPSTART);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCSEPINIT is %x\n", SEP_IOCSEPINIT);
+		"SEP_IOCSEPINIT is %lx\n", SEP_IOCSEPINIT);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCGETSTATICPOOLADDR is %x\n", SEP_IOCGETSTATICPOOLADDR);
+		"SEP_IOCGETSTATICPOOLADDR is %lx\n", SEP_IOCGETSTATICPOOLADDR);
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCENDTRANSACTION is %x\n", SEP_IOCENDTRANSACTION);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCREALLOCEXTCACHE is %x\n", SEP_IOCREALLOCEXTCACHE);
+		"SEP_IOCREALLOCEXTCACHE is %lx\n", SEP_IOCREALLOCEXTCACHE);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCRARPREPAREMESSAGE is %x\n", SEP_IOCRARPREPAREMESSAGE);
+		"SEP_IOCRARPREPAREMESSAGE is %lx\n", SEP_IOCRARPREPAREMESSAGE);
 	dev_dbg(&sep->pdev->dev,
-		"SEP_IOCPREPAREDCB is %x\n", SEP_IOCPREPAREDCB);
+		"SEP_IOCPREPAREDCB is %lx\n", SEP_IOCPREPAREDCB);
 	dev_dbg(&sep->pdev->dev,
 		"SEP_IOCFREEDCB is %x\n", SEP_IOCFREEDCB);
 
@@ -3736,7 +3736,7 @@ static int sep_callback(unsigned long sep_context_pointer)
 	}
 
 	dev_dbg(&sep->pdev->dev, "rar start is %p, phy is %llx,"
-		" size is %x\n",
+		" size is %Zx\n",
 		sep->rar_addr, (unsigned long long)sep->rar_bus,
 		sep->rar_size);
 

drivers/staging/sep/sep_driver.c static int __devinit sep_probe(struct pci_dev *pdev, · line 3870

Quoted 8 lines
drivers/staging/sep/sep_driver.c +1 -1
@@ -3864,7 +3864,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 		}
 
 		dev_dbg(&sep->pdev->dev, "rar start is %p, phy is %llx,"
-			" size is %x\n", sep->rar_addr,
+			" size is %Zx\n", sep->rar_addr,
 			(unsigned long long)sep->rar_bus,
 			sep->rar_size);
 	}

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#4 lore raw

Re: [PATCH 3/3] staging/sep: Fix sparse printk format warning

Quoted 1 line

Are you sure? I'm used to these being gcc warnings, not sparse.

You're right - these are generated by gcc ;) sorry for the confusion.

Quoted 1 line

Also, this fixes the warnings on x86_64 but not on x86_32/i386:

You're right again, I'm on x86_64 - so what should I use instead? (atleast the patch fixes the size_t format strings ;)

Peter

#5 lore raw

Re: [PATCH 3/3] staging/sep: Fix sparse printk format warning

Quoted 5 lines · On Mon, 29 Nov 2010 22:59:11 +0100 Peter Hüwe wrote:
Quoted 1 line

Are you sure? I'm used to these being gcc warnings, not sparse.

You're right - these are generated by gcc ;) sorry for the confusion.

Quoted 1 line

Also, this fixes the warnings on x86_64 but not on x86_32/i386:

You're right again, I'm on x86_64 - so what should I use instead?

I dunno, I've tried to fix this myself and the only thing that I have been successful with is casting those ioctl values to (unsigned long) and using %lx to print them.

Quoted 1 line

(atleast the patch fixes the size_t format strings ;)

agreed.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#6 lore raw

Re: [PATCH 3/3] staging/sep: Fix sparse printk format warning

Quoted 11 lines · Randy Dunlap
Quoted 5 lines · On Mon, 29 Nov 2010 22:59:11 +0100 Peter Hüwe wrote:
Quoted 1 line

Are you sure? I'm used to these being gcc warnings, not sparse.

You're right - these are generated by gcc ;) sorry for the confusion.

Quoted 1 line

Also, this fixes the warnings on x86_64 but not on x86_32/i386:

You're right again, I'm on x86_64 - so what should I use instead?

I dunno, I've tried to fix this myself and the only thing that I have been successful with is casting those ioctl values to (unsigned long) and using %lx to print them.

What about to remove that completely :)? I don't see what that could be good for -- everybody from userspace can print it...

regards,

Signature · 1 line
js
#7 lore raw

Re: [PATCH 1/3] staging: sep: Fix sparse warning 'do-while statement is not a compound statement'

In reply to Peter Huewe
Quoted 3 lines · Peter Huewe

This patch fixes the warning generated by sparse: 'do-while statement is not a compound statement' by adding the necessary brackets around the do block

This, and your other patches, no longer apply to the linux-next tree.

Care to redo them (and get the description right for the 3/3 patch) and resend them?

thanks,

greg k-h

#8 lore raw

PATCH 1/3 staging/sep: Fix sparse warning 'do-while statement is not a compound statement'

This patch fixes the warning generated by sparse: 'do-while statement is not a compound statement' by adding the necessary brackets around the do block

---
KernelVersion: linux-next-20101202

 drivers/staging/sep/sep_dev.h    |    4 ++--
 drivers/staging/sep/sep_driver.c |   12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/sep/sep_dev.h +2 -2
index 7b4993b..0ffe68c 100644
@@ -147,9 +147,9 @@ static inline u32 sep_read_reg(struct sep_device *dev, int reg)
 static inline void sep_wait_sram_write(struct sep_device *dev)
 {
 	u32 reg_val;
-	do
+	do {
 		reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR);
-	while (!(reg_val & 1));
+	} while (!(reg_val & 1));
 }
 
 
drivers/staging/sep/sep_driver.c +6 -6
index 7633111..d734887 100644
@@ -2587,9 +2587,9 @@ static int sep_start_handler(struct sep_device *sep)
 	dev_dbg(&sep->pdev->dev, "sep_start_handler start\n");
 
 	/* Wait in polling for message from SEP */
-	do
+	do {
 		reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
-	while (!reg_val);
+	} while (!reg_val);
 
 	/* Check the value */
 	if (reg_val == 0x1)
@@ -2754,9 +2754,9 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 	/* Wait for acknowledge */
 	dev_dbg(&sep->pdev->dev, "init; waiting for msg response\n");
 
-	do
+	do {
 		reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
-	while (!(reg_val & 0xFFFFFFFD));
+	} while (!(reg_val & 0xFFFFFFFD));
 
 	if (reg_val == 0x1) {
 		dev_warn(&sep->pdev->dev, "init; device int failed\n");
@@ -2774,9 +2774,9 @@ static int sep_init_handler(struct sep_device *sep, unsigned long arg)
 	/* Wait for response */
 	dev_dbg(&sep->pdev->dev, "init; waiting for zero set response\n");
 
-	do
+	do {
 		reg_val = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
-	while (reg_val != 0);
+	} while (reg_val != 0);
 
 end_function:
 	dev_dbg(&sep->pdev->dev, "init is done\n");
Signature · 1 line
1.7.2.2
#9 lore raw

PATCH 2/3 staging/sep: Fix sparse warning 'Using plain integer as NULL pointer'

In reply to Greg KH

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

---
KernelVersion: linux-next-20101202

 drivers/staging/sep/sep_driver.c |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)
drivers/staging/sep/sep_driver.c +19 -19
index d734887..2216bed 100644
@@ -459,12 +459,12 @@ static int sep_free_dma_table_data_handler(struct sep_device *sep)
 		}
 
 		/* Reset all the values */
-		dma->in_page_array = 0;
-		dma->out_page_array = 0;
+		dma->in_page_array = NULL;
+		dma->out_page_array = NULL;
 		dma->in_num_pages = 0;
 		dma->out_num_pages = 0;
-		dma->in_map_array = 0;
-		dma->out_map_array = 0;
+		dma->in_map_array = NULL;
+		dma->out_map_array = NULL;
 		dma->in_map_num_entries = 0;
 		dma->out_map_num_entries = 0;
 	}
@@ -1114,13 +1114,13 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
 	if (in_out_flag == SEP_DRIVER_IN_FLAG) {
 		*lli_array_ptr = lli_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages = 1;
-		sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
+		sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = NULL;
 		sep->dma_res_arr[sep->nr_dcb_creat].in_map_array = map_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].in_map_num_entries = 1;
 	} else {
 		*lli_array_ptr = lli_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].out_num_pages = 1;
-		sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = 0;
+		sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = NULL;
 		sep->dma_res_arr[sep->nr_dcb_creat].out_map_array = map_array;
 		sep->dma_res_arr[sep->nr_dcb_creat].out_map_num_entries = 1;
 	}
@@ -1216,7 +1216,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
 	result = get_user_pages(current, current->mm, app_virt_addr,
 		num_pages,
 		((in_out_flag == SEP_DRIVER_IN_FLAG) ? 0 : 1),
-		0, page_array, 0);
+		0, page_array, NULL);
 
 	up_read(&current->mm->mmap_sem);
 
@@ -1709,7 +1709,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 	dev_dbg(&sep->pdev->dev, "block_size is %x\n", block_size);
 
 	/* Initialize the pages pointers */
-	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
+	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = NULL;
 	sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages = 0;
 
 	/* Set the kernel address for first table to be allocated */
@@ -1745,7 +1745,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 		sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages);
 
 	current_entry = 0;
-	info_entry_ptr = 0;
+	info_entry_ptr = NULL;
 
 	sep_lli_entries = sep->dma_res_arr[sep->nr_dcb_creat].in_num_pages;
 
@@ -1794,7 +1794,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
 			in_lli_table_ptr,
 			&current_entry, &num_entries_in_table, table_data_size);
 
-		if (info_entry_ptr == 0) {
+		if (info_entry_ptr == NULL) {
 
 			/* Set the output parameters to physical addresses */
 			*lli_table_ptr = sep_shared_area_virt_to_bus(sep,
@@ -1877,13 +1877,13 @@ static int sep_construct_dma_tables_from_lli(
 	/* Points to the area where next lli table can be allocated */
 	u32 lli_table_alloc_addr = 0;
 	/* Input lli table */
-	struct sep_lli_entry *in_lli_table_ptr = 0;
+	struct sep_lli_entry *in_lli_table_ptr = NULL;
 	/* Output lli table */
-	struct sep_lli_entry *out_lli_table_ptr = 0;
+	struct sep_lli_entry *out_lli_table_ptr = NULL;
 	/* Pointer to the info entry of the table - the last entry */
-	struct sep_lli_entry *info_in_entry_ptr = 0;
+	struct sep_lli_entry *info_in_entry_ptr = NULL;
 	/* Pointer to the info entry of the table - the last entry */
-	struct sep_lli_entry *info_out_entry_ptr = 0;
+	struct sep_lli_entry *info_out_entry_ptr = NULL;
 	/* Points to the first entry to be processed in the lli_in_array */
 	u32 current_in_entry = 0;
 	/* Points to the first entry to be processed in the lli_out_array */
@@ -1999,7 +1999,7 @@ static int sep_construct_dma_tables_from_lli(
 			table_data_size);
 
 		/* If info entry is null - this is the first table built */
-		if (info_in_entry_ptr == 0) {
+		if (info_in_entry_ptr == NULL) {
 			/* Set the output parameters to physical addresses */
 			*lli_table_in_ptr =
 			sep_shared_area_virt_to_bus(sep, in_lli_table_ptr);
@@ -2136,8 +2136,8 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
 	}
 
 	/* Initialize the pages pointers */
-	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = 0;
-	sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = 0;
+	sep->dma_res_arr[sep->nr_dcb_creat].in_page_array = NULL;
+	sep->dma_res_arr[sep->nr_dcb_creat].out_page_array = NULL;
 
 	/* Lock the pages of the buffer and translate them to pages */
 	if (is_kva == true) {
@@ -2264,7 +2264,7 @@ static int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
 	/* Size of tail */
 	u32 tail_size = 0;
 	/* Address of the created DCB table */
-	struct sep_dcblock *dcb_table_ptr = 0;
+	struct sep_dcblock *dcb_table_ptr = NULL;
 	/* The physical address of the first input DMA table */
 	dma_addr_t in_first_mlli_address = 0;
 	/* Number of entries in the first input DMA table */
@@ -2545,7 +2545,7 @@ static int sep_get_static_pool_addr_handler(struct sep_device *sep,
 	unsigned long arg)
 {
 	struct stat_pool_addr_struct command_args;
-	u32 *static_pool_addr = 0;
+	u32 *static_pool_addr = NULL;
 	unsigned long addr_hold;
 
 	dev_dbg(&sep->pdev->dev, "sep_get_static_pool_addr_handler start\n");
Signature · 1 line
1.7.2.2
#10 lore raw

PATCH 3/3 staging/sep: Fix printk format warning

In reply to Greg KH

This patch fixes gcc's complaints about the wrong format string for size_t arguments:
"format '%x' expects type 'unsigned int', but argument has type 'size_t'"

---
KernelVersion: linux-next-20101202

 drivers/staging/sep/sep_driver.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/sep/sep_driver.c +6 -6
index 2216bed..f2c216d 100644
@@ -110,7 +110,7 @@ static int sep_load_firmware(struct sep_device *sep)
 		sep->resident_addr);
 	dev_dbg(&sep->pdev->dev, "resident bus is %lx\n",
 		(unsigned long)sep->resident_bus);
-	dev_dbg(&sep->pdev->dev, "resident size is %08x\n",
+	dev_dbg(&sep->pdev->dev, "resident size is %08zx\n",
 		sep->resident_size);
 
 	/* Set addresses for dcache (no loading needed) */
@@ -144,7 +144,7 @@ static int sep_load_firmware(struct sep_device *sep)
 		sep->cache_addr);
 	dev_dbg(&sep->pdev->dev, "cache bus is %08lx\n",
 		(unsigned long)sep->cache_bus);
-	dev_dbg(&sep->pdev->dev, "cache size is %08x\n",
+	dev_dbg(&sep->pdev->dev, "cache size is %08zx\n",
 		sep->cache_size);
 
 	/* Set addresses and load extapp */
@@ -165,7 +165,7 @@ static int sep_load_firmware(struct sep_device *sep)
 		sep->extapp_addr);
 	dev_dbg(&sep->pdev->dev, "extapp bus is %08llx\n",
 		(unsigned long long)sep->extapp_bus);
-	dev_dbg(&sep->pdev->dev, "extapp size is %08x\n",
+	dev_dbg(&sep->pdev->dev, "extapp size is %08zx\n",
 		sep->extapp_size);
 
 	return error;
@@ -205,7 +205,7 @@ static int sep_map_and_alloc_shared_area(struct sep_device *sep)
 		return -ENOMEM;
 	}
 	dev_dbg(&sep->pdev->dev,
-		"shared_addr %x bytes @%p (bus %llx)\n",
+		"shared_addr %zx bytes @%p (bus %llx)\n",
 				sep->shared_size, sep->shared_addr,
 				(unsigned long long)sep->shared_bus);
 	return 0;
@@ -3290,7 +3290,7 @@ static int sep_callback(unsigned long sep_context_pointer)
 		error = -ENOMEM;
 		goto end_function;
 	}
-	dev_dbg(&sep->pdev->dev, "rar start is %p, phy is %llx, size is %x\n",
+	dev_dbg(&sep->pdev->dev, "rar start is %p, phy is %llx, size is %zx\n",
 			sep->rar_addr, (unsigned long long)sep->rar_bus,
 			sep->rar_size);
 
@@ -3537,7 +3537,7 @@ static int __devinit sep_probe(struct pci_dev *pdev,
 		}
 
 		dev_dbg(&sep->pdev->dev, "rar start is %p, phy is %llx,"
-			" size is %x\n", sep->rar_addr,
+			" size is %zx\n", sep->rar_addr,
 			(unsigned long long)sep->rar_bus,
 			sep->rar_size);
 	}
Signature · 1 line
1.7.2.2