* [PATCH v2 1/6] lib: simplify fdt_parse_plmt_node()
2022-11-28 9:14 [PATCH v2 0/6] lib: fixes for fdt functions Heinrich Schuchardt
@ 2022-11-28 9:14 ` Heinrich Schuchardt
2022-12-02 15:55 ` Bin Meng
2022-11-28 9:14 ` [PATCH v2 2/6] lib: simplify fdt_parse_plicsw_node() Heinrich Schuchardt
` (5 subsequent siblings)
6 siblings, 1 reply; 22+ messages in thread
From: Heinrich Schuchardt @ 2022-11-28 9:14 UTC (permalink / raw)
To: opensbi
We should not check !plmt_base || !plmt_size twice.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
---
v2:
Reviewed-by added
---
lib/utils/fdt/fdt_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index 89b8bba..dbd7484 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -814,7 +814,7 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
rc = fdt_get_node_addr_size(fdt, nodeoffset, 0,
®_addr, ®_size);
- if (rc < 0 || !plmt_base || !plmt_size)
+ if (rc < 0)
return SBI_ENODEV;
*plmt_base = reg_addr;
*plmt_size = reg_size;
--
2.37.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v2 1/6] lib: simplify fdt_parse_plmt_node()
2022-11-28 9:14 ` [PATCH v2 1/6] lib: simplify fdt_parse_plmt_node() Heinrich Schuchardt
@ 2022-12-02 15:55 ` Bin Meng
0 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2022-12-02 15:55 UTC (permalink / raw)
To: opensbi
On Mon, Nov 28, 2022 at 5:16 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> We should not check !plmt_base || !plmt_size twice.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Reviewed-by: Xiang W <wxjstz@126.com>
> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
> ---
> v2:
> Reviewed-by added
> ---
> lib/utils/fdt/fdt_helper.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: Bin Meng <bmeng@tinylab.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 2/6] lib: simplify fdt_parse_plicsw_node()
2022-11-28 9:14 [PATCH v2 0/6] lib: fixes for fdt functions Heinrich Schuchardt
2022-11-28 9:14 ` [PATCH v2 1/6] lib: simplify fdt_parse_plmt_node() Heinrich Schuchardt
@ 2022-11-28 9:14 ` Heinrich Schuchardt
2022-12-02 15:55 ` Bin Meng
2022-11-28 9:14 ` [PATCH v2 3/6] lib: fix fdt_parse_plmt_node() Heinrich Schuchardt
` (4 subsequent siblings)
6 siblings, 1 reply; 22+ messages in thread
From: Heinrich Schuchardt @ 2022-11-28 9:14 UTC (permalink / raw)
To: opensbi
We should not check !plicsw_base || !size twice.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
---
v2:
Reviewed-by added
---
lib/utils/fdt/fdt_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index dbd7484..87b9fb2 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -868,7 +868,7 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
rc = fdt_get_node_addr_size(fdt, nodeoffset, 0,
®_addr, ®_size);
- if (rc < 0 || !plicsw_base || !size)
+ if (rc < 0)
return SBI_ENODEV;
*plicsw_base = reg_addr;
*size = reg_size;
--
2.37.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v2 2/6] lib: simplify fdt_parse_plicsw_node()
2022-11-28 9:14 ` [PATCH v2 2/6] lib: simplify fdt_parse_plicsw_node() Heinrich Schuchardt
@ 2022-12-02 15:55 ` Bin Meng
0 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2022-12-02 15:55 UTC (permalink / raw)
To: opensbi
On Mon, Nov 28, 2022 at 5:15 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> We should not check !plicsw_base || !size twice.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Reviewed-by: Xiang W <wxjstz@126.com>
> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
> ---
> v2:
> Reviewed-by added
> ---
> lib/utils/fdt/fdt_helper.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: Bin Meng <bmeng@tinylab.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 3/6] lib: fix fdt_parse_plmt_node()
2022-11-28 9:14 [PATCH v2 0/6] lib: fixes for fdt functions Heinrich Schuchardt
2022-11-28 9:14 ` [PATCH v2 1/6] lib: simplify fdt_parse_plmt_node() Heinrich Schuchardt
2022-11-28 9:14 ` [PATCH v2 2/6] lib: simplify fdt_parse_plicsw_node() Heinrich Schuchardt
@ 2022-11-28 9:14 ` Heinrich Schuchardt
2022-11-28 12:52 ` Xiang W
` (3 more replies)
2022-11-28 9:14 ` [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node() Heinrich Schuchardt
` (3 subsequent siblings)
6 siblings, 4 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2022-11-28 9:14 UTC (permalink / raw)
To: opensbi
cpu_offset, cpu_intc_offset must be int to discover failed invocations of
fdt_node_offset_by_phandle() or fdt_parent_offset().
After determining cpu_offset we have to check this value and not
cpu_intc_offset.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
check correct variable
---
lib/utils/fdt/fdt_helper.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index 87b9fb2..976c96e 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -805,7 +805,7 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
{
const fdt32_t *val;
int rc, i, count;
- uint64_t reg_addr, reg_size, cpu_offset, cpu_intc_offset;
+ uint64_t reg_addr, reg_size;
u32 phandle, hwirq, hartid, hcount;
if (nodeoffset < 0 || !fdt || !plmt_base ||
@@ -826,6 +826,8 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
hcount = 0;
for (i = 0; i < (count / 2); i++) {
+ int cpu_offset, cpu_intc_offset;
+
phandle = fdt32_to_cpu(val[2 * i]);
hwirq = fdt32_to_cpu(val[2 * i + 1]);
@@ -834,7 +836,7 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
continue;
cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
- if (cpu_intc_offset < 0)
+ if (cpu_offset < 0)
continue;
rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
--
2.37.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v2 3/6] lib: fix fdt_parse_plmt_node()
2022-11-28 9:14 ` [PATCH v2 3/6] lib: fix fdt_parse_plmt_node() Heinrich Schuchardt
@ 2022-11-28 12:52 ` Xiang W
2022-11-28 12:52 ` Xiang W
` (2 subsequent siblings)
3 siblings, 0 replies; 22+ messages in thread
From: Xiang W @ 2022-11-28 12:52 UTC (permalink / raw)
To: opensbi
? 2022-11-28???? 10:14 +0100?Heinrich Schuchardt???
> cpu_offset, cpu_intc_offset must be int to discover failed invocations of
> fdt_node_offset_by_phandle() or fdt_parent_offset().
>
> After determining cpu_offset we have to check this value and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Look good to me
Reviewed-by: Xiang W <wxjstz@126.com>
> ---
> v2:
> ????????check correct variable
> ---
> ?lib/utils/fdt/fdt_helper.c | 6 ++++--
> ?1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
> index 87b9fb2..976c96e 100644
> --- a/lib/utils/fdt/fdt_helper.c
> +++ b/lib/utils/fdt/fdt_helper.c
> @@ -805,7 +805,7 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
> ?{
> ????????const fdt32_t *val;
> ????????int rc, i, count;
> -???????uint64_t reg_addr, reg_size, cpu_offset, cpu_intc_offset;
> +???????uint64_t reg_addr, reg_size;
> ????????u32 phandle, hwirq, hartid, hcount;
> ?
> ????????if (nodeoffset < 0 || !fdt || !plmt_base ||
> @@ -826,6 +826,8 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
> ?
> ????????hcount = 0;
> ????????for (i = 0; i < (count / 2); i++) {
> +???????????????int cpu_offset, cpu_intc_offset;
> +
> ????????????????phandle = fdt32_to_cpu(val[2 * i]);
> ????????????????hwirq = fdt32_to_cpu(val[2 * i + 1]);
> ?
> @@ -834,7 +836,7 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
> ????????????????????????continue;
> ?
> ????????????????cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
> -???????????????if (cpu_intc_offset < 0)
> +???????????????if (cpu_offset < 0)
> ????????????????????????continue;
> ?
> ????????????????rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 3/6] lib: fix fdt_parse_plmt_node()
2022-11-28 9:14 ` [PATCH v2 3/6] lib: fix fdt_parse_plmt_node() Heinrich Schuchardt
2022-11-28 12:52 ` Xiang W
@ 2022-11-28 12:52 ` Xiang W
2022-11-29 10:42 ` Yu-Chien Peter Lin
2022-12-02 15:55 ` Bin Meng
3 siblings, 0 replies; 22+ messages in thread
From: Xiang W @ 2022-11-28 12:52 UTC (permalink / raw)
To: opensbi
? 2022-11-28???? 10:14 +0100?Heinrich Schuchardt???
> cpu_offset, cpu_intc_offset must be int to discover failed invocations of
> fdt_node_offset_by_phandle() or fdt_parent_offset().
>
> After determining cpu_offset we have to check this value and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Look good to me
Reviewed-by: Xiang W <wxjstz@126.com>
> ---
> v2:
> ????????check correct variable
> ---
> ?lib/utils/fdt/fdt_helper.c | 6 ++++--
> ?1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
> index 87b9fb2..976c96e 100644
> --- a/lib/utils/fdt/fdt_helper.c
> +++ b/lib/utils/fdt/fdt_helper.c
> @@ -805,7 +805,7 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
> ?{
> ????????const fdt32_t *val;
> ????????int rc, i, count;
> -???????uint64_t reg_addr, reg_size, cpu_offset, cpu_intc_offset;
> +???????uint64_t reg_addr, reg_size;
> ????????u32 phandle, hwirq, hartid, hcount;
> ?
> ????????if (nodeoffset < 0 || !fdt || !plmt_base ||
> @@ -826,6 +826,8 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
> ?
> ????????hcount = 0;
> ????????for (i = 0; i < (count / 2); i++) {
> +???????????????int cpu_offset, cpu_intc_offset;
> +
> ????????????????phandle = fdt32_to_cpu(val[2 * i]);
> ????????????????hwirq = fdt32_to_cpu(val[2 * i + 1]);
> ?
> @@ -834,7 +836,7 @@ int fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,
> ????????????????????????continue;
> ?
> ????????????????cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
> -???????????????if (cpu_intc_offset < 0)
> +???????????????if (cpu_offset < 0)
> ????????????????????????continue;
> ?
> ????????????????rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
> --
> 2.37.2
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 3/6] lib: fix fdt_parse_plmt_node()
2022-11-28 9:14 ` [PATCH v2 3/6] lib: fix fdt_parse_plmt_node() Heinrich Schuchardt
2022-11-28 12:52 ` Xiang W
2022-11-28 12:52 ` Xiang W
@ 2022-11-29 10:42 ` Yu-Chien Peter Lin
2022-12-02 15:55 ` Bin Meng
3 siblings, 0 replies; 22+ messages in thread
From: Yu-Chien Peter Lin @ 2022-11-29 10:42 UTC (permalink / raw)
To: opensbi
On Mon, Nov 28, 2022 at 10:14:17AM +0100, Heinrich Schuchardt wrote:
> cpu_offset, cpu_intc_offset must be int to discover failed invocations of
> fdt_node_offset_by_phandle() or fdt_parent_offset().
>
> After determining cpu_offset we have to check this value and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Looks good to me.
Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 3/6] lib: fix fdt_parse_plmt_node()
2022-11-28 9:14 ` [PATCH v2 3/6] lib: fix fdt_parse_plmt_node() Heinrich Schuchardt
` (2 preceding siblings ...)
2022-11-29 10:42 ` Yu-Chien Peter Lin
@ 2022-12-02 15:55 ` Bin Meng
3 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2022-12-02 15:55 UTC (permalink / raw)
To: opensbi
On Mon, Nov 28, 2022 at 5:16 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> cpu_offset, cpu_intc_offset must be int to discover failed invocations of
> fdt_node_offset_by_phandle() or fdt_parent_offset().
>
> After determining cpu_offset we have to check this value and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> check correct variable
> ---
> lib/utils/fdt/fdt_helper.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
Reviewed-by: Bin Meng <bmeng@tinylab.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node()
2022-11-28 9:14 [PATCH v2 0/6] lib: fixes for fdt functions Heinrich Schuchardt
` (2 preceding siblings ...)
2022-11-28 9:14 ` [PATCH v2 3/6] lib: fix fdt_parse_plmt_node() Heinrich Schuchardt
@ 2022-11-28 9:14 ` Heinrich Schuchardt
2022-11-28 12:53 ` Xiang W
` (3 more replies)
2022-11-28 9:14 ` [PATCH v2 5/6] lib: simplify fdt_translate_address() Heinrich Schuchardt
` (2 subsequent siblings)
6 siblings, 4 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2022-11-28 9:14 UTC (permalink / raw)
To: opensbi
cpu_offset and cpu_intc_offset must be int to detect failed invocations of
fdt_node_offset_by_phandle() or fdt_parent_offset().
After determining cpu_offset we have to check this value and not
cpu_intc_offset.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
check correct variable
---
lib/utils/fdt/fdt_helper.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index 976c96e..674f17b 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -861,7 +861,7 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
{
const fdt32_t *val;
int rc, i, count;
- uint64_t reg_addr, reg_size, cpu_offset, cpu_intc_offset;
+ uint64_t reg_addr, reg_size;
u32 phandle, hwirq, hartid, hcount;
if (nodeoffset < 0 || !fdt || !plicsw_base ||
@@ -882,6 +882,8 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
hcount = 0;
for (i = 0; i < (count / 2); i++) {
+ int cpu_offset, cpu_intc_offset;
+
phandle = fdt32_to_cpu(val[2 * i]);
hwirq = fdt32_to_cpu(val[2 * i + 1]);
@@ -890,7 +892,7 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
continue;
cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
- if (cpu_intc_offset < 0)
+ if (cpu_offset < 0)
continue;
rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
--
2.37.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node()
2022-11-28 9:14 ` [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node() Heinrich Schuchardt
@ 2022-11-28 12:53 ` Xiang W
2022-11-28 12:53 ` Xiang W
` (2 subsequent siblings)
3 siblings, 0 replies; 22+ messages in thread
From: Xiang W @ 2022-11-28 12:53 UTC (permalink / raw)
To: opensbi
? 2022-11-28???? 10:14 +0100?Heinrich Schuchardt???
> cpu_offset and cpu_intc_offset must be int to detect failed invocations of
> fdt_node_offset_by_phandle() or fdt_parent_offset().
>
> After determining cpu_offset we have to check this value and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Look good to me
Reviewed-by: Xiang W <wxjstz@126.com>
> ---
> v2:
> ????????check correct variable
> ---
> ?lib/utils/fdt/fdt_helper.c | 6 ++++--
> ?1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
> index 976c96e..674f17b 100644
> --- a/lib/utils/fdt/fdt_helper.c
> +++ b/lib/utils/fdt/fdt_helper.c
> @@ -861,7 +861,7 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
> ?{
> ????????const fdt32_t *val;
> ????????int rc, i, count;
> -???????uint64_t reg_addr, reg_size, cpu_offset, cpu_intc_offset;
> +???????uint64_t reg_addr, reg_size;
> ????????u32 phandle, hwirq, hartid, hcount;
> ?
> ????????if (nodeoffset < 0 || !fdt || !plicsw_base ||
> @@ -882,6 +882,8 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
> ?
> ????????hcount = 0;
> ????????for (i = 0; i < (count / 2); i++) {
> +???????????????int cpu_offset, cpu_intc_offset;
> +
> ????????????????phandle = fdt32_to_cpu(val[2 * i]);
> ????????????????hwirq = fdt32_to_cpu(val[2 * i + 1]);
> ?
> @@ -890,7 +892,7 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
> ????????????????????????continue;
> ?
> ????????????????cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
> -???????????????if (cpu_intc_offset < 0)
> +???????????????if (cpu_offset < 0)
> ????????????????????????continue;
> ?
> ????????????????rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node()
2022-11-28 9:14 ` [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node() Heinrich Schuchardt
2022-11-28 12:53 ` Xiang W
@ 2022-11-28 12:53 ` Xiang W
2022-11-29 10:44 ` Yu-Chien Peter Lin
2022-12-02 15:55 ` Bin Meng
3 siblings, 0 replies; 22+ messages in thread
From: Xiang W @ 2022-11-28 12:53 UTC (permalink / raw)
To: opensbi
? 2022-11-28???? 10:14 +0100?Heinrich Schuchardt???
> cpu_offset and cpu_intc_offset must be int to detect failed invocations of
> fdt_node_offset_by_phandle() or fdt_parent_offset().
>
> After determining cpu_offset we have to check this value and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Look good to me
Reviewed-by: Xiang W <wxjstz@126.com>
> ---
> v2:
> ????????check correct variable
> ---
> ?lib/utils/fdt/fdt_helper.c | 6 ++++--
> ?1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
> index 976c96e..674f17b 100644
> --- a/lib/utils/fdt/fdt_helper.c
> +++ b/lib/utils/fdt/fdt_helper.c
> @@ -861,7 +861,7 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
> ?{
> ????????const fdt32_t *val;
> ????????int rc, i, count;
> -???????uint64_t reg_addr, reg_size, cpu_offset, cpu_intc_offset;
> +???????uint64_t reg_addr, reg_size;
> ????????u32 phandle, hwirq, hartid, hcount;
> ?
> ????????if (nodeoffset < 0 || !fdt || !plicsw_base ||
> @@ -882,6 +882,8 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
> ?
> ????????hcount = 0;
> ????????for (i = 0; i < (count / 2); i++) {
> +???????????????int cpu_offset, cpu_intc_offset;
> +
> ????????????????phandle = fdt32_to_cpu(val[2 * i]);
> ????????????????hwirq = fdt32_to_cpu(val[2 * i + 1]);
> ?
> @@ -890,7 +892,7 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
> ????????????????????????continue;
> ?
> ????????????????cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
> -???????????????if (cpu_intc_offset < 0)
> +???????????????if (cpu_offset < 0)
> ????????????????????????continue;
> ?
> ????????????????rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
> --
> 2.37.2
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread* [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node()
2022-11-28 9:14 ` [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node() Heinrich Schuchardt
2022-11-28 12:53 ` Xiang W
2022-11-28 12:53 ` Xiang W
@ 2022-11-29 10:44 ` Yu-Chien Peter Lin
2022-12-02 15:55 ` Bin Meng
3 siblings, 0 replies; 22+ messages in thread
From: Yu-Chien Peter Lin @ 2022-11-29 10:44 UTC (permalink / raw)
To: opensbi
On Mon, Nov 28, 2022 at 10:14:18AM +0100, Heinrich Schuchardt wrote:
> cpu_offset and cpu_intc_offset must be int to detect failed invocations of
> fdt_node_offset_by_phandle() or fdt_parent_offset().
>
> After determining cpu_offset we have to check this value and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Looks good to me
Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node()
2022-11-28 9:14 ` [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node() Heinrich Schuchardt
` (2 preceding siblings ...)
2022-11-29 10:44 ` Yu-Chien Peter Lin
@ 2022-12-02 15:55 ` Bin Meng
3 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2022-12-02 15:55 UTC (permalink / raw)
To: opensbi
On Mon, Nov 28, 2022 at 5:16 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> cpu_offset and cpu_intc_offset must be int to detect failed invocations of
> fdt_node_offset_by_phandle() or fdt_parent_offset().
>
> After determining cpu_offset we have to check this value and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> check correct variable
> ---
> lib/utils/fdt/fdt_helper.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
Reviewed-by: Bin Meng <bmeng@tinylab.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 5/6] lib: simplify fdt_translate_address()
2022-11-28 9:14 [PATCH v2 0/6] lib: fixes for fdt functions Heinrich Schuchardt
` (3 preceding siblings ...)
2022-11-28 9:14 ` [PATCH v2 4/6] lib: fix fdt_parse_plicsw_node() Heinrich Schuchardt
@ 2022-11-28 9:14 ` Heinrich Schuchardt
2022-12-02 15:55 ` Bin Meng
2022-11-28 9:14 ` [PATCH v2 6/6] lib: fix fdt_parse_aclint_node() Heinrich Schuchardt
2022-12-05 5:15 ` [PATCH v2 0/6] lib: fixes for fdt functions Anup Patel
6 siblings, 1 reply; 22+ messages in thread
From: Heinrich Schuchardt @ 2022-11-28 9:14 UTC (permalink / raw)
To: opensbi
Don't assign a value to offset which is never used.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Xiang W <wxjstz@126.com>
---
v2:
Reviewed-by added
---
lib/utils/fdt/fdt_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index 674f17b..43d7857 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -124,7 +124,7 @@ static int fdt_translate_address(void *fdt, uint64_t reg, int parent,
int i, rlen;
int cell_addr, cell_size;
const fdt32_t *ranges;
- uint64_t offset = 0, caddr = 0, paddr = 0, rsize = 0;
+ uint64_t offset, caddr = 0, paddr = 0, rsize = 0;
cell_addr = fdt_address_cells(fdt, parent);
if (cell_addr < 1)
--
2.37.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v2 6/6] lib: fix fdt_parse_aclint_node()
2022-11-28 9:14 [PATCH v2 0/6] lib: fixes for fdt functions Heinrich Schuchardt
` (4 preceding siblings ...)
2022-11-28 9:14 ` [PATCH v2 5/6] lib: simplify fdt_translate_address() Heinrich Schuchardt
@ 2022-11-28 9:14 ` Heinrich Schuchardt
2022-11-28 12:54 ` Xiang W
` (2 more replies)
2022-12-05 5:15 ` [PATCH v2 0/6] lib: fixes for fdt functions Anup Patel
6 siblings, 3 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2022-11-28 9:14 UTC (permalink / raw)
To: opensbi
After determining cpu_offset we have to check this variable and not
cpu_intc_offset.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
new patch
---
lib/utils/fdt/fdt_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index 43d7857..d4b38dc 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -772,7 +772,7 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,
continue;
cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
- if (cpu_intc_offset < 0)
+ if (cpu_offset < 0)
continue;
rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
--
2.37.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH v2 6/6] lib: fix fdt_parse_aclint_node()
2022-11-28 9:14 ` [PATCH v2 6/6] lib: fix fdt_parse_aclint_node() Heinrich Schuchardt
@ 2022-11-28 12:54 ` Xiang W
2022-11-28 12:54 ` Xiang W
2022-12-02 15:55 ` Bin Meng
2 siblings, 0 replies; 22+ messages in thread
From: Xiang W @ 2022-11-28 12:54 UTC (permalink / raw)
To: opensbi
? 2022-11-28???? 10:14 +0100?Heinrich Schuchardt???
> After determining cpu_offset we have to check this variable and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Look good to me
Reviewed-by: Xiang W <wxjstz@126.com>
> ---
> v2:
> ????????new patch
> ---
> ?lib/utils/fdt/fdt_helper.c | 2 +-
> ?1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
> index 43d7857..d4b38dc 100644
> --- a/lib/utils/fdt/fdt_helper.c
> +++ b/lib/utils/fdt/fdt_helper.c
> @@ -772,7 +772,7 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,
> ????????????????????????continue;
> ?
> ????????????????cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
> -???????????????if (cpu_intc_offset < 0)
> +???????????????if (cpu_offset < 0)
> ????????????????????????continue;
> ?
> ????????????????rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 6/6] lib: fix fdt_parse_aclint_node()
2022-11-28 9:14 ` [PATCH v2 6/6] lib: fix fdt_parse_aclint_node() Heinrich Schuchardt
2022-11-28 12:54 ` Xiang W
@ 2022-11-28 12:54 ` Xiang W
2022-12-02 15:55 ` Bin Meng
2 siblings, 0 replies; 22+ messages in thread
From: Xiang W @ 2022-11-28 12:54 UTC (permalink / raw)
To: opensbi
? 2022-11-28???? 10:14 +0100?Heinrich Schuchardt???
> After determining cpu_offset we have to check this variable and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Look good to me
Reviewed-by: Xiang W <wxjstz@126.com>
> ---
> v2:
> ????????new patch
> ---
> ?lib/utils/fdt/fdt_helper.c | 2 +-
> ?1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
> index 43d7857..d4b38dc 100644
> --- a/lib/utils/fdt/fdt_helper.c
> +++ b/lib/utils/fdt/fdt_helper.c
> @@ -772,7 +772,7 @@ int fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,
> ????????????????????????continue;
> ?
> ????????????????cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
> -???????????????if (cpu_intc_offset < 0)
> +???????????????if (cpu_offset < 0)
> ????????????????????????continue;
> ?
> ????????????????rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
> --
> 2.37.2
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 6/6] lib: fix fdt_parse_aclint_node()
2022-11-28 9:14 ` [PATCH v2 6/6] lib: fix fdt_parse_aclint_node() Heinrich Schuchardt
2022-11-28 12:54 ` Xiang W
2022-11-28 12:54 ` Xiang W
@ 2022-12-02 15:55 ` Bin Meng
2 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2022-12-02 15:55 UTC (permalink / raw)
To: opensbi
On Mon, Nov 28, 2022 at 5:15 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> After determining cpu_offset we have to check this variable and not
> cpu_intc_offset.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> new patch
> ---
> lib/utils/fdt/fdt_helper.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: Bin Meng <bmeng@tinylab.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 0/6] lib: fixes for fdt functions
2022-11-28 9:14 [PATCH v2 0/6] lib: fixes for fdt functions Heinrich Schuchardt
` (5 preceding siblings ...)
2022-11-28 9:14 ` [PATCH v2 6/6] lib: fix fdt_parse_aclint_node() Heinrich Schuchardt
@ 2022-12-05 5:15 ` Anup Patel
6 siblings, 0 replies; 22+ messages in thread
From: Anup Patel @ 2022-12-05 5:15 UTC (permalink / raw)
To: opensbi
Hi Heinrich,
On Mon, Nov 28, 2022 at 2:44 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> * Use correct type for variables used in error checks
> * Check correct variables
> * Avoid duplicates checks
> * Don't assign values that are never used.
>
> v2:
> check correct variables
> fix fdt_parse_aclint_node() too
>
> Heinrich Schuchardt (6):
> lib: simplify fdt_parse_plmt_node()
> lib: simplify fdt_parse_plicsw_node()
> lib: fix fdt_parse_plmt_node()
> lib: fix fdt_parse_plicsw_node()
> lib: simplify fdt_translate_address()
> lib: fix fdt_parse_aclint_node()
Thanks for catching and fixing all these issues.
Applied this series to the riscv/opensbi repo.
Regards,
Anup
>
> lib/utils/fdt/fdt_helper.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> --
> 2.37.2
>
^ permalink raw reply [flat|nested] 22+ messages in thread