summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-03-22 13:03:08 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 13:57:45 +0200
commitfa4ef25aa012bf0b11a0d7b89798ee5275931302 (patch)
treede4599520a46745c4539a88f3ea27612c794f6d8
parentcd8b5954c6a6e918dae96dd14ff605a819e08d51 (diff)
downloaddt-utils-fa4ef25aa012bf0b11a0d7b89798ee5275931302.tar.gz
state: storage: initialize variable once outside loop
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@pengutronix.de>
-rw-r--r--src/barebox-state/backend_storage.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/barebox-state/backend_storage.c b/src/barebox-state/backend_storage.c
index c619b3e..3c2fdd9 100644
--- a/src/barebox-state/backend_storage.c
+++ b/src/barebox-state/backend_storage.c
@@ -269,6 +269,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;
@@ -279,15 +280,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,