AdaCore / AdaCore/Ada_Drivers_Library

Incorrect usage of 'Val instead of 'Enum_Val

Open
#431 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ada
Stars
286
Forks
165
PR merge metrics
No merged PRs in 30d

Description

The below line will raise a Constraint_Error if Range_Check is enabled as the enumeration is not continuous, using 'Enum_Val instead would fix this. This error could exist in the other uses of 'Val which I have not checked and it could have potentially worse consequences than this one which will likely be harmless when Range_Check is disabled.

https://github.com/AdaCore/Ada_Drivers_Library/blob/b651d01dcfd7e27836f938c1d494e1ed3212ed43/arch/ARM/STM32/drivers/stm32-adc.adb#L410

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open arch/ARM/STM32/drivers/stm32-adc.adb at the linked line around 410 and inspect the use of 'Val with the non-contiguous enumeration. Check the other 'Val uses mentioned in the issue for the same problem; done means the unsafe conversion is corrected and no similar affected use remains.

Written by the indexing model from the issue text.

Assessment

Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.