Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] simfs: fix incorrect math again
Date: Tue, 02 Nov 2010 09:57:27 -0500	[thread overview]
Message-ID: <4CD026D7.5060806@gmail.com> (raw)
In-Reply-To: <20101102074108.059f1d24@kcaccard-MOBL3>

[-- Attachment #1: Type: text/plain, Size: 1749 bytes --]

Hi Kristen,

On 11/02/2010 09:41 AM, Kristen Carlson Accardi wrote:
> On Thu, 14 Oct 2010 11:18:00 -0700
> Kristen Carlson Accardi <kristen@linux.intel.com> wrote:
> 
>> ---
>>  src/simfs.c |    6 ++----
>>  1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/src/simfs.c b/src/simfs.c
>> index fd768ef..bcb6ff8 100644
>> --- a/src/simfs.c
>> +++ b/src/simfs.c
>> @@ -231,8 +231,7 @@ static void sim_fs_op_read_block_cb(const struct ofono_error *error,
>>  		tocopy = MIN(256 - op->offset % 256,
>>  				op->num_bytes - op->current * 256);
>>  	} else {
>> -		bufoff = (op->current - start_block - 1) * 256 +
>> -				op->offset % 256;
>> +		bufoff = op->current * 256;
>>  		dataoff = 0;
>>  		tocopy = MIN(256, op->num_bytes - op->current * 256);
>>  	}
>> @@ -294,8 +293,7 @@ static gboolean sim_fs_op_read_block(gpointer user_data)
>>  			toread = MIN(256 - op->offset % 256,
>>  					op->num_bytes - op->current * 256);
>>  		} else {
>> -			bufoff = (op->current - start_block - 1) * 256 +
>> -					op->offset % 256;
>> +			bufoff = op->current * 256;
>>  			seekoff = SIM_CACHE_HEADER_SIZE + op->current * 256;
>>  			toread = MIN(256, op->num_bytes - op->current * 256);
>>  		}
> 
> Denis - any feedback on this patch?  If we don't add this bugfix,
> reads > 256 bytes will be broken.
> 

I don't believe the patch is correct:

In sim_fs_op_read_block:
...
        if (op->current == start_block) {
                op->buffer = g_try_new0(unsigned char, op->num_bytes);
...

We don't allocate a buffer for the entire file, just for the portion
we're reading.  So setting buffoff to op->current * 256 will not work on
reads that start at non-zero offsets.

Regards,
-Denis

  reply	other threads:[~2010-11-02 14:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-04 22:33 [PATCH 0/4] Icon patches (rebased) Kristen Carlson Accardi
2010-10-04 22:33 ` [PATCH 1/4] simfs: cache images Kristen Carlson Accardi
2010-10-12  1:16   ` Denis Kenzior
2010-10-04 22:33 ` [PATCH 2/4] sim: implement GetIcon Kristen Carlson Accardi
2010-10-13 13:44   ` Denis Kenzior
2010-10-04 22:33 ` [PATCH 3/4] simfs: fix incorrect math when calculating length to copy Kristen Carlson Accardi
2010-10-13 13:44   ` Denis Kenzior
2010-10-14 18:18     ` [PATCH] simfs: fix incorrect math again Kristen Carlson Accardi
2010-11-02 14:41       ` Kristen Carlson Accardi
2010-11-02 14:57         ` Denis Kenzior [this message]
2010-11-29 19:13           ` [PATCH] simfs: make sim_fs_read_block work for > 256 byte files Kristen Carlson Accardi
2010-10-04 22:33 ` [PATCH 4/4] simutil: add file type for EFimg Kristen Carlson Accardi
2010-10-12  3:16   ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CD026D7.5060806@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox