Skip to content

Commit ae86c6e

Browse files
unicornxRbb666
authored andcommitted
componnets: drivers: adc: remove build warnings
gcc build warnings: cast from pointer to integer of different size [-Wpointer-to-int-cast] For rt_adc_ops.enabled, the type of second param is rt_int8_t, original _adc_control also called with wrong type casting. Convert first to rt_base_t, then cast to rt_int8_t to remove the build warnings. Signed-off-by: Chen Wang <[email protected]>
1 parent 719cc90 commit ae86c6e

File tree

1 file changed

+2
-3
lines changed
  • components/drivers/misc

1 file changed

+2
-3
lines changed

components/drivers/misc/adc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,13 @@ static rt_err_t _adc_control(rt_device_t dev, int cmd, void *args)
4545
rt_adc_device_t adc = (struct rt_adc_device *)dev;
4646
rt_err_t result;
4747

48-
4948
if (cmd == RT_ADC_CMD_ENABLE && adc->ops->enabled)
5049
{
51-
result = adc->ops->enabled(adc, (rt_uint32_t)args, RT_TRUE);
50+
result = adc->ops->enabled(adc, (rt_int8_t)(rt_base_t)args, RT_TRUE);
5251
}
5352
else if (cmd == RT_ADC_CMD_DISABLE && adc->ops->enabled)
5453
{
55-
result = adc->ops->enabled(adc, (rt_uint32_t)args, RT_FALSE);
54+
result = adc->ops->enabled(adc, (rt_int8_t)(rt_base_t)args, RT_FALSE);
5655
}
5756
else if (cmd == RT_ADC_CMD_GET_RESOLUTION && adc->ops->get_resolution && args)
5857
{

0 commit comments

Comments
 (0)