mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/7] Harmonize barebox' and dt-utils' state code
@ 2019-02-08  7:15 Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 1/7] common: state: fix compiler warnings about wrong type conversion in messages Ulrich Ölmann
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Ulrich Ölmann @ 2019-02-08  7:15 UTC (permalink / raw)
  To: Barebox List

These patches remove further differences between the common codebase of barebox'
and dt-utils' state implementation.

Ulrich Ölmann (7):
  common: state: fix compiler warnings about wrong type conversion in
    messages
  common: state: fix formatting of "off_t" variables
  common: state: fix formatting of "uint32_t" variables
  common: state: harmonize code with dt-utils
  common: state: harmonize code with dt-utils
  common: state: harmonize code with dt-utils
  common: state: harmonize code with dt-utils

 common/state/backend_bucket_circular.c | 40 ++++++++++++++------------
 common/state/backend_bucket_direct.c   |  3 ++
 common/state/backend_storage.c         | 22 +++++++-------
 common/state/state.c                   | 10 +++++--
 4 files changed, 44 insertions(+), 31 deletions(-)

-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/7] common: state: fix compiler warnings about wrong type conversion in messages
  2019-02-08  7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
@ 2019-02-08  7:15 ` Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 2/7] common: state: fix formatting of "off_t" variables Ulrich Ölmann
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ulrich Ölmann @ 2019-02-08  7:15 UTC (permalink / raw)
  To: Barebox List

To harmonize the common codebase this ports the remaining hunks of the following
dt-utils commit, as the residual hunks have independently already been done
before in barebox commit 1afbf6b5680e ("state: fix compile warnings for dev_err
expansion"):

| commit 9f1db73234b40f4ea071421e8179065df16211ec
| Author: Philipp Rosenberger <p.rosenberger@linutronix.de>
| Date:   Thu Oct 18 09:17:23 2018 +0200
|
|     Fix compiler warnings about wrong type conversion in messages.
|
|     These warning were observed with gcc-6.3 on x86-64.
|
|     Signed-off-by: Philipp Rosenberger <p.rosenberger@linutronix.de>
|     Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 common/state/backend_bucket_circular.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 4b71d8751da6..5a85650f4004 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -165,13 +165,13 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ
 		return ret;
 	}
 
-	dev_dbg(circ->dev, "Read state from %ld length %zd\n", offset,
+	dev_dbg(circ->dev, "Read state from %ld length %d\n", offset,
 		len);
 
 
 	ret = read_full(circ->fd, buf, len);
 	if (ret < 0) {
-		dev_err(circ->dev, "Failed to read circular storage len %zd, %d\n",
+		dev_err(circ->dev, "Failed to read circular storage len %d, %d\n",
 			len, ret);
 		free(buf);
 	}
@@ -196,7 +196,7 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir
 
 	ret = write_full(circ->fd, buf, len);
 	if (ret < 0) {
-		dev_err(circ->dev, "Failed to write circular to %ld length %zd, %d\n",
+		dev_err(circ->dev, "Failed to write circular to %ld length %d, %d\n",
 			offset, len, ret);
 		return ret;
 	}
@@ -207,7 +207,7 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir
 	 */
 	flush(circ->fd);
 
-	dev_dbg(circ->dev, "Written state to offset %ld length %zd data length %zd\n",
+	dev_dbg(circ->dev, "Written state to offset %ld length %d data length %d\n",
 		offset, len, len);
 
 	return 0;
@@ -298,7 +298,7 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck
 	void *write_buf;
 
 	if (written_length > circ->max_size) {
-		dev_err(circ->dev, "Error, state data too big to be written, to write: %zd, writesize: %zd, length: %zd, available: %zd\n",
+		dev_err(circ->dev, "Error, state data too big to be written, to write: %d, writesize: %zd, length: %zd, available: %zd\n",
 			written_length, circ->writesize, len, circ->max_size);
 		return -E2BIG;
 	}
@@ -345,12 +345,12 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck
 
 	ret = state_mtd_peb_write(circ, write_buf, offset, written_length);
 	if (ret < 0 && ret != -EUCLEAN) {
-		dev_err(circ->dev, "Failed to write circular to %ld length %zd, %d\n",
+		dev_err(circ->dev, "Failed to write circular to %ld length %d, %d\n",
 			offset, written_length, ret);
 		goto out_free;
 	}
 
-	dev_dbg(circ->dev, "Written state to PEB %u offset %ld length %zd data length %zd\n",
+	dev_dbg(circ->dev, "Written state to PEB %u offset %ld length %d data length %zd\n",
 		circ->eraseblock, offset, written_length, len);
 
 out_free:
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/7] common: state: fix formatting of "off_t" variables
  2019-02-08  7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 1/7] common: state: fix compiler warnings about wrong type conversion in messages Ulrich Ölmann
@ 2019-02-08  7:15 ` Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 3/7] common: state: fix formatting of "uint32_t" variables Ulrich Ölmann
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ulrich Ölmann @ 2019-02-08  7:15 UTC (permalink / raw)
  To: Barebox List

To harmonize the common codebase this ports the following dt-utils commit:

| commit 89d033284cb69f834c1f2195c9e99a3d7f585cf1
| Author: Ulrich Ölmann <u.oelmann@pengutronix.de>
| Date:   Sun Feb 3 22:48:06 2019 +0100
|
|     state: fix formatting of "off_t" variables
|
|     Explicitely casting an "off_t" variable to "long long" and formatting it via
|     "%lld" or "%llx" respectively makes 32- as well as 64-bit compilers
|     happy (tested with gcc-8.2.1 and clang-7.0.1).
|
|     Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
|     Signed-off-by: Roland Hieber <rhi@pengutronix.de>

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 common/state/backend_bucket_circular.c | 32 +++++++++++++-------------
 common/state/backend_storage.c         | 20 ++++++++--------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 5a85650f4004..ae15fa2529c2 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -161,11 +161,11 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ
 	ret = lseek(circ->fd, offset, SEEK_SET);
 	if (ret < 0) {
 		dev_err(circ->dev, "Failed to set circular read position to %lld, %d\n",
-			offset, ret);
+			(long long) offset, ret);
 		return ret;
 	}
 
-	dev_dbg(circ->dev, "Read state from %ld length %d\n", offset,
+	dev_dbg(circ->dev, "Read state from %lld length %d\n", (long long) offset,
 		len);
 
 
@@ -189,15 +189,15 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir
 
 	ret = lseek(circ->fd, offset, SEEK_SET);
 	if (ret < 0) {
-		dev_err(circ->dev, "Failed to set position for circular write %ld, %d\n",
-			offset, ret);
+		dev_err(circ->dev, "Failed to set position for circular write %lld, %d\n",
+			(long long) offset, ret);
 		return ret;
 	}
 
 	ret = write_full(circ->fd, buf, len);
 	if (ret < 0) {
-		dev_err(circ->dev, "Failed to write circular to %ld length %d, %d\n",
-			offset, len, ret);
+		dev_err(circ->dev, "Failed to write circular to %lld length %d, %d\n",
+			(long long) offset, len, ret);
 		return ret;
 	}
 
@@ -207,8 +207,8 @@ static int state_mtd_peb_write(struct state_backend_storage_bucket_circular *cir
 	 */
 	flush(circ->fd);
 
-	dev_dbg(circ->dev, "Written state to offset %ld length %d data length %d\n",
-		offset, len, len);
+	dev_dbg(circ->dev, "Written state to offset %lld length %d data length %d\n",
+		(long long) offset, len, len);
 
 	return 0;
 }
@@ -265,8 +265,8 @@ static int state_backend_bucket_circular_read(struct state_backend_storage_bucke
 	if (!buf)
 		return -ENOMEM;
 
-	dev_dbg(circ->dev, "Read state from PEB %u global offset %ld length %zd\n",
-		circ->eraseblock, offset, read_len);
+	dev_dbg(circ->dev, "Read state from PEB %u global offset %lld length %zd\n",
+		circ->eraseblock, (long long) offset, read_len);
 
 	ret = state_mtd_peb_read(circ, buf, offset, read_len);
 	if (ret < 0 && ret != -EUCLEAN) {
@@ -345,13 +345,13 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck
 
 	ret = state_mtd_peb_write(circ, write_buf, offset, written_length);
 	if (ret < 0 && ret != -EUCLEAN) {
-		dev_err(circ->dev, "Failed to write circular to %ld length %d, %d\n",
-			offset, written_length, ret);
+		dev_err(circ->dev, "Failed to write circular to %lld length %d, %d\n",
+			(long long) offset, written_length, ret);
 		goto out_free;
 	}
 
-	dev_dbg(circ->dev, "Written state to PEB %u offset %ld length %d data length %zd\n",
-		circ->eraseblock, offset, written_length, len);
+	dev_dbg(circ->dev, "Written state to PEB %u offset %lld length %d data length %zd\n",
+		circ->eraseblock, (long long) offset, written_length, len);
 
 out_free:
 	free(write_buf);
@@ -445,8 +445,8 @@ static int bucket_circular_is_block_bad(struct state_backend_storage_bucket_circ
 
 	ret = ioctl(circ->fd, MEMGETBADBLOCK, &offs);
 	if (ret < 0)
-		dev_err(circ->dev, "Failed to use ioctl to check for bad block at offset %ld, %d\n",
-			offs, ret);
+		dev_err(circ->dev, "Failed to use ioctl to check for bad block at offset %lld, %d\n",
+			(long long) offs, ret);
 
 	return ret;
 }
diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c
index c6ebe86244ab..8cd822eec486 100644
--- a/common/state/backend_storage.c
+++ b/common/state/backend_storage.c
@@ -111,11 +111,11 @@ refresh:
 	ret = bucket->write(bucket, buf, len);
 
 	if (ret) {
-		dev_warn(storage->dev, "Failed to restore bucket %d@0x%08lx\n",
-			 bucket->num, bucket->offset);
+		dev_warn(storage->dev, "Failed to restore bucket %d@0x%08llx\n",
+			 bucket->num, (long long) bucket->offset);
 	} else {
-		dev_info(storage->dev, "restored bucket %d@0x%08lx\n",
-			 bucket->num, bucket->offset);
+		dev_info(storage->dev, "restored bucket %d@0x%08llx\n",
+			 bucket->num, (long long) bucket->offset);
 		bucket->needs_refresh = 0;
 	}
 
@@ -166,7 +166,7 @@ int state_storage_read(struct state_backend_storage *storage,
 		if (!ret && !bucket_used)
 			bucket_used = bucket;
 		if (ret)
-			dev_info(storage->dev, "Ignoring broken bucket %d@0x%08lx...\n", bucket->num, bucket->offset);
+			dev_info(storage->dev, "Ignoring broken bucket %d@0x%08llx...\n", bucket->num, (long long) bucket->offset);
 	}
 
 	dev_dbg(storage->dev, "Checking redundant buckets finished.\n");
@@ -177,7 +177,7 @@ int state_storage_read(struct state_backend_storage *storage,
 		return -ENOENT;
 	}
 
-	dev_info(storage->dev, "Using bucket %d@0x%08lx\n", bucket_used->num, bucket_used->offset);
+	dev_info(storage->dev, "Using bucket %d@0x%08llx\n", bucket_used->num, (long long) bucket_used->offset);
 
 	/*
 	 * Restore/refresh all buckets except the one we currently use (in case
@@ -252,8 +252,8 @@ static int state_storage_mtd_buckets_init(struct state_backend_storage *storage,
 		end = meminfo->size;
 
 	if (!IS_ALIGNED(storage->offset, meminfo->erasesize)) {
-		dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %u\n",
-			storage->offset, meminfo->erasesize);
+		dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %lld, erasesize %u\n",
+			(long long) storage->offset, meminfo->erasesize);
 		return -EINVAL;
 	}
 
@@ -326,8 +326,8 @@ static int state_storage_file_buckets_init(struct state_backend_storage *storage
 							 &bucket, offset,
 							 stridesize);
 		if (ret) {
-			dev_warn(storage->dev, "Failed to create direct bucket at '%s' offset %ld\n",
-				 storage->path, offset);
+			dev_warn(storage->dev, "Failed to create direct bucket at '%s' offset %lld\n",
+				 storage->path, (long long) offset);
 			continue;
 		}
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/7] common: state: fix formatting of "uint32_t" variables
  2019-02-08  7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 1/7] common: state: fix compiler warnings about wrong type conversion in messages Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 2/7] common: state: fix formatting of "off_t" variables Ulrich Ölmann
@ 2019-02-08  7:15 ` Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 4/7] common: state: harmonize code with dt-utils Ulrich Ölmann
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ulrich Ölmann @ 2019-02-08  7:15 UTC (permalink / raw)
  To: Barebox List

To harmonize the common codebase this ports the following dt-utils commit:

| commit 5588a6c32d54bc4a1ef0b9f72807c46dd00bc20e
| Author: Ulrich Ölmann <u.oelmann@pengutronix.de>
| Date:   Sun Feb 3 22:48:07 2019 +0100
|
|     state: fix formatting of "uint32_t" variables
|
|     The format specifier "%zd" is for "size_t" typed variables and produces a
|     warning with gcc, so use "%u" instead.
|
|     Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
|     Signed-off-by: Roland Hieber <rhi@pengutronix.de>

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 common/state/backend_bucket_circular.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index ae15fa2529c2..059a531aa4b3 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -298,7 +298,7 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck
 	void *write_buf;
 
 	if (written_length > circ->max_size) {
-		dev_err(circ->dev, "Error, state data too big to be written, to write: %d, writesize: %zd, length: %zd, available: %zd\n",
+		dev_err(circ->dev, "Error, state data too big to be written, to write: %u, writesize: %zd, length: %zd, available: %zd\n",
 			written_length, circ->writesize, len, circ->max_size);
 		return -E2BIG;
 	}
@@ -345,12 +345,12 @@ static int state_backend_bucket_circular_write(struct state_backend_storage_buck
 
 	ret = state_mtd_peb_write(circ, write_buf, offset, written_length);
 	if (ret < 0 && ret != -EUCLEAN) {
-		dev_err(circ->dev, "Failed to write circular to %lld length %d, %d\n",
+		dev_err(circ->dev, "Failed to write circular to %lld length %u, %d\n",
 			(long long) offset, written_length, ret);
 		goto out_free;
 	}
 
-	dev_dbg(circ->dev, "Written state to PEB %u offset %lld length %d data length %zd\n",
+	dev_dbg(circ->dev, "Written state to PEB %u offset %lld length %u data length %zd\n",
 		circ->eraseblock, (long long) offset, written_length, len);
 
 out_free:
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/7] common: state: harmonize code with dt-utils
  2019-02-08  7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
                   ` (2 preceding siblings ...)
  2019-02-08  7:15 ` [PATCH 3/7] common: state: fix formatting of "uint32_t" variables Ulrich Ölmann
@ 2019-02-08  7:15 ` Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 5/7] " Ulrich Ölmann
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ulrich Ölmann @ 2019-02-08  7:15 UTC (permalink / raw)
  To: Barebox List

Other than in barebox the offset and size of a state's backend device do not
necessarily equal zero in Linux userspace (EEPROMs & block devices), so barebox'
and dt-utils' state code differ here.

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 common/state/state.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/common/state/state.c b/common/state/state.c
index d3e048b99078..3f5d43ecbf73 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -596,6 +596,8 @@ struct state *state_new_from_node(struct device_node *node, bool readonly)
 	const char *alias;
 	uint32_t stridesize;
 	struct device_node *partition_node;
+	off_t offset = 0;
+	size_t size = 0;
 
 	alias = of_alias_get(node);
 	if (!alias) {
@@ -614,7 +616,11 @@ struct state *state_new_from_node(struct device_node *node, bool readonly)
 		goto out_release_state;
 	}
 
+#ifdef __BAREBOX__
 	ret = of_find_path_by_node(partition_node, &state->backend_path, 0);
+#else
+	ret = of_get_devicepath(partition_node, &state->backend_path, &offset, &size);
+#endif
 	if (ret) {
 		if (ret != -EPROBE_DEFER)
 			dev_err(&state->dev, "state failed to parse path to backend: %s\n",
@@ -645,8 +651,8 @@ struct state *state_new_from_node(struct device_node *node, bool readonly)
 	if (ret)
 		goto out_release_state;
 
-	ret = state_storage_init(state, state->backend_path, 0,
-				 0, stridesize, storage_type);
+	ret = state_storage_init(state, state->backend_path, offset,
+				 size, stridesize, storage_type);
 	if (ret)
 		goto out_release_state;
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/7] common: state: harmonize code with dt-utils
  2019-02-08  7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
                   ` (3 preceding siblings ...)
  2019-02-08  7:15 ` [PATCH 4/7] common: state: harmonize code with dt-utils Ulrich Ölmann
@ 2019-02-08  7:15 ` Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 6/7] " Ulrich Ölmann
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ulrich Ölmann @ 2019-02-08  7:15 UTC (permalink / raw)
  To: Barebox List

Linux userspace needs sys/param.h to have the definition of roundup().

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 common/state/backend_bucket_circular.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 059a531aa4b3..da7c8421ae93 100644
--- a/common/state/backend_bucket_circular.c
+++ b/common/state/backend_bucket_circular.c
@@ -23,6 +23,10 @@
 #include <mtd/mtd-peb.h>
 #include <string.h>
 
+#ifndef __BAREBOX__
+#include <sys/param.h>
+#endif
+
 #include "state.h"
 
 /*
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 6/7] common: state: harmonize code with dt-utils
  2019-02-08  7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
                   ` (4 preceding siblings ...)
  2019-02-08  7:15 ` [PATCH 5/7] " Ulrich Ölmann
@ 2019-02-08  7:15 ` Ulrich Ölmann
  2019-02-08  7:15 ` [PATCH 7/7] " Ulrich Ölmann
  2019-02-11  8:12 ` [PATCH 0/7] Harmonize barebox' and dt-utils' state code Sascha Hauer
  7 siblings, 0 replies; 9+ messages in thread
From: Ulrich Ölmann @ 2019-02-08  7:15 UTC (permalink / raw)
  To: Barebox List

Linux userspace with recent glibc versions lets barebox-state suffer from
linux/stat.h redefining 'struct statx' and because of that switched to the
inclusion of sys/stat.h instead, see dt-utils commit 1c80e31872ae ("src: fix
compilation for glibc version 2.27.9000-36.fc29 and newer").

We can follow this switch in barebox without any problems, too, as in barebox
sys/stat.h includes linux/stat.h (and adds some more definitions on top that
don't hurt us here).

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 common/state/backend_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c
index 8cd822eec486..fca887e93fa3 100644
--- a/common/state/backend_storage.c
+++ b/common/state/backend_storage.c
@@ -19,7 +19,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/mtd/mtd-abi.h>
-#include <linux/stat.h>
+#include <sys/stat.h>
 #include <malloc.h>
 #include <printk.h>
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 7/7] common: state: harmonize code with dt-utils
  2019-02-08  7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
                   ` (5 preceding siblings ...)
  2019-02-08  7:15 ` [PATCH 6/7] " Ulrich Ölmann
@ 2019-02-08  7:15 ` Ulrich Ölmann
  2019-02-11  8:12 ` [PATCH 0/7] Harmonize barebox' and dt-utils' state code Sascha Hauer
  7 siblings, 0 replies; 9+ messages in thread
From: Ulrich Ölmann @ 2019-02-08  7:15 UTC (permalink / raw)
  To: Barebox List

Insert a helpful size check that is an outcome of the following dt-utils
commits:

| commit a6eb5350be0f7a5673162d20f2dd72569d5a4d0c
| Author: Markus Pargmann <mpa@pengutronix.de>
| Date:   Fri May 27 13:53:40 2016 +0200
|
|     barebox-state: Import updated state code
|
|     Signed-off-by: Markus Pargmann <mpa@pengutronix.de>

| commit 583acea6669550ffa7ffb465301ddb3529206afc
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date:   Thu Mar 23 11:29:50 2017 +0100
|
|     state: backend-direct: Fix max_size
|
|     The max_size in the direct backend includes the meta data, so
|     substract its size when determing the max data size we can store.
|
|     Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

| commit dcf781f1b3d15aff5f5ff0b604bff447dee2040c
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date:   Thu Mar 23 12:59:48 2017 +0100
|
|     state: backend_bucket_direct: max_size is always given
|
|     max_size is always != 0, so if(direct->max_size) can be skipped.
|
|     Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 common/state/backend_bucket_direct.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index 9d6a337e6662..1f00b0fb2f64 100644
--- a/common/state/backend_bucket_direct.c
+++ b/common/state/backend_bucket_direct.c
@@ -110,6 +110,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
 	int ret;
 	struct state_backend_storage_bucket_direct_meta meta;
 
+	if (len > direct->max_size - sizeof(meta))
+		return -E2BIG;
+
 	ret = lseek(direct->fd, direct->offset, SEEK_SET);
 	if (ret < 0) {
 		dev_err(direct->dev, "Failed to seek file, %d\n", ret);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/7] Harmonize barebox' and dt-utils' state code
  2019-02-08  7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
                   ` (6 preceding siblings ...)
  2019-02-08  7:15 ` [PATCH 7/7] " Ulrich Ölmann
@ 2019-02-11  8:12 ` Sascha Hauer
  7 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2019-02-11  8:12 UTC (permalink / raw)
  To: Ulrich Ölmann; +Cc: Barebox List

On Fri, Feb 08, 2019 at 08:15:19AM +0100, Ulrich Ölmann wrote:
> These patches remove further differences between the common codebase of barebox'
> and dt-utils' state implementation.
> 
> Ulrich Ölmann (7):
>   common: state: fix compiler warnings about wrong type conversion in
>     messages
>   common: state: fix formatting of "off_t" variables
>   common: state: fix formatting of "uint32_t" variables
>   common: state: harmonize code with dt-utils
>   common: state: harmonize code with dt-utils
>   common: state: harmonize code with dt-utils
>   common: state: harmonize code with dt-utils
> 

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-02-11  8:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08  7:15 [PATCH 0/7] Harmonize barebox' and dt-utils' state code Ulrich Ölmann
2019-02-08  7:15 ` [PATCH 1/7] common: state: fix compiler warnings about wrong type conversion in messages Ulrich Ölmann
2019-02-08  7:15 ` [PATCH 2/7] common: state: fix formatting of "off_t" variables Ulrich Ölmann
2019-02-08  7:15 ` [PATCH 3/7] common: state: fix formatting of "uint32_t" variables Ulrich Ölmann
2019-02-08  7:15 ` [PATCH 4/7] common: state: harmonize code with dt-utils Ulrich Ölmann
2019-02-08  7:15 ` [PATCH 5/7] " Ulrich Ölmann
2019-02-08  7:15 ` [PATCH 6/7] " Ulrich Ölmann
2019-02-08  7:15 ` [PATCH 7/7] " Ulrich Ölmann
2019-02-11  8:12 ` [PATCH 0/7] Harmonize barebox' and dt-utils' state code Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox