Skip to content

Commit

Permalink
fix for CR
Browse files Browse the repository at this point in the history
  • Loading branch information
jkralik committed Aug 25, 2022
1 parent ab0226f commit 5e309f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client/core/ownDevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,10 @@ func disownError(err error) error {
return fmt.Errorf("cannot disown device: %w", err)
}

// findOTMClient finds supported client in order as user wants. The first match will be used.
func findOTMClient(otmClients []otm.Client, deviceSupportedOwnerTransferMethods []doxm.OwnerTransferMethod) otm.Client {
for _, s := range deviceSupportedOwnerTransferMethods {
for _, c := range otmClients {
for _, c := range otmClients {
for _, s := range deviceSupportedOwnerTransferMethods {
if s == c.Type() {
return c
}
Expand Down Expand Up @@ -300,10 +301,9 @@ func (d *Device) Own(
return MakePermissionDenied(fmt.Errorf("device is already owned by %v", ownership.OwnerID))
}

//ownership := d.ownership
otmClient := findOTMClient(otmClients, ownership.SupportedOwnerTransferMethods)
if otmClient == nil {
return MakeUnavailable(fmt.Errorf("ownership transfer method '%v' is unsupported, supported are: %v", supportedOTMTypes(otmClients), ownership.SupportedOwnerTransferMethods))
return MakeUnavailable(fmt.Errorf("ownership transfer methods used by clients '%v' are not compatible with the device methods '%v'", supportedOTMTypes(otmClients), ownership.SupportedOwnerTransferMethods))
}

err = d.selectOTM(ctx, otmClient.Type())
Expand Down

0 comments on commit 5e309f0

Please sign in to comment.