writesize is initialized with the same value in each loop iteration, Instead, initialize it once outside the loop. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- common/state/backend_storage.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c index e1869830bd..0808c5c0b4 100644 --- a/common/state/backend_storage.c +++ b/common/state/backend_storage.c @@ -268,6 +268,7 @@ static int state_storage_mtd_buckets_init(struct state_backend_storage *storage, ssize_t end = dev_offset + max_size; int nr_copies = 0; off_t offset; + ssize_t writesize; if (!end || end > meminfo->size) end = meminfo->size; @@ -278,15 +279,16 @@ static int state_storage_mtd_buckets_init(struct state_backend_storage *storage, return -EINVAL; } + if (circular) + writesize = meminfo->writesize; + else + writesize = meminfo->erasesize; + for (offset = dev_offset; offset < end; offset += meminfo->erasesize) { int ret; - ssize_t writesize = meminfo->writesize; unsigned int eraseblock = offset / meminfo->erasesize; bool lazy_init = true; - if (!circular) - writesize = meminfo->erasesize; - ret = state_backend_bucket_circular_create(storage->dev, path, &bucket, eraseblock, -- 2.11.0 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox