Skip to contentSkip to conversation

selftests: gpio: fix minor build issues

PATCH Applied Kent Gibson 2 participants 5 messages Nov 8, 2021 – Nov 15, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover selftests: gpio: fix minor build issues

This is a series of fixes for minor problems in the building of the GPIO selftests introduced by my rework of those tests.

The first patch is from Li Zhijian and fixes a compiler error when building the selftests in environments with stale system includes. I have reworded the commit comment to make it more to the point in describing the root cause of the problem and the fix, as suggested by Shuah in his initial review of that patch.

The second patch fixes a warning when the tests are compiled with -Wall, and the final patch restores the CFLAGS that should not have been removed in the rework, including the -Wall.

Kent Gibson (2):
selftests: gpio: fix uninitialised variable warning
selftests: gpio: restore CFLAGS options

Li Zhijian (1):
selftests: gpio: fix gpio compiling error

 tools/testing/selftests/gpio/Makefile           | 1 +
 tools/testing/selftests/gpio/gpio-mockup-cdev.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.33.1
#1 lore raw

PATCH 1/3 selftests: gpio: fix gpio compiling error

From: Li Zhijian <[email protected]>

The gpio selftests build against the system includes rather than the headers from the linux tree. This results in the compile failing if the system includes are outdated.

Prefer the headers from the linux tree, as per other selftests.

Fixes 8bc395a6a2e2 ("selftests: gpio: rework and simplify test implementation")
[Kent: reworded commit comment and added Fixes:]
---
 tools/testing/selftests/gpio/Makefile | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/gpio/Makefile +1 -0
index 39f2bbe8dd3d..42ea7d2aa844 100644
@@ -3,5 +3,6 @@
 TEST_PROGS := gpio-mockup.sh
 TEST_FILES := gpio-mockup-sysfs.sh
 TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev
+CFLAGS += -I../../../../usr/include
 
 include ../lib.mk
Signature · 1 line
2.33.1
#2 lore raw

PATCH 2/3 selftests: gpio: fix uninitialised variable warning

In reply to Kent Gibson

When compiled with -Wall gpio-mockup-cdev.c reports an uninitialised variable warning. This is a false positive, as the variable is ignored in the case it is uninitialised, but initialise the variable anyway to remove the warning.

---
 tools/testing/selftests/gpio/gpio-mockup-cdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/gpio/gpio-mockup-cdev.c +1 -1
index e83eac71621a..d1640f44f8ac 100644
@@ -117,7 +117,7 @@ int main(int argc, char *argv[])
 {
 	char *chip;
 	int opt, ret, cfd, lfd;
-	unsigned int offset, val, abiv;
+	unsigned int offset, val = 0, abiv;
 	uint32_t flags_v1;
 	uint64_t flags_v2;
 
Signature · 1 line
2.33.1
#3 lore raw

PATCH 3/3 selftests: gpio: restore CFLAGS options

In reply to Kent Gibson

All the CFLAGS options were incorrectly removed in the recent rework of the GPIO selftests. While some of the flags were specific to the old implementation the remainder are still relevant. Restore those options.

---
 tools/testing/selftests/gpio/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/gpio/Makefile +1 -1
index 42ea7d2aa844..d7b312b44a62 100644
@@ -3,6 +3,6 @@
 TEST_PROGS := gpio-mockup.sh
 TEST_FILES := gpio-mockup-sysfs.sh
 TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev
-CFLAGS += -I../../../../usr/include
+CFLAGS += -O2 -g -Wall -I../../../../usr/include/
 
 include ../lib.mk
Signature · 1 line
2.33.1
#4 lore raw
In reply to Kent Gibson
Quoted 21 lines · Kent Gibson

This is a series of fixes for minor problems in the building of the GPIO selftests introduced by my rework of those tests.

The first patch is from Li Zhijian and fixes a compiler error when building the selftests in environments with stale system includes. I have reworded the commit comment to make it more to the point in describing the root cause of the problem and the fix, as suggested by Shuah in his initial review of that patch.

The second patch fixes a warning when the tests are compiled with -Wall, and the final patch restores the CFLAGS that should not have been removed in the rework, including the -Wall.

Kent Gibson (2):
selftests: gpio: fix uninitialised variable warning
selftests: gpio: restore CFLAGS options

Li Zhijian (1):
selftests: gpio: fix gpio compiling error

Quoted 7 lines
 tools/testing/selftests/gpio/Makefile           | 1 +
 tools/testing/selftests/gpio/gpio-mockup-cdev.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

--
2.33.1

Queued for fixes, thanks!

Bart