mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] dtc: Apply upstream patch for build errors.
@ 2026-02-01 12:27 Christian Melki
  2026-02-06  8:56 ` [ptxdist] [APPLIED] " Michael Olbrich
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Melki @ 2026-02-01 12:27 UTC (permalink / raw)
  To: ptxdist

On some setups, these cause build errors.
Fixed upstream. Apply now, probably remove in next stable release.

Signed-off-by: Christian Melki <christian.melki@t2data.com>
---
 .../0001-Fix-discarded-const-qualifiers.patch | 80 +++++++++++++++++++
 patches/dtc-1.7.2/series                      |  4 +
 2 files changed, 84 insertions(+)
 create mode 100644 patches/dtc-1.7.2/0001-Fix-discarded-const-qualifiers.patch
 create mode 100644 patches/dtc-1.7.2/series

diff --git a/patches/dtc-1.7.2/0001-Fix-discarded-const-qualifiers.patch b/patches/dtc-1.7.2/0001-Fix-discarded-const-qualifiers.patch
new file mode 100644
index 000000000..766dbccc2
--- /dev/null
+++ b/patches/dtc-1.7.2/0001-Fix-discarded-const-qualifiers.patch
@@ -0,0 +1,80 @@
+From: Stephen Gallagher <sgallagh@redhat.com>
+Date: Tue, 6 Jan 2026 14:19:30 -0500
+Subject: [PATCH] Fix discarded const qualifiers
+
+It's unsafe to implicitly discard the const qualifier on a pointer. In
+overlay_fixup_phandle(), this was probably just an oversight, and making
+the "sep" variable a const char * is sufficient to fix it.
+
+In create_node(), however, the "p" variable is directly modifying the
+buffer pointed to by "const char* node_name". To fix this, we need to
+actually make a duplicate of the buffer and operate on that instead.
+
+This introduces a malloc()/free()  and an unbounded strdup() into the
+operation, but fdtput isn't a long-running service and the node_name
+argument comes directly from argv, so this shouldn't introduce a
+significant performance impact.
+
+Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
+Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
+---
+ fdtput.c             | 8 +++++---
+ libfdt/fdt_overlay.c | 3 ++-
+ meson.build          | 1 +
+ 3 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/fdtput.c b/fdtput.c
+index c2fecf45a977..8deec7eebcf5 100644
+--- a/fdtput.c
++++ b/fdtput.c
+@@ -230,19 +230,21 @@ static int create_paths(char **blob, const char *in_path)
+ static int create_node(char **blob, const char *node_name)
+ {
+ 	int node = 0;
+-	char *p;
++	const char *p;
++	char *path = NULL;
+ 
+ 	p = strrchr(node_name, '/');
+ 	if (!p) {
+ 		report_error(node_name, -1, -FDT_ERR_BADPATH);
+ 		return -1;
+ 	}
+-	*p = '\0';
+ 
+ 	*blob = realloc_node(*blob, p + 1);
+ 
+ 	if (p > node_name) {
+-		node = fdt_path_offset(*blob, node_name);
++		path = xstrndup(node_name, (size_t)(p - node_name));
++		node = fdt_path_offset(*blob, path);
++		free(path);
+ 		if (node < 0) {
+ 			report_error(node_name, -1, node);
+ 			return -1;
+diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
+index 28b667ffc490..5f8aa62b2686 100644
+--- a/libfdt/fdt_overlay.c
++++ b/libfdt/fdt_overlay.c
+@@ -409,7 +409,8 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
+ 		const char *fixup_str = value;
+ 		uint32_t path_len, name_len;
+ 		uint32_t fixup_len;
+-		char *sep, *endptr;
++		const char *sep;
++		char *endptr;
+ 		int poffset, ret;
+ 
+ 		fixup_end = memchr(value, '\0', len);
+diff --git a/meson.build b/meson.build
+index 310699f0c874..2966b0614a69 100644
+--- a/meson.build
++++ b/meson.build
+@@ -18,6 +18,7 @@ add_project_arguments(
+     '-Wshadow',
+     '-Wsuggest-attribute=format',
+     '-Wwrite-strings',
++    '-Wdiscarded-qualifiers',
+   ]),
+   language: 'c'
+ )
diff --git a/patches/dtc-1.7.2/series b/patches/dtc-1.7.2/series
new file mode 100644
index 000000000..d6c2782c4
--- /dev/null
+++ b/patches/dtc-1.7.2/series
@@ -0,0 +1,4 @@
+# generated by git-ptx-patches
+#tag:base --start-number 1
+0001-Fix-discarded-const-qualifiers.patch
+# 3a8b95763e3400e890427bab311c296a  - git-ptx-patches magic
-- 
2.43.0




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

* Re: [ptxdist] [APPLIED] dtc: Apply upstream patch for build errors.
  2026-02-01 12:27 [ptxdist] [PATCH] dtc: Apply upstream patch for build errors Christian Melki
@ 2026-02-06  8:56 ` Michael Olbrich
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Olbrich @ 2026-02-06  8:56 UTC (permalink / raw)
  To: ptxdist; +Cc: Christian Melki

Thanks, applied as cd95ea4ea169b2e888287332f8756cd5dbb281fe.

Michael

[sent from post-receive hook]

On Fri, 06 Feb 2026 09:56:16 +0100, Christian Melki <christian.melki@t2data.com> wrote:
> On some setups, these cause build errors.
> Fixed upstream. Apply now, probably remove in next stable release.
> 
> Signed-off-by: Christian Melki <christian.melki@t2data.com>
> Message-Id: <20260201122711.2350573-1-christian.melki@t2data.com>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> 
> diff --git a/patches/dtc-1.7.2/0001-Fix-discarded-const-qualifiers.patch b/patches/dtc-1.7.2/0001-Fix-discarded-const-qualifiers.patch
> new file mode 100644
> index 000000000000..766dbccc2427
> --- /dev/null
> +++ b/patches/dtc-1.7.2/0001-Fix-discarded-const-qualifiers.patch
> @@ -0,0 +1,80 @@
> +From: Stephen Gallagher <sgallagh@redhat.com>
> +Date: Tue, 6 Jan 2026 14:19:30 -0500
> +Subject: [PATCH] Fix discarded const qualifiers
> +
> +It's unsafe to implicitly discard the const qualifier on a pointer. In
> +overlay_fixup_phandle(), this was probably just an oversight, and making
> +the "sep" variable a const char * is sufficient to fix it.
> +
> +In create_node(), however, the "p" variable is directly modifying the
> +buffer pointed to by "const char* node_name". To fix this, we need to
> +actually make a duplicate of the buffer and operate on that instead.
> +
> +This introduces a malloc()/free()  and an unbounded strdup() into the
> +operation, but fdtput isn't a long-running service and the node_name
> +argument comes directly from argv, so this shouldn't introduce a
> +significant performance impact.
> +
> +Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
> +Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> +---
> + fdtput.c             | 8 +++++---
> + libfdt/fdt_overlay.c | 3 ++-
> + meson.build          | 1 +
> + 3 files changed, 8 insertions(+), 4 deletions(-)
> +
> +diff --git a/fdtput.c b/fdtput.c
> +index c2fecf45a977..8deec7eebcf5 100644
> +--- a/fdtput.c
> ++++ b/fdtput.c
> +@@ -230,19 +230,21 @@ static int create_paths(char **blob, const char *in_path)
> + static int create_node(char **blob, const char *node_name)
> + {
> + 	int node = 0;
> +-	char *p;
> ++	const char *p;
> ++	char *path = NULL;
> + 
> + 	p = strrchr(node_name, '/');
> + 	if (!p) {
> + 		report_error(node_name, -1, -FDT_ERR_BADPATH);
> + 		return -1;
> + 	}
> +-	*p = '\0';
> + 
> + 	*blob = realloc_node(*blob, p + 1);
> + 
> + 	if (p > node_name) {
> +-		node = fdt_path_offset(*blob, node_name);
> ++		path = xstrndup(node_name, (size_t)(p - node_name));
> ++		node = fdt_path_offset(*blob, path);
> ++		free(path);
> + 		if (node < 0) {
> + 			report_error(node_name, -1, node);
> + 			return -1;
> +diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
> +index 28b667ffc490..5f8aa62b2686 100644
> +--- a/libfdt/fdt_overlay.c
> ++++ b/libfdt/fdt_overlay.c
> +@@ -409,7 +409,8 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
> + 		const char *fixup_str = value;
> + 		uint32_t path_len, name_len;
> + 		uint32_t fixup_len;
> +-		char *sep, *endptr;
> ++		const char *sep;
> ++		char *endptr;
> + 		int poffset, ret;
> + 
> + 		fixup_end = memchr(value, '\0', len);
> +diff --git a/meson.build b/meson.build
> +index 310699f0c874..2966b0614a69 100644
> +--- a/meson.build
> ++++ b/meson.build
> +@@ -18,6 +18,7 @@ add_project_arguments(
> +     '-Wshadow',
> +     '-Wsuggest-attribute=format',
> +     '-Wwrite-strings',
> ++    '-Wdiscarded-qualifiers',
> +   ]),
> +   language: 'c'
> + )
> diff --git a/patches/dtc-1.7.2/series b/patches/dtc-1.7.2/series
> new file mode 100644
> index 000000000000..d6c2782c41ab
> --- /dev/null
> +++ b/patches/dtc-1.7.2/series
> @@ -0,0 +1,4 @@
> +# generated by git-ptx-patches
> +#tag:base --start-number 1
> +0001-Fix-discarded-const-qualifiers.patch
> +# 3a8b95763e3400e890427bab311c296a  - git-ptx-patches magic



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

end of thread, other threads:[~2026-02-06  8:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-01 12:27 [ptxdist] [PATCH] dtc: Apply upstream patch for build errors Christian Melki
2026-02-06  8:56 ` [ptxdist] [APPLIED] " Michael Olbrich

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