Fix KW issues for tpm_emulator

There are several KW issues which uninitialized variables
are used. This patch will fix those KW issues.

Signed-off-by: weideng <wei.a.deng@intel.com>
Signed-off-by: yingbinx <yingbinx.zeng@intel.com>
This commit is contained in:
yingbinx 2018-12-12 15:30:23 +08:00 committed by wenlingz
parent 2d469a5e5f
commit 6b998580d6

View File

@ -531,7 +531,7 @@ static int swtpm_ctrlchan_create(const char *arg_path)
*/ */
static int swtpm_cmdchan_create(void) static int swtpm_cmdchan_create(void)
{ {
ptm_res res; ptm_res res = 0;
int sv[2] = {-1, -1}; int sv[2] = {-1, -1};
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0) if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0)
@ -584,7 +584,7 @@ err_exit:
static int swtpm_stop(void) static int swtpm_stop(void)
{ {
ptm_res res; ptm_res res = 0;
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_STOP, &res, 0, sizeof(res), NULL, 0) < 0) { if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_STOP, &res, 0, sizeof(res), NULL, 0) < 0) {
printf("swtpm: Could not stop TPM: %s", strerror(errno)); printf("swtpm: Could not stop TPM: %s", strerror(errno));
@ -663,7 +663,7 @@ static int swtpm_startup_tpm(size_t buffersize,
static void swtpm_shutdown(void) static void swtpm_shutdown(void)
{ {
ptm_res res; ptm_res res = 0;
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SHUTDOWN, if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_SHUTDOWN,
&res, 0, sizeof(res), NULL, 0) < 0) { &res, 0, sizeof(res), NULL, 0) < 0) {
@ -789,7 +789,7 @@ int swtpm_reset_tpm_established_flag(void)
void swtpm_cancel_cmd(void) void swtpm_cancel_cmd(void)
{ {
ptm_res res; ptm_res res = 0;
if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_CANCEL_TPM_CMD, &res, 0, if (swtpm_ctrlcmd(tpm_context.ctrl_chan_fd, CMD_CANCEL_TPM_CMD, &res, 0,
sizeof(res), NULL, 0) < 0) { sizeof(res), NULL, 0) < 0) {