Skip to contentSkip to conversation

fdt_rw.c: Fix Unchecked return value error

PATCH In review Ryan Long 2 participants 2 messages Mar 2, 2021 – Mar 9, 2021 1 message not in the archive

lore
Share & tools
lore

Ryan Long

author
#0 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.

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 with (void).

---
 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): 1614715099-23657-1-git-send-email-ryan.long-lGxtRh3/[email protected]

#2 lore raw
Quoted 9 lines · Ryan Long

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

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 with (void).

It's weird that the Coverity Scan on dtc upstream didn't pick this up. I thought maybe it did at some point and I just marked it as a false positive, but I looked through and I couldn't seem to find it at all (though the Coverity UI is pretty confusing, so maybe I just missed it).

I've taken a slightly different approach to squashing this upstream, so I haven't applied this as is.

Quoted 17 lines
---
 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 · 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