trace: fix compiler complain on two variables

In the nightly test, the compiler complains:

trace.c: In function ‘_spdk_trace_record’:
00:07:12.523  trace.c:144:53: error: ‘argval’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
00:07:12.523       memcpy(&buffer->data[offset], (uint8_t *)argval + argoff,
00:07:12.523                                                       ^
00:07:12.523  trace.c:145:36: error: ‘arglen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
00:07:12.523              spdk_min(curlen, arglen - argoff));

And this patch is provided to fix such issue.

Fixes #issue 2034

Change-Id: I4c78d63bdc6a7d166990ae1d18a6abf183efdee1
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8709
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Chengqiang Meng <chengqiangx.meng@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Ziye Yang 2021-07-08 21:22:49 +08:00 committed by Ben Walker
parent 4ee3f1bccf
commit cd1261ae00

View File

@ -116,7 +116,7 @@ _spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id, uint32_
break;
default:
assert(0 && "Invalid trace argument type");
break;
return;
}
/* Copy argument's data. For some argument types (strings) user is allowed to pass a
@ -141,6 +141,7 @@ _spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id, uint32_
curlen = spdk_min(sizeof(buffer->data) - offset, argument->size - argoff);
if (argoff < arglen) {
assert(argval != NULL);
memcpy(&buffer->data[offset], (uint8_t *)argval + argoff,
spdk_min(curlen, arglen - argoff));
}