[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <961aa3350806020528t4224f435qfb8406328c38c33f@mail.gmail.com>
Date: Mon, 2 Jun 2008 21:28:48 +0900
From: "Akinobu Mita" <akinobu.mita@...il.com>
To: "Christian Borntraeger" <borntraeger@...ibm.com>
Cc: linux-kernel@...r.kernel.org,
"Martin Schwidefsky" <schwidefsky@...ibm.com>,
"Heiko Carstens" <heiko.carstens@...ibm.com>, linux390@...ibm.com,
linux-s390@...r.kernel.org
Subject: Re: [patch -v2 06/23] s390/vmcp: use simple_read_from_buffer
2008/6/2 Christian Borntraeger <borntraeger@...ibm.com>:
> Am Montag, 2. Juni 2008 schrieb akinobu.mita@...il.com:
>
>> - tocopy = min(session->resp_size - (size_t) (*ppos), count);
>> - tocopy = min(tocopy, session->bufsize - (size_t) (*ppos));
>> + ret = simple_read_from_buffer(buff, count, ppos,
>> + session->response, session->resp_size);
>>
>
> Its not that simple. The z/VM Diagnose 8 has a quite interesting return value.
>
> - session->bufsize is the size of the buffer as we allocated and know
> - session->resp_size is the size of the data - no matter if the buffer was
> large enough. z/VM is smart enough to not go beyond the buffer, but it tells
> us how many bytes it skipped. resp_size contains bufsize + skipped_bytes.
>
> Unfortunately there is no end of string delimiter and we have to use the
> response size.
>
> There are two cases:
> 1. The buffer was large enough, so we can use session->resp_size
> 2. The buffer was not large enough and output was truncated. we must now use
> session->bufsize
Thanks. I made too much simplified the original code.
So I'll change these lines to be
size_t size = min_t(size_t, session->resp_size, session->bufsize);
ret = simple_read_from_buffer(buff, count, ppos, session->response, size);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists