---
 src/simfs.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/simfs.c b/src/simfs.c
index 5f459ab..258a42f 100644
--- a/src/simfs.c
+++ b/src/simfs.c
@@ -59,6 +59,7 @@ static gboolean sim_fs_op_read_block(gpointer user_data);
 struct sim_fs_op {
        int id;
        unsigned char *buffer;
+       int bufoff;
        enum ofono_sim_file_structure structure;
        unsigned short offset;
        gboolean info_only;
@@ -217,7 +218,6 @@ static void sim_fs_op_read_block_cb(const struct 
ofono_error *error,
        struct sim_fs_op *op = g_queue_peek_head(fs->op_q);
        int start_block;
        int end_block;
-       int bufoff;
        int dataoff;
        int tocopy;
 
@@ -230,25 +230,25 @@ static void sim_fs_op_read_block_cb(const struct 
ofono_error *error,
        end_block = (op->offset + (op->num_bytes - 1)) / 256;
 
        if (op->current == start_block) {
-               bufoff = 0;
+               op->bufoff = 0;
                dataoff = op->offset % 256;
                tocopy = MIN(256 - op->offset % 256,
                                op->num_bytes - op->current * 256);
        } else {
-               bufoff = (op->current - start_block - 1) * 256 +
-                               op->offset % 256;
                dataoff = 0;
                tocopy = MIN(256, op->num_bytes - op->current * 256);
        }
 
        DBG("bufoff: %d, dataoff: %d, tocopy: %d",
-                               bufoff, dataoff, tocopy);
+                               op->bufoff, dataoff, tocopy);
 
-       memcpy(op->buffer + bufoff, data + dataoff, tocopy);
+       memcpy(op->buffer + op->bufoff, data + dataoff, tocopy);
        cache_block(fs, op->current, 256, data, len);
 
        op->current++;
 
+       op->bufoff += tocopy;
+
        if (op->current > end_block) {
                ofono_sim_file_read_cb_t cb = op->cb;
 
-- 
1.7.2.3

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to