lkml.org 
[lkml]   [2008]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] relay: When unsigned ret cannot store a negative value
On Sat, 29 Nov 2008 10:38:06 -0500
roel kluin <roel.kluin@gmail.com> wrote:

> When unsigned ret cannot store a negative value
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> UNTESTED! is this the way to go?
>
> diff --git a/kernel/relay.c b/kernel/relay.c
> index 32b0bef..c9d62e5 100644
> --- a/kernel/relay.c
> +++ b/kernel/relay.c
> @@ -1220,7 +1220,8 @@ static int subbuf_splice_actor(struct file *in,
> unsigned int flags,
> int *nonpad_ret)
> {
> - unsigned int pidx, poff, total_len, subbuf_pages, nr_pages, ret;
> + unsigned int pidx, poff, total_len, subbuf_pages, nr_pages;
> + ssize_t ret;
> struct rchan_buf *rbuf = in->private_data;
> unsigned int subbuf_size = rbuf->chan->subbuf_size;
> uint64_t pos = (uint64_t) *ppos;
> @@ -1289,7 +1290,8 @@ static int subbuf_splice_actor(struct file *in,
> if (!spd.nr_pages)
> return 0;
>
> - ret = *nonpad_ret = splice_to_pipe(pipe, &spd);
> + ret = splice_to_pipe(pipe, &spd);
> + *nonpad_ret = ret;
> if (ret < 0 || ret < total_len)
> return ret;
>

Yeah, this code needs help. subbuf_splice_actor() returns `int', but
carefully calculates and returns an unsigned type.

I suspect that quite a bit of code in there (including
relay_file_splice_read()) should be gone through and have its choice of
types reviewed and fixed. Probably by converting things to ssize_t.




\
 
 \ /
  Last update: 2008-12-02 23:15    [W:0.048 / U:0.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site