Skip to content

Commit ed8bfd5

Browse files
Colin Ian Kingdavem330
authored andcommitted
VSOCK: remove unnecessary ternary operator on return value
Rather than assign the positive errno values to ret and then checking if it is positive and flip the sign, just return the errno value. Detected by CoverityScan, CID#986649 ("Logically Dead Code") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Jorgen Hansen <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 282ccf6 commit ed8bfd5

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

net/vmw_vsock/vmci_transport.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,23 @@ static int PROTOCOL_OVERRIDE = -1;
9696

9797
static s32 vmci_transport_error_to_vsock_error(s32 vmci_error)
9898
{
99-
int err;
100-
10199
switch (vmci_error) {
102100
case VMCI_ERROR_NO_MEM:
103-
err = ENOMEM;
104-
break;
101+
return -ENOMEM;
105102
case VMCI_ERROR_DUPLICATE_ENTRY:
106103
case VMCI_ERROR_ALREADY_EXISTS:
107-
err = EADDRINUSE;
108-
break;
104+
return -EADDRINUSE;
109105
case VMCI_ERROR_NO_ACCESS:
110-
err = EPERM;
111-
break;
106+
return -EPERM;
112107
case VMCI_ERROR_NO_RESOURCES:
113-
err = ENOBUFS;
114-
break;
108+
return -ENOBUFS;
115109
case VMCI_ERROR_INVALID_RESOURCE:
116-
err = EHOSTUNREACH;
117-
break;
110+
return -EHOSTUNREACH;
118111
case VMCI_ERROR_INVALID_ARGS:
119112
default:
120-
err = EINVAL;
113+
break;
121114
}
122-
123-
return err > 0 ? -err : err;
115+
return -EINVAL;
124116
}
125117

126118
static u32 vmci_transport_peer_rid(u32 peer_cid)

0 commit comments

Comments
 (0)