Skip to content

tests/driver_hih6130: fix 'absolute-value' error [backport 2021.01]#16141

Closed
aabadie wants to merge 1 commit intoRIOT-OS:2021.01-branchfrom
aabadie:backport/2021.01/pr/tests/driver_hih6130_fix_integer_absolute
Closed

tests/driver_hih6130: fix 'absolute-value' error [backport 2021.01]#16141
aabadie wants to merge 1 commit intoRIOT-OS:2021.01-branchfrom
aabadie:backport/2021.01/pr/tests/driver_hih6130_fix_integer_absolute

Conversation

@aabadie
Copy link
Contributor

@aabadie aabadie commented Mar 3, 2021

Backport of #15964

Contribution description

This PR fixes a minor issues with a couple of calls of abs in tests/driver_hih6130. This function expect an int as input but a float is given. This leads to an error with gcc 10 (on riscv).
The proposed fix is to cast it to an int. It's untested but now it builds fine.

Testing procedure

  • Green Murdock
  • If someone has the sensor, it would nice to have this PR tested on it
  • The build succeeds on gcc 10 riscv:
this PR:
$ BUILD_IN_DOCKER=1 make BOARD=atmega256rfr2-xpro -C tests/driver_hih6130/ --no-print-directory Launching build container using image "riot/riotbuild:latest".
docker run --rm --tty --user $(id -u) -v '/usr/share/zoneinfo/Europe/Paris:/etc/localtime:ro' -v '/work/riot/RIOT-review:/data/riotbuild/riotbase:delegated' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'      -e 'BOARD=atmega256rfr2-xpro'  -w '/data/riotbuild/riotbase/tests/driver_hih6130/' 'riot/riotbuild:latest' make 'BOARD=atmega256rfr2-xpro'    
Building application "tests_driver_hih6130" for "atmega256rfr2-xpro" with MCU "atmega256rfr2".

"make" -C /data/riotbuild/riotbase/boards/atmega256rfr2-xpro
"make" -C /data/riotbuild/riotbase/boards/common/atmega
"make" -C /data/riotbuild/riotbase/core
"make" -C /data/riotbuild/riotbase/cpu/atmega256rfr2
"make" -C /data/riotbuild/riotbase/cpu/atmega_common
"make" -C /data/riotbuild/riotbase/cpu/atmega_common/periph
"make" -C /data/riotbuild/riotbase/cpu/avr8_common
"make" -C /data/riotbuild/riotbase/cpu/avr8_common/avr_libc_extra
"make" -C /data/riotbuild/riotbase/drivers
"make" -C /data/riotbuild/riotbase/drivers/hih6130
"make" -C /data/riotbuild/riotbase/drivers/periph_common
"make" -C /data/riotbuild/riotbase/sys
"make" -C /data/riotbuild/riotbase/sys/auto_init
"make" -C /data/riotbuild/riotbase/sys/div
"make" -C /data/riotbuild/riotbase/sys/malloc_thread_safe
"make" -C /data/riotbuild/riotbase/sys/stdio_uart
"make" -C /data/riotbuild/riotbase/sys/xtimer
   text	   data	    bss	    dec	    hex	filename
  11390	    556	    984	  12930	   3282	/data/riotbuild/riotbase/tests/driver_hih6130/bin/atmega256rfr2-xpro/tests_driver_hih6130.elf
master:
$ BUILD_IN_DOCKER=1 make BOARD=hifive1b -C tests/driver_hih6130/ --no-print-directory 
Launching build container using image "riot/riotbuild:latest".
docker run --rm --tty --user $(id -u) -v '/usr/share/zoneinfo/Europe/Paris:/etc/localtime:ro' -v '/work/riot/RIOT-review:/data/riotbuild/riotbase:delegated' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles'      -e 'BOARD=hifive1b'  -w '/data/riotbuild/riotbase/tests/driver_hih6130/' 'riot/riotbuild:latest' make 'BOARD=hifive1b'    
Building application "tests_driver_hih6130" for "hifive1b" with MCU "fe310".

/data/riotbuild/riotbase/tests/driver_hih6130/main.c: In function 'main':
/data/riotbuild/riotbase/tests/driver_hih6130/main.c:68:42: error: using integer absolute value function 'abs' when argument is of floating-point type 'float' [-Werror=absolute-value]
   68 |             (int)integral, (unsigned int)abs(fractional * 10000.f));
      |                                          ^~~
/data/riotbuild/riotbase/tests/driver_hih6130/main.c:71:42: error: using integer absolute value function 'abs' when argument is of floating-point type 'float' [-Werror=absolute-value]
   71 |             (int)integral, (unsigned int)abs(fractional * 10000.f));
      |                                          ^~~
cc1: all warnings being treated as errors
/data/riotbuild/riotbase/Makefile.base:107: recipe for target '/data/riotbuild/riotbase/tests/driver_hih6130/bin/hifive1b/application_tests_driver_hih6130/main.o' failed
make[1]: *** [/data/riotbuild/riotbase/tests/driver_hih6130/bin/hifive1b/application_tests_driver_hih6130/main.o] Error 1
/data/riotbuild/riotbase/Makefile.include:618: recipe for target 'application_tests_driver_hih6130.module' failed
make: *** [application_tests_driver_hih6130.module] Error 2

Issues/PRs references

Must be fixed before RIOT-OS/riotdocker#131 is merged and deployed on Murdock workers.

@aabadie aabadie added Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Process: release backport Integration Process: The PR is a release backport of a change previously provided to master Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 3, 2021
@aabadie
Copy link
Contributor Author

aabadie commented Mar 4, 2021

Merged with #16140

@aabadie aabadie closed this Mar 4, 2021
@aabadie aabadie deleted the backport/2021.01/pr/tests/driver_hih6130_fix_integer_absolute branch March 4, 2021 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: tests Area: tests and testing framework Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Process: release backport Integration Process: The PR is a release backport of a change previously provided to master Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant