Re: [PATCH] Type cast some size_t arguments to 'unsigned int' to avoid (harmless) gcc printk warnings.

H. Peter Anvin
2007-05-09T03:42:16Z

Chris Wedgwood wrote:
> Signed-off-by: Chris Wedgwood <cw@f00f.org>
> ---
> net/sunrpc/sched.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
> index 4a53e94..60df3c1 100644
> --- a/net/sunrpc/sched.c
> +++ b/net/sunrpc/sched.c
> @@ -764,7 +764,7 @@ void *rpc_malloc(struct rpc_task *task, size_t size)
> buf = kmalloc(size, gfp);
> *buf = size;
> dprintk("RPC: %5u allocated buffer of size %u at %p\n",
> - task->tk_pid, size, buf);
> + task->tk_pid, (unsigned int)size, buf);
> return (void *) ++buf;
> }
>
> @@ -783,7 +783,7 @@ void rpc_free(void *buffer)
> buf--;
>
> dprintk("RPC: freeing buffer of size %u at %p\n",
> - size, buf);
> + (unsigned int)size, buf);
> if (size <= RPC_BUFFER_MAXSIZE)
> mempool_free(buf, rpc_buffer_mempool);
> else

NAK. This is wrong for multiple reasons.
Use %zu instead.

-hpa