On Wed, May 09, 2018 at 10:58:13PM +0800, Fam Zheng wrote: > +static int iscsi_populate_target_desc(unsigned char *desc, IscsiLun *lun)
The return values of these iscsi_populate_*() functions are unused and don't make sense since the caller must already know the size ahead of time. I suggest removing them to simplify the code. > +{ > + struct scsi_inquiry_device_designator *dd = lun->dd; > + > + memset(desc, 0, 32); > + desc[0] = IDENT_DESCR_TGT_DESCR; > + desc[4] = dd->code_set; > + desc[5] = (dd->designator_type & 0xF) > + | ((dd->association & 3) << 4); > + desc[7] = dd->designator_length; > + memcpy(desc + 8, dd->designator, dd->designator_length); > + > + desc[28] = 0; > + desc[29] = (lun->block_size >> 16) & 0xFF; > + desc[30] = (lun->block_size >> 8) & 0xFF; > + desc[31] = lun->block_size & 0xFF; > + > + return 32; > +} > + > +static int iscsi_xcopy_desc_hdr(uint8_t *hdr, int dc, int cat, int src_index, > + int dst_index) > +{ > + int desc_len = 28; s/desc_len/XCOPY_BLK2BLK_SEG_DESC_SIZE/ ? Then the 28 constant doesn't need to be duplicated. Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com>
signature.asc
Description: PGP signature