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

clock_control: int is returned on enum return value #32385

Closed
alexanderwachter opened this issue Feb 17, 2021 · 1 comment · Fixed by #32386
Closed

clock_control: int is returned on enum return value #32385

alexanderwachter opened this issue Feb 17, 2021 · 1 comment · Fixed by #32386
Assignees
Labels
area: Clock Control bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@alexanderwachter
Copy link
Member

Describe the bug
When using clock_control.h in an app, it does not compile due to warnings.
The return value of the function in an enum, but in case the device is not ready, a posix error code is returned.

static inline enum clock_control_status clock_control_get_status(const struct device *dev,
								 clock_control_subsys_t sys)
{
	const struct clock_control_driver_api *api =
		(const struct clock_control_driver_api *)dev->api;

	if (!api->get_status) {
		return CLOCK_CONTROL_STATUS_UNKNOWN;
	}

	if (!device_is_ready(dev)) {
		return -ENODEV;
	}

	return api->get_status(dev, sys);
}

To Reproduce
Compile a C++ app that includes clock_control.h

Expected behavior
Only return values from the enum

Impact
APP does not compile

Logs and console output

zephyr/include/drivers/clock_control.h:193:11: error: invalid conversion from 'int' to 'clock_control_status' [-fpermissive]
  193 |   return -ENODEV;
      |           ^~~~~~
      |           |
      |           int
@alexanderwachter alexanderwachter added bug The issue is a bug, or the PR is fixing a bug area: Clock Control labels Feb 17, 2021
@alexanderwachter alexanderwachter changed the title clock_control: clock_control: int is returned on enum return value Feb 17, 2021
@alexanderwachter
Copy link
Member Author

PR: #32386

@nashif nashif added the priority: low Low impact/importance bug label Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Clock Control bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants