diff mbox series

[3.16-stable,11/87] iio: fix printk format string warning

Message ID 20170505194745.3627137-12-arnd@arndb.de
State New
Headers show
Series build warnings and errors | expand

Commit Message

Arnd Bergmann May 5, 2017, 7:46 p.m. UTC
On 3.16, we get this warning:

drivers/iio/industrialio-core.c: In function 'iio_format_value':
drivers/iio/industrialio-core.c:408:30: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long int' [-Werror=format=]

Upstream commit 8f57e4d930d4 ("include/linux/kernel.h: change abs() macro
so it uses consistent return type") addressed this in a more verbose
way, but here we can simply add a type cast to shut up the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/iio/industrialio-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.9.0

Comments

Ben Hutchings Nov. 6, 2017, 4:55 p.m. UTC | #1
On Fri, 2017-05-05 at 21:46 +0200, Arnd Bergmann wrote:
> On 3.16, we get this warning:

> 

> drivers/iio/industrialio-core.c: In function 'iio_format_value':

> drivers/iio/industrialio-core.c:408:30: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long int' [-Werror=format=]

> 

> Upstream commit 8f57e4d930d4 ("include/linux/kernel.h: change abs() macro

> so it uses consistent return type") addressed this in a more verbose

> way, but here we can simply add a type cast to shut up the warning.


I'm skipping this one because I have now cherry-picked that commit.

Ben.

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

> ---

>  drivers/iio/industrialio-core.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c

> index 230cbdda6ce1..669c27d93049 100644

> --- a/drivers/iio/industrialio-core.c

> +++ b/drivers/iio/industrialio-core.c

> @@ -405,7 +405,7 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals)

>  	case IIO_VAL_FRACTIONAL:

>  		tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]);

>  		vals[0] = (int)div_s64_rem(tmp, 1000000000, &vals[1]);

> -		return sprintf(buf, "%d.%09u\n", vals[0], abs(vals[1]));

> +		return sprintf(buf, "%d.%09ld\n", vals[0], abs(vals[1]));

>  	case IIO_VAL_FRACTIONAL_LOG2:

>  		tmp = (s64)vals[0] * 1000000000LL >> vals[1];

>  		vals[1] = do_div(tmp, 1000000000LL);

-- 
Ben Hutchings
It is a miracle that curiosity survives formal education. - Albert
Einstein
diff mbox series

Patch

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 230cbdda6ce1..669c27d93049 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -405,7 +405,7 @@  ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals)
 	case IIO_VAL_FRACTIONAL:
 		tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]);
 		vals[0] = (int)div_s64_rem(tmp, 1000000000, &vals[1]);
-		return sprintf(buf, "%d.%09u\n", vals[0], abs(vals[1]));
+		return sprintf(buf, "%d.%09ld\n", vals[0], abs(vals[1]));
 	case IIO_VAL_FRACTIONAL_LOG2:
 		tmp = (s64)vals[0] * 1000000000LL >> vals[1];
 		vals[1] = do_div(tmp, 1000000000LL);