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:
Vladislav Bolkhovitin
2011-09-28 02:18:44 +00:00
parent 32991d0fd4
commit 4ec4d341eb

View File

@@ -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 */