Re: [PATCH 6/6] scsi_scan: Fixup scsilun_to_int()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux