Skip to contentSkip to conversation

Unchecked return value error in fdt_rw.c

PATCH In review Ryan Long 3 participants 5 messages Mar 1, 2021 – Mar 3, 2021 3 messages not in the archive

lore
Share & tools
lore

Ryan Long

author
#0 lore raw

PATCH 1/1 Unchecked return value error in fdt_rw.c

Hi,

I filed an issue on github, but I was told it'd be good to send this to the mailing list as well.

RTEMS (RTEMS.org) is a free single process, multi-threaded real-time operating system with a long history. Your dtc toolchain has been incorporated into RTEMS. The RTEMS Project is a member of the Coverity Scan program and it flagged an issue with /dtc/libfdt/fdt_rw.c. In trying to be good citizens of the wider open source community, the project wants these issues to be reported to the upstream owner along with a fix or suggestions. This is one of those reports.

When Coverity Scan was ran on some of your code, a "Unchecked return value" error was found at line 352 in fdt_rw.c. For similar errors that we received for RTEMS, we created a macro that will assert the value returned and "use" the return value like so.

int status = fdt_next_tag(fdt, parentoffsetm &nextoffset); assert(status == 0);
(void)status;

For this patch, I just put the "(void)" statement in front of the function call, and it achieves the same results. Could this be put in? We don't want to deviate from our upstream codebases, but we would also like to get rid of these errors.

Thanks,
Ryan

Ryan Long (1):
fdt_rw.c: Fix Unchecked return value error

 cpukit/dtc/libfdt/fdt_rw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
1.8.3.1

A message that is not in the archive (sent off-list or not yet received): 1614637450-4972-1-git-send-email-ryan.long-lGxtRh3/[email protected]

author
#2 lore raw

PATCH 1/1 fdt_rw.c: Fix Unchecked return value error

Fixed "Unchecked return value" error, by adding "(void)" in front of the function call.

---
 cpukit/dtc/libfdt/fdt_rw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpukit/dtc/libfdt/fdt_rw.c +1 -1
index 1385425..cdae5dd 100644
@@ -348,7 +348,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 		return offset;
 
 	/* Try to place the new node after the parent's properties */
-	fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */
+	(void) fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */
 	do {
 		offset = nextoffset;
 		tag = fdt_next_tag(fdt, offset, &nextoffset);
Signature · 1 line
1.8.3.1

A message that is not in the archive (sent off-list or not yet received): 1614637450-4972-2-git-send-email-ryan.long-lGxtRh3/[email protected]

#4 lore raw

Re: [PATCH] fdt_rw.c: Fix Unchecked return value error

Quoted 3 lines · Ryan Long

Fixed "Unchecked return value" error, by adding "(void)" in front of the function call.

You don't need cover letters for single patches. Move the explanation here because it's a lot better at explaining the why. The what is not needed here so much because we can read what the patch does.

You also need a S-o-b.

Quoted 9 lines
---
 cpukit/dtc/libfdt/fdt_rw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpukit/dtc/libfdt/fdt_rw.c +0 -0
index 1385425..cdae5dd 100644

cpukit/dtc/libfdt/fdt_rw.c int fdt_add_subnode_namelen(void *fdt, int parentoffset, · line 351

Quoted 5 lines
cpukit/dtc/libfdt/fdt_rw.c +1 -1
@@ -348,7 +348,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
                return offset;
 
        /* Try to place the new node after the parent's properties */
-       fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */
+       (void) fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */

Can't we just actually check the error here?

Quoted 6 lines
cpukit/dtc/libfdt/fdt_rw.c +0 -1
        do {
                offset = nextoffset;
                tag = fdt_next_tag(fdt, offset, &nextoffset);
--

1.8.3.1

#5 lore raw
In reply to a message not in the archive
Quoted 14 lines · Ryan Long

Hi,

I filed an issue on github, but I was told it'd be good to send this to the mailing list as well.

RTEMS (RTEMS.org) is a free single process, multi-threaded real-time operating system with a long history. Your dtc toolchain has been incorporated into RTEMS. The RTEMS Project is a member of the Coverity Scan program and it flagged an issue with /dtc/libfdt/fdt_rw.c. In trying to be good citizens of the wider open source community, the project wants these issues to be reported to the upstream owner along with a fix or suggestions. This is one of those reports.

Quoted 4 lines

When Coverity Scan was ran on some of your code, a "Unchecked return value" error was found at line 352 in fdt_rw.c. For similar errors that we received for RTEMS, we created a macro that will assert the value returned and "use" the return value like so.

Humm, I think Coverity scans run on the Linux kernel too, but I've never seen any reports on the kernel's copy. Just wondering why...

Rob

A message that is not in the archive (sent off-list or not yet received): CAL_JsqK68HjwdT5+-kjo3Yr7XokC=6ioa7dkMzeUsve8iEzVxA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#7 lore raw
Quoted 15 lines · Rob Herring
Quoted 14 lines · Ryan Long

Hi,

I filed an issue on github, but I was told it'd be good to send this to the mailing list as well.

RTEMS (RTEMS.org) is a free single process, multi-threaded real-time operating system with a long history. Your dtc toolchain has been incorporated into RTEMS. The RTEMS Project is a member of the Coverity Scan program and it flagged an issue with /dtc/libfdt/fdt_rw.c. In trying to be good citizens of the wider open source community, the project wants these issues to be reported to the upstream owner along with a fix or suggestions. This is one of those reports.

Quoted 7 lines
Quoted 4 lines

When Coverity Scan was ran on some of your code, a "Unchecked return value" error was found at line 352 in fdt_rw.c. For similar errors that we received for RTEMS, we created a macro that will assert the value returned and "use" the return value like so.

Humm, I think Coverity scans run on the Linux kernel too, but I've never seen any reports on the kernel's copy. Just wondering why...

It runs on dtc upstream as well.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson