Skip to content

Commit

Permalink
Replace all asserts in kernel code with ASSERT
Browse files Browse the repository at this point in the history
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
  • Loading branch information
Gary-Hobson authored and xiaoxiang781216 committed May 11, 2024
1 parent 80aff63 commit 2d0a05c
Show file tree
Hide file tree
Showing 28 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions arch/arm/src/armv8-r/arm_gicv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static int arm_gic_send_sgi(unsigned int sgi_id, uint64_t target_aff,
uint32_t aff1;
uint64_t sgi_val;

assert(GIC_IS_SGI(sgi_id));
ASSERT(GIC_IS_SGI(sgi_id));

/* Extract affinity fields from target */

Expand Down Expand Up @@ -448,7 +448,7 @@ static void gicv3_cpuif_init(void)
CP15_SET(ICC_SRE, icc_sre);
icc_sre = CP15_GET(ICC_SRE);

assert(icc_sre & ICC_SRE_ELX_SRE_BIT);
ASSERT(icc_sre & ICC_SRE_ELX_SRE_BIT);
}

CP15_SET(ICC_PMR, GIC_IDLE_PRIO);
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/src/imxrt/imxrt_flexspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static uint32_t imxrt_flexspi_configure_dll(struct flexspi_type_s *base,
}
break;
default:
assert(false);
ASSERT(false);
break;
}

Expand Down Expand Up @@ -431,7 +431,7 @@ static int imxrt_flexspi_check_and_clear_error(struct flexspi_type_s *base,
}
else
{
assert(false);
ASSERT(false);
}

/* Clear the flags */
Expand Down Expand Up @@ -808,7 +808,7 @@ void imxrt_flexspi_update_lut_private(struct flexspi_type_s *base,
const uint32_t *cmd,
uint32_t count)
{
assert(index < 64u);
ASSERT(index < 64u);

uint32_t i = 0;
volatile uint32_t *lut_base;
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/src/lc823450/lc823450_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void lc823450_gpio_write(uint16_t gpiocfg, bool value)
#ifdef CONFIG_LC823450_VGPIO
if (port == (GPIO_PORTV >> GPIO_PORT_SHIFT))
{
assert(pin < GPIO_VIRTUAL_NUM);
ASSERT(pin < GPIO_VIRTUAL_NUM);
if (vgpio_ops[pin] && vgpio_ops[pin]->write)
{
vgpio_ops[pin]->write(pin, value);
Expand Down Expand Up @@ -437,7 +437,7 @@ bool lc823450_gpio_read(uint16_t gpiocfg)
#ifdef CONFIG_LC823450_VGPIO
if (port == (GPIO_PORTV >> GPIO_PORT_SHIFT))
{
assert(pin < GPIO_VIRTUAL_NUM);
ASSERT(pin < GPIO_VIRTUAL_NUM);
if (vgpio_ops[pin] && vgpio_ops[pin]->read)
{
return vgpio_ops[pin]->read(pin);
Expand Down Expand Up @@ -506,7 +506,7 @@ int lc823450_gpio_initialize(void)
#ifdef CONFIG_LC823450_VGPIO
int lc823450_vgpio_register(unsigned int pin, struct vgpio_ops_s *ops)
{
assert(pin < GPIO_VIRTUAL_NUM);
ASSERT(pin < GPIO_VIRTUAL_NUM);
vgpio_ops[pin] = ops;
return OK;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/phy62xx/phyplus_timer_lowerhalf.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static void phyplus_setcallback(struct timer_lowerhalf_s *lower,
}

leave_critical_section(flags);
assert(ret == OK);
ASSERT(ret == OK);

/* #if 0
* irqstate_t flags = enter_critical_section();
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/rp2040/rp2040_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bool rp2040_clock_configure(int clk_index,
{
uint32_t div;

assert(src_freq >= freq);
ASSERT(src_freq >= freq);

if (freq > src_freq)
{
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/src/rp2040/rp2040_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ static int hw_claim_unused_from_range(uint8_t *bits, bool required,
static void hw_claim_clear(uint8_t *bits, uint32_t bit_index)
{
uint32_t save = hw_claim_lock();
assert(bits[bit_index >> 3u] & (1u << (bit_index & 7u)));
ASSERT(bits[bit_index >> 3u] & (1u << (bit_index & 7u)));
bits[bit_index >> 3u] &= (uint8_t) ~(1u << (bit_index & 7u));
hw_claim_unlock(save);
}

static int _pio_find_offset_for_program(uint32_t pio,
const rp2040_pio_program_t *program)
{
assert(program->length < PIO_INSTRUCTION_COUNT);
ASSERT(program->length < PIO_INSTRUCTION_COUNT);
uint32_t used_mask = _used_instruction_space[rp2040_pio_get_index(pio)];
uint32_t program_mask = (1u << program->length) - 1;

Expand Down Expand Up @@ -306,7 +306,7 @@ void rp2040_pio_remove_program(uint32_t pio,
uint32_t program_mask = (1u << program->length) - 1;
program_mask <<= loaded_offset;
uint32_t save = hw_claim_lock();
assert(program_mask ==
ASSERT(program_mask ==
(_used_instruction_space[rp2040_pio_get_index(pio)] &
program_mask));
_used_instruction_space[rp2040_pio_get_index(pio)] &= ~program_mask;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/rp2040/rp2040_pio_instructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ inline static uint32_t _pio_encode_instr_and_args(
uint32_t major = _pio_major_instr_bits(instr_bits);
if (major == pio_instr_bits_in || major == pio_instr_bits_out)
{
assert(arg2 && arg2 <= 32);
ASSERT(arg2 && arg2 <= 32);
}
else
{
assert(arg2 <= 31);
ASSERT(arg2 <= 31);
}
#endif
return instr_bits | (arg1 << 5u) | (arg2 & 0x1fu);
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/src/rp2040/rp2040_pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ void rp2040_pll_init(uint32_t base, uint32_t refdiv, uint32_t vco_freq,

/* Check parameter ranges */

assert(fbdiv >= 16 && fbdiv <= 320);
assert((post_div1 >= 1 && post_div1 <= 7) &&
ASSERT(fbdiv >= 16 && fbdiv <= 320);
ASSERT((post_div1 >= 1 && post_div1 <= 7) &&
(post_div2 >= 1 && post_div2 <= 7));
assert(post_div2 <= post_div1);
assert(ref_mhz <= (vco_freq / 16));
ASSERT(post_div2 <= post_div1);
ASSERT(ref_mhz <= (vco_freq / 16));

/* Put calculated value into feedback divider */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/rp2040/rp2040_xosc.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void rp2040_xosc_init(void)
{
/* Assumes 1-15 MHz input */

assert(BOARD_XOSC_FREQ <= (15 * MHZ));
ASSERT(BOARD_XOSC_FREQ <= (15 * MHZ));
putreg32(RP2040_XOSC_CTRL_FREQ_RANGE_1_15MHZ, RP2040_XOSC_CTRL);

/* Set xosc startup delay */
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/tiva/common/tiva_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ static int tiva_pwm_ioctl(struct pwm_lowerhalf_s *dev, int cmd,

struct pwm_lowerhalf_s *tiva_pwm_initialize(int channel)
{
assert(channel >= 0 && channel <= 7);
ASSERT(channel >= 0 && channel <= 7);
struct tiva_pwm_chan_s *chan;

switch (channel)
Expand Down Expand Up @@ -824,7 +824,7 @@ struct pwm_lowerhalf_s *tiva_pwm_initialize(int channel)

/* Enable PWM controller (refer to TM4C1294NCPDT 23.4.1) */

assert(chan->controller_id == 0);
ASSERT(chan->controller_id == 0);
tiva_pwm_enablepwr(chan->controller_id);
tiva_pwm_enableclk(chan->controller_id);

Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/src/common/arm64_gicv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ static int arm64_gic_send_sgi(unsigned int sgi_id, uint64_t target_aff,
unsigned long base;

base = gic_get_rdist() + GICR_SGI_BASE_OFF;
assert(GIC_IS_SGI(sgi_id));
ASSERT(GIC_IS_SGI(sgi_id));

/* Extract affinity fields from target */

Expand Down Expand Up @@ -505,7 +505,7 @@ static void gicv3_cpuif_init(void)
write_sysreg(icc_sre, ICC_SRE_EL1);
icc_sre = read_sysreg(ICC_SRE_EL1);

assert(icc_sre & ICC_SRE_ELX_SRE_BIT);
ASSERT(icc_sre & ICC_SRE_ELX_SRE_BIT);
}

write_sysreg(GIC_IDLE_PRIO, ICC_PMR_EL1);
Expand Down
4 changes: 2 additions & 2 deletions arch/risc-v/src/bl602/bl602_os_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ void *bl_os_timer_create(void *func, void *argv)
struct timer_adpt *timer = kmm_malloc(sizeof(struct timer_adpt));
if (!timer)
{
assert(0);
ASSERT(0);
}

memset((void *)timer, 0, sizeof(struct timer_adpt));
Expand Down Expand Up @@ -1066,7 +1066,7 @@ void *bl_os_workqueue_create(void)
struct work_s *work = kmm_calloc(1, sizeof(struct work_s));
if (!work)
{
assert(0);
ASSERT(0);
}

return (void *)work;
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/esp32c3-legacy/esp32c3_rt_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ static int rt_timer_thread(int argc, char *argv[])
if (ret)
{
tmrerr("ERROR: Wait toutsem error=%d\n", ret);
assert(0);
ASSERT(0);
}

flags = enter_critical_section();
Expand Down
4 changes: 2 additions & 2 deletions arch/sim/src/sim/posix/sim_macho_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static void save_and_replace_init_funcs(int argc, const char *argv[],
init_func_t *fp;
unsigned int nfuncs = &mod_init_func_end - &mod_init_func_start;

assert(nfuncs > 0);
ASSERT(nfuncs > 0);
g_num_saved_init_funcs = nfuncs - 1;
if (g_num_saved_init_funcs == 0)
{
Expand All @@ -102,7 +102,7 @@ static void save_and_replace_init_funcs(int argc, const char *argv[],
{
if (*fp == save_and_replace_init_funcs)
{
assert(i == 0);
ASSERT(i == 0);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/esp32/esp32_psram.c
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ psram_enable(int mode, int vaddrmode) /* psram init */
}
}

assert(mode < PSRAM_CACHE_MAX && "we don't support any other mode.");
ASSERT(mode < PSRAM_CACHE_MAX && "we don't support any other mode.");
s_psram_mode = mode;

putreg32(0x1, SPI_EXT3_REG(0));
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/esp32/esp32_rt_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static int rt_timer_thread(int argc, char *argv[])
if (ret)
{
tmrerr("ERROR: Wait priv->toutsem error=%d\n", ret);
assert(0);
ASSERT(0);
}

flags = spin_lock_irqsave(&priv->lock);
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/esp32/esp32_tim_lowerhalf.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static void esp32_timer_setcallback(struct timer_lowerhalf_s *lower,
}

spin_unlock_irqrestore(&priv->lock, flags);
assert(ret == OK);
ASSERT(ret == OK);
}

/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/esp32s2/esp32s2_rt_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ static int rt_timer_thread(int argc, char *argv[])
if (ret)
{
tmrerr("ERROR: Wait priv->toutsem error=%d\n", ret);
assert(0);
ASSERT(0);
}

flags = enter_critical_section();
Expand Down
4 changes: 2 additions & 2 deletions arch/xtensa/src/esp32s2/esp32s2_spiram.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ int mmu_map_psram(uint32_t start_paddr, uint32_t end_paddr,

/* should be MMU page aligned */

assert((start_paddr % MMU_PAGE_SIZE) == 0);
ASSERT((start_paddr % MMU_PAGE_SIZE) == 0);

uint32_t start_vaddr = DPORT_CACHE_ADDRESS_LOW;
uint32_t end_vaddr = start_vaddr + map_length;
Expand All @@ -156,7 +156,7 @@ int mmu_map_psram(uint32_t start_paddr, uint32_t end_paddr,
cache_bus_mask |= (end_vaddr >= DRAM1_ADDRESS_HIGH) ?
EXTMEM_PRO_DCACHE_MASK_DRAM0 : 0;

assert(end_vaddr <= DRAM0_CACHE_ADDRESS_HIGH);
ASSERT(end_vaddr <= DRAM0_CACHE_ADDRESS_HIGH);

minfo("start_paddr is %x, map_length is %xB, %d pages",
start_paddr, map_length, BYTES_TO_MMU_PAGE(map_length));
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/esp32s3/esp32s3_psram_quad.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static void psram_gpio_config(void)

int psram_enable(int mode, int vaddrmode)
{
assert(mode < PSRAM_CACHE_MAX && \
ASSERT(mode < PSRAM_CACHE_MAX && \
"we don't support any other mode for now.");

psram_gpio_config();
Expand Down
2 changes: 1 addition & 1 deletion crypto/bn.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

/* Custom assert macro - easy to disable */

#define require(p, msg) assert(p && msg)
#define require(p, msg) ASSERT(p && msg)

/****************************************************************************
* Private Functions Prototype
Expand Down
4 changes: 2 additions & 2 deletions drivers/usbdev/usbdev_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ static int usbdev_fs_open(FAR struct file *filep)

fs_ep->crefs += 1;

assert(fs_ep->crefs != 0);
ASSERT(fs_ep->crefs != 0);

nxmutex_unlock(&fs_ep->lock);
return ret;
Expand Down Expand Up @@ -510,7 +510,7 @@ static int usbdev_fs_close(FAR struct file *filep)

fs_ep->crefs -= 1;

assert(fs_ep->crefs >= 0);
ASSERT(fs_ep->crefs >= 0);

if (fs_ep->unlinked && fs_ep->crefs == 0)
{
Expand Down
Loading

0 comments on commit 2d0a05c

Please sign in to comment.