Skip to content

Commit 395c056

Browse files
update socket error return code
1 parent 88007b2 commit 395c056

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/tpm2_swtpm.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static int SwTpmReceive(TPM2_CTX* ctx, void* buffer, size_t rxSz)
181181
/* use select to wait for data */
182182
rc = select(ctx->tcpCtx.fd + 1, &rfds, NULL, NULL, &tv);
183183
if (rc == 0) {
184-
rc = SOCKET_ERROR_E; /* timeout */
184+
rc = TPM_RC_FAILURE; /* timeout */
185185
break;
186186
}
187187
rc = (int)WOLFTPM_READ(ctx->tcpCtx.fd, ptr, remain);
@@ -206,7 +206,7 @@ static int SwTpmReceive(TPM2_CTX* ctx, void* buffer, size_t rxSz)
206206
" = %s\n", ctx->tcpCtx.fd, errno, strerror(errno));
207207
}
208208
#endif
209-
rc = SOCKET_ERROR_E;
209+
rc = TPM_RC_FAILURE;
210210
break;
211211
}
212212

@@ -247,7 +247,7 @@ static int SwTpmConnect(TPM2_CTX* ctx, const char* uartDev, uint32_t baud)
247247
DEBUG_PRINTF("Error opening %s: Error %i (%s)\n",
248248
uartDev, errno, strerror(errno));
249249
#endif
250-
return SOCKET_ERROR_E;
250+
return TPM_RC_FAILURE;
251251
}
252252
tcgetattr(fd, &tty);
253253
cfsetospeed(&tty, baud);
@@ -332,7 +332,7 @@ static int SwTpmReceive(TPM2_CTX* ctx, void* buffer, size_t rxSz)
332332

333333
if ((timeOut--) <= 0) {
334334
rxBuffIdx = 0; /* reset read state */
335-
rc = SOCKET_ERROR_E; /* timeout */
335+
rc = TPM_RC_FAILURE; /* timeout */
336336
#if DEBUG_WOLFTPM
337337
DEBUG_PRINTF("Connection timed out\r\n");
338338
#endif
@@ -345,7 +345,7 @@ static int SwTpmReceive(TPM2_CTX* ctx, void* buffer, size_t rxSz)
345345
#ifdef DEBUG_WOLFTPM
346346
DEBUG_PRINTF("Failed to read from TPM UART\n\r");
347347
#endif
348-
rc = SOCKET_ERROR_E;
348+
rc = TPM_RC_FAILURE;
349349
break;
350350
}
351351
rxBuffIdx += rc;
@@ -566,7 +566,7 @@ int TPM2_SWTPM_SendCommand(TPM2_CTX* ctx, TPM2_Packet* packet)
566566
DEBUG_PRINTF("Response size(%d) larger than command buffer(%d)\n",
567567
rspSz, packet->pos);
568568
#endif
569-
rc = SOCKET_ERROR_E;
569+
rc = TPM_RC_FAILURE;
570570
}
571571
}
572572

@@ -593,6 +593,7 @@ int TPM2_SWTPM_SendCommand(TPM2_CTX* ctx, TPM2_Packet* packet)
593593
int sz = (rspSz < packet->size) ? rspSz : packet->size;
594594
DEBUG_PRINTF("Response size: %d\n", rspSz);
595595
TPM2_PrintBin(packet->buf, sz);
596+
(void)sz;
596597
}
597598
#endif
598599

0 commit comments

Comments
 (0)