#2288 assigned defect

Use of assert()

Reported by: Joel Sherrill Owned by: Needs Funding
Priority: normal Milestone: Indefinite
Component: unspecified Version: 4.11
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

While reviewing test results, I noticed a few uses of regular assert().

There are 92 in cpukit/.
There are 70 in testsuites/
There are 371 in c/

Should at least the ones in cpukit/ be changed to RTEMS asserts before we branch?

Attachments (1)

SQUASHED-Fix-Use-of-assert-ticket-2288.patch (169.9 KB) - added by jfjhh on Dec 25, 2015 at 10:01:52 PM.
Fixes usage of assert(). Adds a new bsp_error_code block.

Download all attachments as: .zip

Change History (4)

comment:1 Changed on Mar 9, 2015 at 6:32:13 PM by Joel Sherrill

My gut feeling is that the set in the tests and the cpukit should be addressed real soon. The BSPs may need a review but I wouldn't hold a release if all were not changed. If we have some thought on how to fix it that can be addressed with a script, that might be workable though.

FWIW this looks like the set of tests using assert().

./fstests/fstime/test.c
./libtests/block09/init.c
./libtests/block10/init.c
./libtests/capture01/init.c
./libtests/exit01/init.c
./libtests/exit02/init.c
./libtests/flashdisk01/test-file-system.c
./smptests/smpfatal01/init.c
./smptests/smpfatal02/init.c
./smptests/smpfatal03/init.c
./smptests/smpfatal04/init.c
./smptests/smpfatal05/init.c
./smptests/smpfatal08/init.c
./sptests/spheapprot/init.c

So that shouldn't be too bad to correct if all can be safely changed to rtems_test_assert().

I am also not sure what rb_heap_assert() maps down to.


This is the set of files in cpukit/. Note event.h is definitely just in a comment.

./libblock/src/media.c
./libblock/src/media-path.c
./libblock/src/media-server.c
./libcsupport/include/rtems/libcsupport.h
./libcsupport/src/envlock.c
./libfs/src/dosfs/fat_file.c
./libfs/src/dosfs/msdos_conv_utf8.c
./libfs/src/dosfs/msdos_misc.c
./libfs/src/imfs/imfs.h
./libfs/src/jffs2/include/asm/bug.h
./libfs/src/jffs2/include/rtems/jffs2.h
./libmisc/shell/shell.c
./mghttpd/mongoose.c
./posix/include/rtems/posix/aio_misc.h
./posix/src/sigsuspend.c
./rtems/include/rtems/rtems/event.h
./score/cpu/arm/tls_get_addr.c
./score/include/rtems/score/assert.h
./score/include/rtems/score/interr.h


And this is the set of files using assert() in c/:

./src/libchip/ide/ata.c
./src/libchip/ide/ata_util.c
./src/libchip/network/dwmac-1000-core.c
./src/libchip/network/dwmac.c
./src/libchip/network/dwmac-desc-enh.c
./src/libchip/shmdr/init.c
./src/libchip/shmdr/poll.c
./src/lib/libbsp/arm/altera-cyclone-v/i2c/i2cdrv.c
./src/lib/libbsp/arm/altera-cyclone-v/network/network.c
./src/lib/libbsp/arm/altera-cyclone-v/rtc/rtc.c
./src/lib/libbsp/arm/csb336/console/uart.c
./src/lib/libbsp/arm/csb336/network/network.c
./src/lib/libbsp/arm/csb337/network/network.c
./src/lib/libbsp/arm/edb7312/clock/clockdrv.c
./src/lib/libbsp/arm/edb7312/network/network.c
./src/lib/libbsp/arm/gba/clock/clockdrv.c
./src/lib/libbsp/arm/gumstix/rtl8019/rtl8019.c
./src/lib/libbsp/arm/lm3s69xx/console/uart.c
./src/lib/libbsp/arm/lm3s69xx/startup/bspstart.c
./src/lib/libbsp/arm/lpc176x/gpio/gpio.c
./src/lib/libbsp/arm/lpc176x/misc/io.c
./src/lib/libbsp/arm/lpc176x/timer/timer.c
./src/lib/libbsp/arm/lpc24xx/include/io.h
./src/lib/libbsp/arm/lpc24xx/misc/lcd.c
./src/lib/libbsp/arm/lpc32xx/include/tm27.h
./src/lib/libbsp/arm/rtl22xx/network/network.c
./src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c
./src/lib/libbsp/arm/shared/arm-l2c-310/cache_.h
./src/lib/libbsp/arm/shared/arm-pl050.c
./src/lib/libbsp/arm/shared/arm-pl111-fb.c
./src/lib/libbsp/arm/shared/comm/uart.c
./src/lib/libbsp/arm/shared/include/arm-gic-tm27.h
./src/lib/libbsp/arm/shared/lpc/network/lpc-ethernet.c
./src/lib/libbsp/arm/stm32f4/i2c/i2c.c
./src/lib/libbsp/arm/stm32f4/startup/bspstart.c
./src/lib/libbsp/i386/pc386/3c509/3c509.c
./src/lib/libbsp/i386/pc386/clock/ckinit.c
./src/lib/libbsp/i386/pc386/console/ps2_mouse.c
./src/lib/libbsp/i386/pc386/console/vgacons.c
./src/lib/libbsp/i386/pc386/wd8003/wd8003.c
./src/lib/libbsp/i386/shared/comm/i386-stub-glue.c
./src/lib/libbsp/i386/shared/comm/tty_drv.c
./src/lib/libbsp/i386/shared/comm/uart.c
./src/lib/libbsp/i386/shared/smp/smp-imps.c
./src/lib/libbsp/mips/csb350/network/network.c
./src/lib/libbsp/powerpc/beatnik/network/if_mve/mv643xx_eth.c
./src/lib/libbsp/powerpc/gen5200/bestcomm/bestcomm_glue.c
./src/lib/libbsp/powerpc/gen5200/console/console.c
./src/lib/libbsp/powerpc/gen5200/ide/ata.c
./src/lib/libbsp/powerpc/gen5200/ide/ata-dma-pio-single.c
./src/lib/libbsp/powerpc/gen5200/include/ata.h
./src/lib/libbsp/powerpc/gen5200/include/bestcomm.h
./src/lib/libbsp/powerpc/gen5200/startup/bestcomm.c
./src/lib/libbsp/powerpc/mpc55xxevb/network/smsc9218i.c
./src/lib/libbsp/powerpc/qoriq/console/uart-bridge-master.c
./src/lib/libbsp/powerpc/qoriq/console/uart-bridge-slave.c
./src/lib/libbsp/powerpc/qoriq/include/tm27.h
./src/lib/libbsp/powerpc/qoriq/network/network.c
./src/lib/libbsp/powerpc/score603e/irq/FPGA.c
./src/lib/libbsp/powerpc/score603e/PCI_bus/flash.c
./src/lib/libbsp/powerpc/score603e/timer/timer.c
./src/lib/libbsp/powerpc/shared/console/console.c
./src/lib/libbsp/powerpc/shared/console/uart.c
./src/lib/libbsp/powerpc/virtex/console/consolelite.c
./src/lib/libbsp/powerpc/virtex/network/xiltemac.c
./src/lib/libbsp/shared/console-polled.c
./src/lib/libbsp/sparc/leon2/console/console.c
./src/lib/libbsp/sparc/leon2/console/debugputs.c
./src/lib/libcpu/powerpc/mpc6xx/timer/timer.c

Last edited on Mar 9, 2015 at 6:40:20 PM by Joel Sherrill (previous) (diff)

comment:2 Changed on May 16, 2015 at 9:42:56 AM by Sebastian Huber

The problem with rtems_test_assert() is that it ends up in exit() which is not a good idea in certain tests.

The assert() in c/ should get converted to bsp_fatal(). In cpukit to _Assert() or a fatal error with a unique (source, code). Maybe we should add a rtems_assert() (like assert() but controlled via RTEMS_DEBUG).

Changed on Dec 25, 2015 at 10:01:52 PM by jfjhh

Fixes usage of assert(). Adds a new bsp_error_code block.

comment:3 Changed on Jan 25, 2017 at 1:05:19 PM by Sebastian Huber

Milestone: 4.11Indefinite
Owner: set to Needs Funding
Status: newassigned
Note: See TracTickets for help on using tickets.