summaryrefslogtreecommitdiffstats
path: root/common/state/backend_bucket_direct.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-03-23 09:16:14 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 18:43:53 +0200
commit9948003da46c27b45d4479124407ed7805d84a02 (patch)
tree8eaca5b4873abd1b957b3cfe729b066b3ec9a60e /common/state/backend_bucket_direct.c
parentb7d9863dae31d7d4d3d4a9d671c4595287243b98 (diff)
downloadbarebox-9948003da46c27b45d4479124407ed7805d84a02.tar.gz
state: replace len_hint logic
The len_hint mechanism is rather hard to understand as it's not clear from where to where the hint is passed and also it's not clear what happens if the hint is empty or wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state/backend_bucket_direct.c')
-rw-r--r--common/state/backend_bucket_direct.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index 5225433..06a5433 100644
--- a/common/state/backend_bucket_direct.c
+++ b/common/state/backend_bucket_direct.c
@@ -47,7 +47,7 @@ static inline struct state_backend_storage_bucket_direct
static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
*bucket, uint8_t ** buf_out,
- ssize_t * len_hint)
+ ssize_t * len_out)
{
struct state_backend_storage_bucket_direct *direct =
get_bucket_direct(bucket);
@@ -69,18 +69,13 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
if (meta.magic == direct_magic) {
read_len = meta.written_length;
} else {
- if (*len_hint)
- read_len = *len_hint;
- else
- read_len = direct->max_size;
+ read_len = direct->max_size;
ret = lseek(direct->fd, direct->offset, SEEK_SET);
if (ret < 0) {
dev_err(direct->dev, "Failed to seek file, %d\n", ret);
return ret;
}
}
- if (direct->max_size)
- read_len = min(read_len, direct->max_size);
buf = xmalloc(read_len);
if (!buf)
@@ -94,7 +89,7 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
}
*buf_out = buf;
- *len_hint = read_len;
+ *len_out = read_len;
return 0;
}