lib/idxd: Fix warning on cleanlinux with gcc-10.

home/clear/spdk/lib/idxd/idxd.c: In function ‘spdk_idxd_submit_copy’:
/home/clear/spdk/lib/idxd/idxd.c:761:5: error: ‘src_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  761 |  if (src_nbytes < nbytes || dst_nbytes < nbytes) {
      |     ^
/home/clear/spdk/lib/idxd/idxd.c:761:26: error: ‘dst_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  761 |  if (src_nbytes < nbytes || dst_nbytes < nbytes) {
      |      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
  LINK lvol_ut
/home/clear/spdk/lib/idxd/idxd.c: In function ‘spdk_idxd_submit_dualcast’:
/home/clear/spdk/lib/idxd/idxd.c:806:5: error: ‘src_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  806 |  if (src_nbytes < nbytes || dst1_nbytes < nbytes || dst2_nbytes < nbytes) {
      |     ^
/home/clear/spdk/lib/idxd/idxd.c:806:26: error: ‘dst1_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  806 |  if (src_nbytes < nbytes || dst1_nbytes < nbytes || dst2_nbytes < nbytes) {
      |      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/home/clear/spdk/lib/idxd/idxd.c:806:50: error: ‘dst2_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  806 |  if (src_nbytes < nbytes || dst1_nbytes < nbytes || dst2_nbytes < nbytes) {
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/home/clear/spdk/lib/idxd/idxd.c: In function ‘spdk_idxd_submit_compare’:
/home/clear/spdk/lib/idxd/idxd.c:845:5: error: ‘src1_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  845 |  if (src1_nbytes < nbytes || src2_nbytes < nbytes) {
      |     ^
/home/clear/spdk/lib/idxd/idxd.c:845:27: error: ‘src2_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  845 |  if (src1_nbytes < nbytes || src2_nbytes < nbytes) {
      |      ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/home/clear/spdk/lib/idxd/idxd.c: In function ‘spdk_idxd_submit_fill’:
/home/clear/spdk/lib/idxd/idxd.c:881:5: error: ‘dst_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  881 |  if (dst_nbytes < nbytes) {
      |     ^
/home/clear/spdk/lib/idxd/idxd.c: In function ‘spdk_idxd_submit_crc32c’:
/home/clear/spdk/lib/idxd/idxd.c:919:5: error: ‘src_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  919 |  if (src_nbytes < nbytes || dst_nbytes < nbytes) {
      |     ^
/home/clear/spdk/lib/idxd/idxd.c:919:26: error: ‘dst_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  919 |  if (src_nbytes < nbytes || dst_nbytes < nbytes) {
      |      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
  CC test/unit/lib/util/cpuset.c/cpuset_ut.o
/home/clear/spdk/lib/idxd/idxd.c: In function ‘spdk_idxd_batch_prep_copy’:
/home/clear/spdk/lib/idxd/idxd.c:1108:5: error: ‘src_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1108 |  if (src_nbytes < nbytes || dst_nbytes < nbytes) {
      |     ^
/home/clear/spdk/lib/idxd/idxd.c:1108:26: error: ‘dst_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1108 |  if (src_nbytes < nbytes || dst_nbytes < nbytes) {
      |      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/home/clear/spdk/lib/idxd/idxd.c: In function ‘spdk_idxd_batch_prep_fill’:
/home/clear/spdk/lib/idxd/idxd.c:1142:5: error: ‘dst_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1142 |  if (dst_nbytes < nbytes) {
      |     ^
/home/clear/spdk/lib/idxd/idxd.c: In function ‘spdk_idxd_batch_prep_crc32c’:
/home/clear/spdk/lib/idxd/idxd.c:1218:5: error: ‘src_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1218 |  if (src_nbytes < nbytes || dst_nbytes < nbytes) {
      |     ^
/home/clear/spdk/lib/idxd/idxd.c:1218:26: error: ‘dst_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1218 |  if (src_nbytes < nbytes || dst_nbytes < nbytes) {
      |      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
  LINK iscsi_fuzz
/home/clear/spdk/lib/idxd/idxd.c: In function ‘spdk_idxd_batch_prep_compare’:
/home/clear/spdk/lib/idxd/idxd.c:1255:5: error: ‘src1_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1255 |  if (src1_nbytes < nbytes || src2_nbytes < nbytes) {
      |     ^
/home/clear/spdk/lib/idxd/idxd.c:1255:27: error: ‘src2_nbytes’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1255 |  if (src1_nbytes < nbytes || src2_nbytes < nbytes) {
      |      ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: yidong0635 <dongx.yi@intel.com>
Change-Id: I7f1b01c04e4f7287616c590b652aa5cee26d2901
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4694
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
yidong0635 2020-10-15 08:52:49 -04:00 committed by Tomasz Zawadzki
parent 9714818d04
commit ec51918c07

View File

@ -743,7 +743,7 @@ spdk_idxd_submit_copy(struct spdk_idxd_io_channel *chan, void *dst, const void *
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t src_addr, dst_addr; uint64_t src_addr, dst_addr;
uint64_t src_nbytes, dst_nbytes; uint64_t src_nbytes = 0, dst_nbytes = 0;
/* Common prep. */ /* Common prep. */
desc = _idxd_prep_command(chan, cb_fn, cb_arg, NULL); desc = _idxd_prep_command(chan, cb_fn, cb_arg, NULL);
@ -781,7 +781,7 @@ spdk_idxd_submit_dualcast(struct spdk_idxd_io_channel *chan, void *dst1, void *d
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t src_addr, dst1_addr, dst2_addr; uint64_t src_addr, dst1_addr, dst2_addr;
uint64_t src_nbytes, dst1_nbytes, dst2_nbytes; uint64_t src_nbytes = 0, dst1_nbytes = 0, dst2_nbytes = 0;
if ((uintptr_t)dst1 & (ALIGN_4K - 1) || (uintptr_t)dst2 & (ALIGN_4K - 1)) { if ((uintptr_t)dst1 & (ALIGN_4K - 1) || (uintptr_t)dst2 & (ALIGN_4K - 1)) {
SPDK_ERRLOG("Dualcast requires 4K alignment on dst addresses\n"); SPDK_ERRLOG("Dualcast requires 4K alignment on dst addresses\n");
@ -827,7 +827,7 @@ spdk_idxd_submit_compare(struct spdk_idxd_io_channel *chan, void *src1, const vo
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t src1_addr, src2_addr; uint64_t src1_addr, src2_addr;
uint64_t src1_nbytes, src2_nbytes; uint64_t src1_nbytes = 0, src2_nbytes = 0;
/* Common prep. */ /* Common prep. */
desc = _idxd_prep_command(chan, cb_fn, cb_arg, NULL); desc = _idxd_prep_command(chan, cb_fn, cb_arg, NULL);
@ -864,7 +864,7 @@ spdk_idxd_submit_fill(struct spdk_idxd_io_channel *chan, void *dst, uint64_t fil
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t dst_addr; uint64_t dst_addr;
uint64_t dst_nbytes; uint64_t dst_nbytes = 0;
/* Common prep. */ /* Common prep. */
desc = _idxd_prep_command(chan, cb_fn, cb_arg, NULL); desc = _idxd_prep_command(chan, cb_fn, cb_arg, NULL);
@ -901,7 +901,7 @@ spdk_idxd_submit_crc32c(struct spdk_idxd_io_channel *chan, uint32_t *dst, void *
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t src_addr, dst_addr; uint64_t src_addr, dst_addr;
uint64_t src_nbytes, dst_nbytes; uint64_t src_nbytes = 0, dst_nbytes = 0;
/* Common prep. */ /* Common prep. */
desc = _idxd_prep_command(chan, cb_fn, cb_arg, NULL); desc = _idxd_prep_command(chan, cb_fn, cb_arg, NULL);
@ -1090,7 +1090,7 @@ spdk_idxd_batch_prep_copy(struct spdk_idxd_io_channel *chan, struct idxd_batch *
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t src_addr, dst_addr; uint64_t src_addr, dst_addr;
uint64_t src_nbytes, dst_nbytes; uint64_t src_nbytes = 0, dst_nbytes = 0;
/* Common prep. */ /* Common prep. */
desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch); desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch);
@ -1125,7 +1125,7 @@ spdk_idxd_batch_prep_fill(struct spdk_idxd_io_channel *chan, struct idxd_batch *
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t dst_addr; uint64_t dst_addr;
uint64_t dst_nbytes; uint64_t dst_nbytes = 0;
/* Common prep. */ /* Common prep. */
desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch); desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch);
@ -1158,7 +1158,7 @@ spdk_idxd_batch_prep_dualcast(struct spdk_idxd_io_channel *chan, struct idxd_bat
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t src_addr, dst1_addr, dst2_addr; uint64_t src_addr, dst1_addr, dst2_addr;
uint64_t src_nbytes, dst1_nbytes, dst2_nbytes; uint64_t src_nbytes = 0, dst1_nbytes = 0, dst2_nbytes = 0;
if ((uintptr_t)dst1 & (ALIGN_4K - 1) || (uintptr_t)dst2 & (ALIGN_4K - 1)) { if ((uintptr_t)dst1 & (ALIGN_4K - 1) || (uintptr_t)dst2 & (ALIGN_4K - 1)) {
SPDK_ERRLOG("Dualcast requires 4K alignment on dst addresses\n"); SPDK_ERRLOG("Dualcast requires 4K alignment on dst addresses\n");
@ -1200,7 +1200,7 @@ spdk_idxd_batch_prep_crc32c(struct spdk_idxd_io_channel *chan, struct idxd_batch
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t src_addr, dst_addr; uint64_t src_addr, dst_addr;
uint64_t src_nbytes, dst_nbytes; uint64_t src_nbytes = 0, dst_nbytes = 0;
/* Common prep. */ /* Common prep. */
desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch); desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch);
@ -1237,7 +1237,7 @@ spdk_idxd_batch_prep_compare(struct spdk_idxd_io_channel *chan, struct idxd_batc
{ {
struct idxd_hw_desc *desc; struct idxd_hw_desc *desc;
uint64_t src1_addr, src2_addr; uint64_t src1_addr, src2_addr;
uint64_t src1_nbytes, src2_nbytes; uint64_t src1_nbytes = 0, src2_nbytes = 0;
/* Common prep. */ /* Common prep. */
desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch); desc = _idxd_prep_batch_cmd(chan, cb_fn, cb_arg, batch);