> -----Original Message----- > From: Keith Busch <[email protected]> > Sent: Tuesday, October 13, 2020 8:51 PM > To: Dmitry Fomichev <[email protected]> > Cc: Klaus Jensen <[email protected]>; Kevin Wolf > <[email protected]>; Philippe Mathieu-Daudé <[email protected]>; > Maxim Levitsky <[email protected]>; Fam Zheng <[email protected]>; > Alistair Francis <[email protected]>; Matias Bjorling > <[email protected]>; Niklas Cassel <[email protected]>; > Damien Le Moal <[email protected]>; [email protected]; > [email protected] > Subject: Re: [PATCH v6 01/11] hw/block/nvme: Add Commands Supported > and Effects log > > On Wed, Oct 14, 2020 at 06:42:02AM +0900, Dmitry Fomichev wrote: > > +{ > > + NvmeEffectsLog log = {}; > > + uint32_t *dst_acs = log.acs, *dst_iocs = log.iocs; > > + uint32_t trans_len; > > + int i; > > + > > + trace_pci_nvme_cmd_supp_and_effects_log_read(); > > + > > + if (off >= sizeof(log)) { > > + trace_pci_nvme_err_invalid_effects_log_offset(off); > > + return NVME_INVALID_FIELD | NVME_DNR; > > + } > > + > > + for (i = 0; i < 256; i++) { > > + dst_acs[i] = nvme_cse_acs[i]; > > + } > > + > > + for (i = 0; i < 256; i++) { > > + dst_iocs[i] = nvme_cse_iocs_nvm[i]; > > + } > > You're just copying the array, so let's do it like this: > > memcpy(log.acs, nvme_cse_acs, sizeof(nvme_cse_acs)); > memcpy(log.iocs, nvme_cse_iocs_nvm, sizeof(nvme_cse_iocs_nvm)); >
Sure, this is a lot cleaner. > I think you also need to check > > if (NVME_CC_CSS(n->bar.cc) != NVME_CC_CSS_ADMIN_ONLY) > > before copying iocs. Yes, thanks.
