mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-17 10:41:26 +00:00
Micro-optimize scst_unpack_lun(): avoid comparing "len" twice with the constant "2".
Signed-off-by: Bart Van Assche <bvanassche@acm.org> git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3883 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -5292,30 +5292,28 @@ uint64_t scst_unpack_lun(const uint8_t *lun, int len)
|
||||
|
||||
TRACE_BUFF_FLAG(TRACE_DEBUG, "Raw LUN", lun, len);
|
||||
|
||||
if (unlikely(len < 2)) {
|
||||
PRINT_ERROR("Illegal lun length %d, expected 2 bytes or "
|
||||
"more", len);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (len > 2) {
|
||||
switch (len) {
|
||||
case 8:
|
||||
if ((*((__be64 *)lun) &
|
||||
cpu_to_be64(0x0000FFFFFFFFFFFFLL)) != 0)
|
||||
goto out_err;
|
||||
break;
|
||||
case 4:
|
||||
if (*((__be16 *)&lun[2]) != 0)
|
||||
goto out_err;
|
||||
break;
|
||||
case 6:
|
||||
if (*((__be32 *)&lun[2]) != 0)
|
||||
goto out_err;
|
||||
break;
|
||||
default:
|
||||
switch (len) {
|
||||
case 2:
|
||||
break;
|
||||
case 8:
|
||||
if ((*((__be64 *)lun) & cpu_to_be64(0x0000FFFFFFFFFFFFLL)) != 0)
|
||||
goto out_err;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (*((__be16 *)&lun[2]) != 0)
|
||||
goto out_err;
|
||||
break;
|
||||
case 6:
|
||||
if (*((__be32 *)&lun[2]) != 0)
|
||||
goto out_err;
|
||||
break;
|
||||
case 1:
|
||||
case 0:
|
||||
PRINT_ERROR("Illegal lun length %d, expected 2 bytes "
|
||||
"or more", len);
|
||||
goto out;
|
||||
default:
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
address_method = (*lun) >> 6; /* high 2 bits of byte 0 */
|
||||
|
||||
Reference in New Issue
Block a user