There's no compelling reason to return a cam_status type for
cam_periph_acquire(), and doing so only creates confusion with normal C
coding practices. It's technically an API change, but the periph API
isn't widely used. No efffective change to operation.
Details
- Reviewers
imp mav ken - Commits
- rS328918: Return a C errno for cam_periph_acquire().
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
The change in general is fine. It just needs fixing in the ctlferegister() case.
sys/cam/ctl/scsi_ctl.c | ||
---|---|---|
546 ↗ | (On Diff #38498) | This isn't quite right. ctlferegister() is defined to return cam_status. The status variable is set above to CAM_REQ_CMP, and then reset to various things as we go through the loop. Here, you're returning the status value that probably reflects success, but it should reflect a failure to acquire. So, how about returning CAM_REQ_CMP_ERR here. |
sys/cam/ctl/scsi_ctl.c | ||
---|---|---|
546 ↗ | (On Diff #38498) | Good catch, thanks. |
I neither have major objections aside of one inline, nor too happy. From one side I agree that there is no any/much sense to return cam_status from functions like that, which do not work with command statuses. From the other side it is a) an API change, which may lead to difficult to find errors, but b) there are many other functions suffering the same problem (but which may be more invasive to fix though).
sys/cam/cam_periph.c | ||
---|---|---|
409 ↗ | (On Diff #38498) | Why still cam_status here? Should be an int probably. |
sys/cam/cam_periph.c | ||
---|---|---|
409 ↗ | (On Diff #38498) | Good catch, I'll fix it. |
This is just the first part of a larger project to clean up CAM. Some of the other functions that you refer to will be fixed after this.