Skip to contentSkip to conversation

pylibfdt: Rework "avoid unused variable warning" lines

PATCH Applied Tom Rini 2 participants 2 messages May 24, 2021 – May 25, 2021 1 message not in the archive

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 pylibfdt: Rework "avoid unused variable warning" lines

Clang has -Wself-assign enabled by default under -Wall and so when building with -Werror we would get an error here. Inspired by Linux kernel git commit a21151b9d81a ("tools/build: tweak unused value workaround") make use of the fact that both Clang and GCC support casting to void as the method to note that something is intentionally unused.

---
 pylibfdt/libfdt.i | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
pylibfdt/libfdt.i +2 -2
index 3e09d3a7eedc..51ee8014d17c 100644
@@ -1009,7 +1009,7 @@ typedef uint32_t fdt32_t;
 	}
 	$1 = (void *)PyByteArray_AsString($input);
         fdt = $1;
-        fdt = fdt; /* avoid unused variable warning */
+        (void)fdt; /* avoid unused variable warning */
 }
 
 /* Some functions do change the device tree, so use void * */
@@ -1020,7 +1020,7 @@ typedef uint32_t fdt32_t;
 	}
 	$1 = PyByteArray_AsString($input);
         fdt = $1;
-        fdt = fdt; /* avoid unused variable warning */
+        (void)fdt; /* avoid unused variable warning */
 }
 
 /* typemap used for fdt_get_property_by_offset() */
Signature · 1 line
2.17.1

A message that is not in the archive (sent off-list or not yet received): 20210524154910.30523-1-trini-OWPKS81ov/FWk0Htik3J/[email protected]

Applied
#2 lore raw
Quoted 8 lines · Tom Rini

Clang has -Wself-assign enabled by default under -Wall and so when building with -Werror we would get an error here. Inspired by Linux kernel git commit a21151b9d81a ("tools/build: tweak unused value workaround") make use of the fact that both Clang and GCC support casting to void as the method to note that something is intentionally unused.

Applied, thanks.

Quoted 26 lines
---
 pylibfdt/libfdt.i | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
pylibfdt/libfdt.i +2 -2
index 3e09d3a7eedc..51ee8014d17c 100644
@@ -1009,7 +1009,7 @@ typedef uint32_t fdt32_t;
 	}
 	$1 = (void *)PyByteArray_AsString($input);
         fdt = $1;
-        fdt = fdt; /* avoid unused variable warning */
+        (void)fdt; /* avoid unused variable warning */
 }
 
 /* Some functions do change the device tree, so use void * */
@@ -1020,7 +1020,7 @@ typedef uint32_t fdt32_t;
 	}
 	$1 = PyByteArray_AsString($input);
         fdt = $1;
-        fdt = fdt; /* avoid unused variable warning */
+        (void)fdt; /* avoid unused variable warning */
 }
 
 /* typemap used for fdt_get_property_by_offset() */
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