On 05/31/14 11:01, Hannes Reinecke wrote:
> u64 scsilun_to_int(struct scsi_lun *scsilun)
> {
> - int i;
> - u64 lun;
> + const unsigned char * cp;
> + uint64_t res;
>
> - lun = 0;
> - for (i = 0; i < sizeof(lun); i += 2)
> - lun = lun | (((scsilun->scsi_lun[i] << 8) |
> - scsilun->scsi_lun[i + 1]) << (i * 8));
> - return lun;
> + res = (scsilun->scsi_lun[6] << 8) + scsilun->scsi_lun[7];
> + for (cp = scsilun->scsi_lun + 4; cp >= scsilun->scsi_lun; cp -= 2) {
> + res <<= 16;
> + res += (*cp << 8) + *(cp + 1);
> + }
> + return res;
> }
> EXPORT_SYMBOL(scsilun_to_int);
Has it been considered to use get_unaligned_be16(cp) instead of (*cp <<
8) + *(cp + 1) ? At least in my opinion the former is easier to read.
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html