Page MenuHomeFreeBSD

Use C errno as return value for cam_periph_acquire()
ClosedPublic

Authored by scottl on Jan 26 2018, 10:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 8, 12:01 AM
Unknown Object (File)
Tue, May 7, 11:16 PM
Unknown Object (File)
Fri, Apr 26, 4:37 PM
Unknown Object (File)
Wed, Apr 24, 4:49 PM
Unknown Object (File)
Mar 23 2024, 9:01 AM
Unknown Object (File)
Jan 14 2024, 4:52 AM
Unknown Object (File)
Dec 22 2023, 11:13 PM
Unknown Object (File)
Dec 13 2023, 1:02 AM
Subscribers
None

Details

Summary

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.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 14596
Build 14729: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Jan 26 2018, 10:11 PM
ken requested changes to this revision.Feb 1 2018, 11:39 PM

The change in general is fine. It just needs fixing in the ctlferegister() case.

sys/cam/ctl/scsi_ctl.c
546

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.

This revision now requires changes to proceed.Feb 1 2018, 11:39 PM
sys/cam/ctl/scsi_ctl.c
546

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

Why still cam_status here? Should be an int probably.

sys/cam/cam_periph.c
409

Good catch, I'll fix it.

In D14063#298088, @mav wrote:

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).

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.

This revision was not accepted when it landed; it landed in state Needs Revision.Jun 26 2018, 9:55 PM
This revision was automatically updated to reflect the committed changes.