Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: audio: tlv320dac310x: device config_info content mutated #25256

Closed
pabigot opened this issue May 12, 2020 · 1 comment
Closed

drivers: audio: tlv320dac310x: device config_info content mutated #25256

pabigot opened this issue May 12, 2020 · 1 comment
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale

Comments

@pabigot
Copy link
Collaborator

pabigot commented May 12, 2020

The device config_info structure is intended to be read-only, and so
the generic pointer stored in struct device is a pointer-to-const.
The tlv320dac310x driver removes this qualifier when casting the pointer to
the device-specific type. This removal is a violation of MISRA 11.8
as it evokes undefined behavior.

When the qualifier is preserved the driver does not build, because it modifies the object content at runtime. Consequently the fix for this driver has been removed from #25248.

https://github.com/pabigot/zephyr/commits/nordic/issue/24745b provides
the changes necessary to preserve const correctness. When applied it
produces the following diagnostic, among others:

/home/buildslave/src/github.com/zephyrproject-rtos/zephyr/drivers/audio/tlv320dac310x.c: In function 'codec_initialize':
/home/buildslave/src/github.com/zephyrproject-rtos/zephyr/drivers/audio/tlv320dac310x.c:81:22: error: assignment of member 'i2c_device' in read-only object
   81 |  dev_cfg->i2c_device = device_get_binding(dev_cfg->i2c_dev_name);
      |                      ^
/home/buildslave/src/github.com/zephyrproject-rtos/zephyr/drivers/audio/tlv320dac310x.c:89:23: error: assignment of member 'gpio_device' in read-only object
   89 |  dev_cfg->gpio_device = device_get_binding(dev_cfg->gpio_dev_name);

The driver must be updated to resolve this and incorporate the change from the referenced branch.

@pabigot pabigot added the bug The issue is a bug, or the PR is fixing a bug label May 12, 2020
@carlescufi carlescufi added the priority: low Low impact/importance bug label May 19, 2020
@github-actions
Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale
Projects
None yet
Development

No branches or pull requests

3 participants