diff --git a/lib/scsi/scsi_bdev.c b/lib/scsi/scsi_bdev.c index e135296e0a..fe6b1d2044 100644 --- a/lib/scsi/scsi_bdev.c +++ b/lib/scsi/scsi_bdev.c @@ -1614,15 +1614,16 @@ bdev_scsi_process_block(struct spdk_scsi_task *task) switch (cdb[1] & 0x1f) { /* SERVICE ACTION */ case SPDK_SBC_SAI_READ_CAPACITY_16: { uint8_t buffer[32] = {0}; - uint32_t lbppb; + uint32_t lbppb, lbppbe; to_be64(&buffer[0], spdk_bdev_get_num_blocks(bdev) - 1); to_be32(&buffer[8], spdk_bdev_get_data_block_size(bdev)); lbppb = spdk_bdev_get_physical_block_size(bdev) / spdk_bdev_get_data_block_size(bdev); - if (spdk_u32log2(lbppb) > 0xf) { - SPDK_ERRLOG("lbppbe(0x%x) > 0xf\n", spdk_u32log2(lbppb)); + lbppbe = spdk_u32log2(lbppb); + if (lbppbe > 0xf) { + SPDK_ERRLOG("lbppbe(0x%x) > 0xf\n", lbppbe); } else { - buffer[13] = spdk_u32log2(lbppb); + buffer[13] = lbppbe; } /* * Set the TPE bit to 1 to indicate thin provisioning.