diff --git a/.clang-tidy b/.clang-tidy
index 0d8e9250b..303130493 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -7,8 +7,6 @@
 #   want to turn into opaque or strong types. They are part of the API.
 # -bugprone-implicit-widening-of-multiplication-result
 #   [TODO]
-# -bugprone-narrowing-conversions
-#   [TODO]
 #
 # -clang-analyzer-optin.performance.Padding
 #   We prefer logical/semantic order over (potentially insignificant)
@@ -25,7 +23,6 @@ Checks: "\
   -bugprone-branch-clone, \
   -bugprone-easily-swappable-parameters, \
   -bugprone-implicit-widening-of-multiplication-result, \
-  -bugprone-narrowing-conversions, \
   \
   clang-analyzer, \
   -clang-analyzer-optin.performance.Padding, \
diff --git a/src/tss2-esys/esys_crypto.c b/src/tss2-esys/esys_crypto.c
index 99e75cc31..cfda38a3f 100644
--- a/src/tss2-esys/esys_crypto.c
+++ b/src/tss2-esys/esys_crypto.c
@@ -615,25 +615,28 @@ iesys_crypto_KDFa(ESYS_CRYPTO_CALLBACKS *crypto_cb,
                   "IESYS KDFa contextV key");
     BYTE *subKey = outKey;
     UINT32 counter = 0;
-    INT32 bytes = 0;
+    size_t bytes = 0;
     size_t hlen = 0;
     TSS2_RC r = iesys_crypto_hash_get_digest_size(hashAlg, &hlen);
     return_if_error(r, "Error");
     if (counterInOut != NULL)
         counter = *counterInOut;
     bytes = use_digest_size ? hlen : (bitLength + 7) / 8;
-    LOG_DEBUG("IESYS KDFa hmac key bytes: %i", bytes);
+    LOG_DEBUG("IESYS KDFa hmac key bytes: %zu", bytes);
 
      /* Fill outKey with results from KDFaHmac */
-    for (; bytes > 0; subKey = &subKey[hlen], bytes = bytes - hlen) {
-        LOG_TRACE("IESYS KDFa hmac key bytes: %i", bytes);
-        //if(bytes < (INT32)hlen)
-        //    hlen = bytes;
+    for (;; subKey = &subKey[hlen], bytes = bytes - hlen) {
+        LOG_TRACE("IESYS KDFa hmac key bytes: %zu", bytes);
         counter++;
         r = iesys_crypto_KDFaHmac(crypto_cb, hashAlg, hmacKey,
                                   hmacKeySize, counter, label, contextU,
                                   contextV, bitLength, &subKey[0], &hlen);
         return_if_error(r, "Error");
+
+        if (bytes <= hlen) {
+            /* no bytes remaining */
+            break;
+        }
     }
     if ((bitLength % 8) != 0)
         outKey[0] &= ((((BYTE)1) << (bitLength % 8)) - 1);
@@ -669,7 +672,7 @@ iesys_crypto_KDFe(ESYS_CRYPTO_CALLBACKS *crypto_cb,
 {
     TSS2_RC r = TSS2_RC_SUCCESS;
     size_t hash_len;
-    INT16 byte_size = (INT16)((bit_size +7) / 8);
+    size_t byte_size = ((bit_size +7) / 8);
     BYTE *stream = key;
     ESYS_CRYPTO_CONTEXT_BLOB *cryptoContext;
     BYTE counter_buffer[4];
@@ -691,7 +694,7 @@ iesys_crypto_KDFe(ESYS_CRYPTO_CALLBACKS *crypto_cb,
     }
 
     /* Fill seed key with hash of counter, Z, label, partyUInfo, and partyVInfo */
-    for (; byte_size > 0; stream = &stream[hash_len], byte_size = byte_size - hash_len)
+    for (;; stream = &stream[hash_len], byte_size = byte_size - hash_len)
         {
             counter ++;
             r = iesys_crypto_hash_start(crypto_cb,
@@ -730,6 +733,11 @@ iesys_crypto_KDFe(ESYS_CRYPTO_CALLBACKS *crypto_cb,
             r = iesys_crypto_hash_finish(crypto_cb,
                 &cryptoContext, (uint8_t *) stream, &hash_len);
             goto_if_error(r, "Error", error);
+
+            if (byte_size <= hash_len) {
+                /* no bytes remaining */
+                break;
+            }
         }
     LOGBLOB_DEBUG(key, bit_size/8, "Result KDFe");
     if((bit_size % 8) != 0)
diff --git a/src/tss2-esys/esys_crypto_ossl.c b/src/tss2-esys/esys_crypto_ossl.c
index 939d0aae9..15e534cec 100644
--- a/src/tss2-esys/esys_crypto_ossl.c
+++ b/src/tss2-esys/esys_crypto_ossl.c
@@ -752,7 +752,7 @@ iesys_cryptossl_pk_encrypt(TPM2B_PUBLIC * pub_tpm_key,
                    "Could not duplicate OAEP label", cleanup);
     }
 
-    if (1 != EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, label_copy, strlen(label_copy)+1)) {
+    if (1 != EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, label_copy, (int) strlen(label_copy)+1)) {
         OPENSSL_free(label_copy);
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE,
                    "Could not set RSA label.", cleanup);
@@ -989,12 +989,12 @@ iesys_cryptossl_get_ecdh_point(TPM2B_PUBLIC *key,
     }
 #endif
 
-    if (1 != iesys_bn2binpad(bn_x, &Q->x.buffer[0], key_size)) {
+    if (1 != iesys_bn2binpad(bn_x, &Q->x.buffer[0], (int) key_size)) {
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE,
                    "Write big num byte buffer", cleanup);
     }
 
-    if (1 != iesys_bn2binpad(bn_y, &Q->y.buffer[0], key_size)) {
+    if (1 != iesys_bn2binpad(bn_y, &Q->y.buffer[0], (int) key_size)) {
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE,
                    "Write big num byte buffer", cleanup);
     }
@@ -1024,7 +1024,7 @@ iesys_cryptossl_get_ecdh_point(TPM2B_PUBLIC *key,
                    "Get affine x coordinate", cleanup);
     }
 
-    if (1 != iesys_bn2binpad(bn_x, &Z->buffer[0], key_size)) {
+    if (1 != iesys_bn2binpad(bn_x, &Z->buffer[0], (int) key_size)) {
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE,
                    "Write big num byte buffer", cleanup);
     }
@@ -1120,7 +1120,7 @@ iesys_cryptossl_sym_aes_encrypt(uint8_t * key,
     }
 
     /* Perform the encryption */
-    if (1 != EVP_EncryptUpdate(ctx, buffer, &cipher_len, buffer, buffer_size)) {
+    if (1 != EVP_EncryptUpdate(ctx, buffer, &cipher_len, buffer, (int) buffer_size)) {
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Encrypt update", cleanup);
     }
 
@@ -1203,7 +1203,7 @@ iesys_cryptossl_sym_aes_decrypt(uint8_t * key,
     }
 
     /* Perform the decryption */
-    if (1 != EVP_DecryptUpdate(ctx, buffer, &cipher_len, buffer, buffer_size)) {
+    if (1 != EVP_DecryptUpdate(ctx, buffer, &cipher_len, buffer, (int) buffer_size)) {
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Encrypt update", cleanup);
     }
 
@@ -1282,7 +1282,7 @@ iesys_cryptossl_sym_sm4_encrypt(uint8_t * key,
     }
 
     /* Perform the encryption */
-    if (1 != EVP_EncryptUpdate(ctx, buffer, &cipher_len, buffer, buffer_size)) {
+    if (1 != EVP_EncryptUpdate(ctx, buffer, &cipher_len, buffer, (int) buffer_size)) {
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Encrypt update", cleanup);
     }
 
@@ -1361,7 +1361,7 @@ iesys_cryptossl_sym_sm4_decrypt(uint8_t * key,
     }
 
     /* Perform the decryption */
-    if (1 != EVP_DecryptUpdate(ctx, buffer, &cipher_len, buffer, buffer_size)) {
+    if (1 != EVP_DecryptUpdate(ctx, buffer, &cipher_len, buffer, (int) buffer_size)) {
         goto_error(r, TSS2_ESYS_RC_GENERAL_FAILURE, "Encrypt update", cleanup);
     }
 
diff --git a/src/tss2-fapi/fapi_crypto.c b/src/tss2-fapi/fapi_crypto.c
index 8f932277d..ec42f8169 100644
--- a/src/tss2-fapi/fapi_crypto.c
+++ b/src/tss2-fapi/fapi_crypto.c
@@ -752,7 +752,7 @@ ifapi_ecc_der_sig_to_tpm(
     const BIGNUM *bnr;
     const BIGNUM *bns;
 
-    d2i_ECDSA_SIG(&ecdsaSignature, &signature, signatureSize);
+    d2i_ECDSA_SIG(&ecdsaSignature, &signature, (long) signatureSize);
     return_if_null(ecdsaSignature, "Invalid DER signature",
                    TSS2_FAPI_RC_GENERAL_FAILURE);
 
@@ -1188,12 +1188,12 @@ get_ecc_tpm2b_public_from_evp(
     tpmPublic->publicArea.unique.ecc.x.size = ecKeySize;
     tpmPublic->publicArea.unique.ecc.y.size = ecKeySize;
     if (1 != ifapi_bn2binpad(bnX, &tpmPublic->publicArea.unique.ecc.x.buffer[0],
-                             ecKeySize)) {
+                             (int) ecKeySize)) {
         goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE,
                    "Write big num byte buffer", cleanup);
     }
     if (1 != ifapi_bn2binpad(bnY, &tpmPublic->publicArea.unique.ecc.y.buffer[0],
-                             ecKeySize)) {
+                             (int) ecKeySize)) {
         goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE,
                    "Write big num byte buffer", cleanup);
     }
@@ -1253,7 +1253,7 @@ ifapi_get_evp_from_pem(const char *pemKey, EVP_PKEY **publicKey) {
     BIO *bufio = NULL;
 
     /* Use BIO for conversion */
-    bufio = BIO_new_mem_buf((void *)pemKey, strlen(pemKey));
+    bufio = BIO_new_mem_buf((void *)pemKey, (int) strlen(pemKey));
     goto_if_null(bufio, "BIO buffer could not be allocated.",
                  TSS2_FAPI_RC_MEMORY, cleanup);
 
@@ -1418,7 +1418,7 @@ ifapi_verify_signature_quote(
 
     /* Create an OpenSSL object for the key */
     bufio = BIO_new_mem_buf((void *)public_pem_key,
-                            strlen(public_pem_key));
+                            (int) strlen(public_pem_key));
     goto_if_null(bufio, "BIO buffer could not be allocated.",
                  TSS2_FAPI_RC_MEMORY, error_cleanup);
 
@@ -1549,7 +1549,7 @@ ifapi_verify_signature(
 
     /* Convert the key to an OpenSSL object */
     bufio = BIO_new_mem_buf((void *)public_pem_key,
-                                strlen(public_pem_key));
+                                (int) strlen(public_pem_key));
     goto_if_null(bufio, "Out of memory.", TSS2_FAPI_RC_MEMORY, error_cleanup);
     publicKey = PEM_read_bio_PUBKEY(bufio, NULL, NULL, NULL);
     goto_if_null(publicKey, "PEM format could not be decoded.",
@@ -1823,7 +1823,7 @@ ifapi_cert_to_pem(
     EVP_PKEY *publicKey = NULL;
     int pemCertSize;
 
-    if (!d2i_X509(&cert, (const unsigned char **)&certBuffer, certBufferSize)) {
+    if (!d2i_X509(&cert, (const unsigned char **)&certBuffer, (long) certBufferSize)) {
         LOGBLOB_ERROR(certBuffer, certBufferSize, "Bad certificate data");
         return_error(TSS2_FAPI_RC_GENERAL_FAILURE, "Invalid certificate.");
     }
@@ -1939,7 +1939,7 @@ static X509
 
     /* Use BIO for conversion */
     size_t pem_length = strlen(pem_cert);
-    bufio = BIO_new_mem_buf((void *)pem_cert, pem_length);
+    bufio = BIO_new_mem_buf((void *)pem_cert, (int) pem_length);
     if (!bufio)
         return NULL;
     /* Convert the certificate */
@@ -2096,7 +2096,7 @@ ifapi_base64encode(uint8_t *buffer, size_t buffer_size, char** b64_data) {
     bio = BIO_push(bio64, bio);
 
     BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
-    bytes_written = BIO_write(bio, buffer, buffer_size);
+    bytes_written = BIO_write(bio, buffer, (int) buffer_size);
     if (bytes_written != (int)buffer_size) {
         goto_error(r, TSS2_FAPI_RC_GENERAL_FAILURE, "Invalid BIO_write",
                    cleanup);
@@ -2149,7 +2149,7 @@ ifapi_rsa_encrypt(const char *pem_key,
     const EVP_MD *evp_md;
 
     /* Convert the pem key to an OpenSSL object */
-    bufio = BIO_new_mem_buf((void *)pem_key, strlen(pem_key));
+    bufio = BIO_new_mem_buf((void *)pem_key, (int) strlen(pem_key));
     goto_if_null(bufio, "Out of memory.", TSS2_FAPI_RC_MEMORY, cleanup);
 
     publicKey = PEM_read_bio_PUBKEY(bufio, NULL, NULL, NULL);
@@ -2332,7 +2332,7 @@ load_private_ECC_from_key(EVP_PKEY *key,
         goto out;
     }
 
-    p->size = BN_bn2binpad(b, p->buffer, priv_bytes);
+    p->size = BN_bn2binpad(b, p->buffer, (int) priv_bytes);
     if (p->size != priv_bytes) {
         goto out;
     }
diff --git a/src/tss2-fapi/ifapi_curl.c b/src/tss2-fapi/ifapi_curl.c
index 6280a79f3..18f4a9ff9 100644
--- a/src/tss2-fapi/ifapi_curl.c
+++ b/src/tss2-fapi/ifapi_curl.c
@@ -37,7 +37,7 @@ static X509
     unsigned const char* tmp_ptr1 = buffer;
     unsigned const char** tmp_ptr2 = &tmp_ptr1;
 
-    if (!d2i_X509(&cert, tmp_ptr2, cert_buffer_size))
+    if (!d2i_X509(&cert, tmp_ptr2, (long) cert_buffer_size))
         return NULL;
     return cert;
 }
@@ -59,7 +59,7 @@ static X509
 
     /* Use BIO for conversion */
     size_t pem_length = strlen(pem_cert);
-    bufio = BIO_new_mem_buf((void *)pem_cert, pem_length);
+    bufio = BIO_new_mem_buf((void *)pem_cert, (int) pem_length);
     if (!bufio)
         return NULL;
     /* Convert the certificate */
@@ -119,7 +119,7 @@ get_crl_from_cert(X509 *cert, X509_CRL **crl)
     unsigned const char** tmp_ptr2 = &tmp_ptr1;
 
     if (crl_buffer_size > 0) {
-        if (!d2i_X509_CRL(crl, tmp_ptr2, crl_buffer_size)) {
+        if (!d2i_X509_CRL(crl, tmp_ptr2, (long) crl_buffer_size)) {
             goto_error(r, TSS2_FAPI_RC_BAD_VALUE, "Can't convert crl.", cleanup);
         }
     }
diff --git a/src/tss2-fapi/ifapi_eventlog_system.c b/src/tss2-fapi/ifapi_eventlog_system.c
index 35bb99616..f27a72005 100644
--- a/src/tss2-fapi/ifapi_eventlog_system.c
+++ b/src/tss2-fapi/ifapi_eventlog_system.c
@@ -65,7 +65,7 @@ get_number(const char *token, int64_t *num)
  * @retval the position of the sub string after the prefix.
  * @retval 0 if no prefix is found.
  */
-static int
+static unsigned int
 get_token_start_idx(const char *token)
 {
     uint itoken = 0;
@@ -552,7 +552,7 @@ ifapi_json_TCG_EVENT_TYPE_deserialize_txt(json_object *jso,
         return TSS2_RC_SUCCESS;
 
     } else {
-        int itoken = get_token_start_idx(token);
+        unsigned int itoken = get_token_start_idx(token);
         size_t i;
         size_t n = sizeof(deserialize_TCG_EVENT_TYPE_tab) /
                    sizeof(deserialize_TCG_EVENT_TYPE_tab[0]);
diff --git a/src/tss2-fapi/ifapi_get_web_cert.c b/src/tss2-fapi/ifapi_get_web_cert.c
index 890e6e921..b2000217f 100644
--- a/src/tss2-fapi/ifapi_get_web_cert.c
+++ b/src/tss2-fapi/ifapi_get_web_cert.c
@@ -261,7 +261,7 @@ base64_encode(const unsigned char* buffer)
 
     CURL *curl = curl_easy_init();
     if (curl) {
-        char *output = curl_easy_escape(curl, b64text, len);
+        char *output = curl_easy_escape(curl, b64text, (int) len);
         if (output) {
             final_string = strdup(output);
             curl_free(output);
@@ -310,7 +310,7 @@ base64_decode(unsigned char* buffer, size_t len, size_t *new_len)
     if (curl) {
         /* Convert URL encoded string to a "plain string" */
         char *output = curl_easy_unescape(curl, (char *)buffer,
-                                          len, &unescape_len);
+                                          (int) len, &unescape_len);
         if (output) {
             unescaped_string = strdup(output);
             curl_free(output);
diff --git a/src/tss2-fapi/ifapi_ima_eventlog.c b/src/tss2-fapi/ifapi_ima_eventlog.c
index c340c706f..ea2cb1b06 100644
--- a/src/tss2-fapi/ifapi_ima_eventlog.c
+++ b/src/tss2-fapi/ifapi_ima_eventlog.c
@@ -589,7 +589,7 @@ static TSS2_RC
 read_event_buffer(IFAPI_IMA_TEMPLATE *template, FILE *fp)
 {
     bool old_ima_format;
-    int size, rsize;
+    size_t size, rsize;
 
     /* Check IMA  legacy format. */
     if (strcmp(template->ima_type, "ima") == 0) {
diff --git a/src/tss2-fapi/ifapi_json_deserialize.c b/src/tss2-fapi/ifapi_json_deserialize.c
index 3dcefc10d..540829771 100644
--- a/src/tss2-fapi/ifapi_json_deserialize.c
+++ b/src/tss2-fapi/ifapi_json_deserialize.c
@@ -59,10 +59,10 @@ static char *tss_const_prefixes[] = { "TPM2_ALG_", "TPM2_", "TPM_", "TPMA_", "PO
  * @retval the position of the sub string after the prefix.
  * @retval 0 if no prefix is found.
  */
-static int
+static unsigned int
 get_token_start_idx(const char *token)
 {
-    int itoken = 0;
+    unsigned int itoken = 0;
     char *entry;
     int i;
 
@@ -830,7 +830,7 @@ ifapi_json_IFAPI_EVENT_TYPE_deserialize_txt(json_object *jso,
         return TSS2_RC_SUCCESS;
 
     } else {
-        int itoken = get_token_start_idx(token);
+        int unsigned itoken = get_token_start_idx(token);
         size_t i;
         size_t n = sizeof(deserialize_IFAPI_EVENT_TYPE_tab) /
                    sizeof(deserialize_IFAPI_EVENT_TYPE_tab[0]);
diff --git a/src/tss2-fapi/ifapi_json_eventlog_serialize.c b/src/tss2-fapi/ifapi_json_eventlog_serialize.c
index 8230dd781..c176a5d54 100644
--- a/src/tss2-fapi/ifapi_json_eventlog_serialize.c
+++ b/src/tss2-fapi/ifapi_json_eventlog_serialize.c
@@ -297,7 +297,7 @@ TSS2_RC trace_unicodename(
     const char16_t *UnicodeName,
     UINT64 UnicodeNameLength)
 {
-    int ret = 0;
+    size_t ret = 0;
     char *mbstr = NULL, *tmp = NULL;
     mbstate_t st;
 
@@ -311,7 +311,7 @@ TSS2_RC trace_unicodename(
 
     for(size_t i = 0; i < UnicodeNameLength; ++i, tmp += ret) {
         ret = c16rtomb(tmp, UnicodeName[i], &st);
-        if (ret < 0) {
+        if (ret == (size_t) -1) {
             LOG_ERROR("c16rtomb failed: %s", strerror(errno));
             free(mbstr);
             return TSS2_FAPI_RC_BAD_VALUE;
@@ -528,7 +528,7 @@ TSS2_RC ifapi_json_TCG_EVENT_HEADER2_serialize(
     }
     jso2 = NULL;
 
-    jso2 = json_object_new_int64(recnum);
+    jso2 = json_object_new_int64((int64_t) recnum);
     return_if_null(jso2, "Out of memory.", TSS2_FAPI_RC_MEMORY);
     if (json_object_object_add(*jso, "recnum", jso2)) {
         return_error(TSS2_FAPI_RC_GENERAL_FAILURE, "Could not add json object.");
@@ -632,7 +632,7 @@ TSS2_RC ifapi_json_TCG_EVENT_serialize(const TCG_EVENT *in, size_t recnum, json_
     if (json_object_object_add(*jso, "pcr", jso2)) {
         return_error(TSS2_FAPI_RC_GENERAL_FAILURE, "Could not add json object.");
     }
-    jso2 = json_object_new_int64(recnum);
+    jso2 = json_object_new_int64((int64_t) recnum);
     return_if_null(jso2, "Out of memory.", TSS2_FAPI_RC_MEMORY);
 
     if (json_object_object_add(*jso, "recnum", jso2)) {
diff --git a/src/tss2-fapi/ifapi_json_serialize.c b/src/tss2-fapi/ifapi_json_serialize.c
index 36eb3d094..b8ec19545 100644
--- a/src/tss2-fapi/ifapi_json_serialize.c
+++ b/src/tss2-fapi/ifapi_json_serialize.c
@@ -596,7 +596,7 @@ TSS2_RC
 ifapi_json_IFAPI_OBJECT_TYPE_CONSTANT_serialize(const IFAPI_OBJECT_TYPE_CONSTANT
         in, json_object **jso)
 {
-    *jso = json_object_new_int(in);
+    *jso = json_object_new_int64((int64_t) in);
     if (*jso == NULL) {
         LOG_ERROR("Bad value %"PRIx32 "", in);
         return TSS2_FAPI_RC_BAD_VALUE;
diff --git a/src/tss2-fapi/ifapi_policy_json_deserialize.c b/src/tss2-fapi/ifapi_policy_json_deserialize.c
index 509961e11..d80361636 100644
--- a/src/tss2-fapi/ifapi_policy_json_deserialize.c
+++ b/src/tss2-fapi/ifapi_policy_json_deserialize.c
@@ -38,10 +38,10 @@ static char *tss_const_prefixes[] = { "TPM2_ALG_", "TPM2_", "TPM_", "TPMA_", "PO
  * @retval the position of the sub string after the prefix.
  * @retval 0 if no prefix is found.
  */
-static int
+static unsigned int
 get_token_start_idx(const char *token)
 {
-    int itoken = 0;
+    unsigned int itoken = 0;
     char *entry;
     int i;
 
@@ -146,7 +146,7 @@ ifapi_json_TPMI_POLICYTYPE_deserialize_txt(json_object *jso,
         return TSS2_RC_SUCCESS;
 
     } else {
-        int itoken = get_token_start_idx(token);
+        int unsigned itoken = get_token_start_idx(token);
         size_t i;
         size_t n = sizeof(deserialize_TPMI_POLICYTYPE_tab) /
                    sizeof(deserialize_TPMI_POLICYTYPE_tab[0]);
diff --git a/src/tss2-fapi/tpm_json_deserialize.c b/src/tss2-fapi/tpm_json_deserialize.c
index d9f695241..236dbc4c3 100644
--- a/src/tss2-fapi/tpm_json_deserialize.c
+++ b/src/tss2-fapi/tpm_json_deserialize.c
@@ -257,7 +257,7 @@ ifapi_get_sub_object(json_object *jso, char *name, json_object **sub_jso)
     } else {
         char name2[strlen(name) + 1];
         for (i = 0; name[i]; i++)
-            name2[i] = tolower(name[i]);
+            name2[i] = (char) tolower(name[i]);
         name2[strlen(name)] = '\0';
         return json_object_object_get_ex(jso, name2, sub_jso);
     }
@@ -331,7 +331,7 @@ ifapi_json_pcr_selection_deserialize(
     TSS2_RC r;
     size_t i;
     int64_t n;
-    int n_byte = 0;
+    int64_t n_byte = 0;
     json_type jso_type = json_object_get_type(jso);
 
     if (jso_type != json_type_array) {
@@ -543,11 +543,11 @@ ifapi_json_BYTE_array_deserialize(size_t max, json_object *jso, BYTE *out)
     LOG_TRACE("call");
     json_type jso_type = json_object_get_type(jso);
     if (jso_type == json_type_array) {
-        int size = json_object_array_length(jso);
-        if (size > (int)max) {
-            LOG_ERROR("Array of BYTE too large (%i > %zu)", size, max);
+        size_t size = json_object_array_length(jso);
+        if (size > max) {
+            LOG_ERROR("Array of BYTE too large (%zu > %zu)", size, max);
         }
-        for (int i = 0; i < size; i++) {
+        for (size_t i = 0; i < size; i++) {
             json_object *jso2 = json_object_array_get_idx(jso, i);
             TSS2_RC r = ifapi_json_BYTE_deserialize(jso2, &out[i]);
             return_if_error(r, "BAD VALUE");
diff --git a/src/tss2-fapi/tpm_json_serialize.c b/src/tss2-fapi/tpm_json_serialize.c
index cdb9895ff..5408bb788 100644
--- a/src/tss2-fapi/tpm_json_serialize.c
+++ b/src/tss2-fapi/tpm_json_serialize.c
@@ -85,7 +85,7 @@ ifapi_json_pcr_select_serialize(
     for (i1 = 0; i1 < TPM2_PCR_LAST - TPM2_PCR_FIRST; i1++) {
         i2 = i1 + TPM2_PCR_FIRST;
         if (pcrSelect[i2 / 8] & (((BYTE)1) << (i2 % 8))) {
-            jso2 = json_object_new_int(i2);
+            jso2 = json_object_new_int64(i2);
             return_if_null(jso2, "Out of memory.", TSS2_FAPI_RC_MEMORY);
             if (json_object_array_add(*jso, jso2)) {
                 return_error(TSS2_FAPI_RC_GENERAL_FAILURE, "Could not add json object.");
@@ -321,7 +321,7 @@ ifapi_json_UINT64_serialize(UINT64 in, json_object **jso)
 {
     json_object *jso1 = NULL, *jso2 = NULL;
     if (in < 0x1000000000000) {
-        *jso = json_object_new_int64(in);
+        *jso = json_object_new_int64((int64_t) in);
         if (*jso == NULL) {
             LOG_ERROR("Bad value %"PRIu32 "", (uint32_t)in);
             return TSS2_FAPI_RC_BAD_VALUE;
@@ -329,12 +329,12 @@ ifapi_json_UINT64_serialize(UINT64 in, json_object **jso)
         return TSS2_RC_SUCCESS;
     }
 
-    jso1 = json_object_new_int64(in / 0x100000000);
+    jso1 = json_object_new_int64((int64_t) (in / 0x100000000));
     return_if_null(jso1, "Out of memory.", TSS2_FAPI_RC_MEMORY);
 
     in %= 0x100000000;
 
-    jso2 = json_object_new_int64(in);
+    jso2 = json_object_new_int64((int64_t) in);
     if (!jso2) json_object_put(jso1);
     return_if_null(jso2, "Out of memory.", TSS2_FAPI_RC_MEMORY);
 
@@ -873,7 +873,7 @@ ifapi_json_TPM2_PT_PCR_serialize(const TPM2_PT_PCR in, json_object **jso)
 TSS2_RC
 ifapi_json_TPM2_HANDLE_serialize(const TPM2_HANDLE in, json_object **jso)
 {
-    *jso = json_object_new_int(in);
+    *jso = json_object_new_int((int32_t) in);
     if (*jso == NULL) {
         LOG_ERROR("Bad value %"PRIx32 "", in);
         return TSS2_FAPI_RC_BAD_VALUE;
diff --git a/src/tss2-tcti/mpsse/mpsse.c b/src/tss2-tcti/mpsse/mpsse.c
index ea56e3cfb..47fad8c3b 100644
--- a/src/tss2-tcti/mpsse/mpsse.c
+++ b/src/tss2-tcti/mpsse/mpsse.c
@@ -490,16 +490,14 @@ const char *ErrorString (struct mpsse_context *mpsse)
  *
  * Returns the existing clock rate in hertz.
  */
-int GetClock (struct mpsse_context *mpsse)
+uint32_t GetClock (struct mpsse_context *mpsse)
 {
-    int clock = 0;
-
-    if (is_valid_context (mpsse))
+    if (! is_valid_context (mpsse))
     {
-        clock = mpsse->clock;
+        return 0;
     }
 
-    return clock;
+    return mpsse->clock;
 }
 
 /*
@@ -920,7 +918,7 @@ char ReadBits (struct mpsse_context *mpsse, int size)
              * In MSB mode, bits are sifted in from the left. If less than 8 bits were
              * read, we need to shift them left accordingly.
              */
-            bits = bits << (8-size);
+            bits = (char) ((bits << (8-size)) & 0xff);
         }
         else if (mpsse->endianess == LSB)
         {
@@ -928,7 +926,7 @@ char ReadBits (struct mpsse_context *mpsse, int size)
              * In LSB mode, bits are shifted in from the right. If less than 8 bits were
              * read, we need to shift them right accordingly.
              */
-            bits = bits >> (8-size);
+            bits = (char) ((bits >> (8-size)) & 0xff);
         }
 
         free (rdata);
diff --git a/src/tss2-tcti/mpsse/mpsse.h b/src/tss2-tcti/mpsse/mpsse.h
index 6f09dfb61..d36321174 100644
--- a/src/tss2-tcti/mpsse/mpsse.h
+++ b/src/tss2-tcti/mpsse/mpsse.h
@@ -188,7 +188,7 @@ struct mpsse_context
     int flush_after_read;
     int vid;
     int pid;
-    int clock;
+    uint32_t clock;
     int xsize;
     int open;
     int endianess;
@@ -214,7 +214,7 @@ const char *ErrorString (struct mpsse_context *mpsse);
 int SetMode (struct mpsse_context *mpsse, int endianess);
 void EnableBitmode (struct mpsse_context *mpsse, int tf);
 int SetClock (struct mpsse_context *mpsse, uint32_t freq);
-int GetClock (struct mpsse_context *mpsse);
+uint32_t GetClock (struct mpsse_context *mpsse);
 int GetVid (struct mpsse_context *mpsse);
 int GetPid (struct mpsse_context *mpsse);
 const char *GetDescription (struct mpsse_context *mpsse);
diff --git a/src/tss2-tcti/mpsse/support.c b/src/tss2-tcti/mpsse/support.c
index 33b6c2c85..1d58803e0 100644
--- a/src/tss2-tcti/mpsse/support.c
+++ b/src/tss2-tcti/mpsse/support.c
@@ -226,27 +226,27 @@ unsigned char *build_block_buffer (struct mpsse_context *mpsse, uint8_t cmd, uns
 }
 
 /* Set the low bit pins high/low */
-int set_bits_low (struct mpsse_context *mpsse, int port)
+int set_bits_low (struct mpsse_context *mpsse, uint8_t port)
 {
-    char buf[CMD_SIZE] = { 0 };
+    uint8_t buf[CMD_SIZE] = { 0 };
 
     buf[0] = SET_BITS_LOW;
     buf[1] = port;
     buf[2] = mpsse->tris;
 
-    return raw_write (mpsse, (unsigned char *) &buf, sizeof (buf));
+    return raw_write (mpsse, buf, sizeof (buf));
 }
 
 /* Set the high bit pins high/low */
-int set_bits_high (struct mpsse_context *mpsse, int port)
+int set_bits_high (struct mpsse_context *mpsse, uint8_t port)
 {
-    char buf[CMD_SIZE] = { 0 };
+    uint8_t buf[CMD_SIZE] = { 0 };
 
     buf[0] = SET_BITS_HIGH;
     buf[1] = port;
     buf[2] = mpsse->trish;
 
-    return raw_write (mpsse, (unsigned char *)&buf, sizeof (buf));
+    return raw_write (mpsse, buf, sizeof (buf));
 }
 
 /* Set the GPIO pins high/low */
diff --git a/src/tss2-tcti/mpsse/support.h b/src/tss2-tcti/mpsse/support.h
index 37ce7b5f5..ec203fd77 100644
--- a/src/tss2-tcti/mpsse/support.h
+++ b/src/tss2-tcti/mpsse/support.h
@@ -41,8 +41,8 @@ void set_timeouts (struct mpsse_context *mpsse, int timeout);
 uint16_t freq2div (uint32_t system_clock, uint32_t freq);
 uint32_t div2freq (uint32_t system_clock, uint16_t div);
 unsigned char *build_block_buffer (struct mpsse_context *mpsse, uint8_t cmd, unsigned char *data, int size, int *buf_size);
-int set_bits_high (struct mpsse_context *mpsse, int port);
-int set_bits_low (struct mpsse_context *mpsse, int port);
+int set_bits_high (struct mpsse_context *mpsse, uint8_t port);
+int set_bits_low (struct mpsse_context *mpsse, uint8_t port);
 int gpio_write (struct mpsse_context *mpsse, int pin, int direction);
 int is_valid_context (struct mpsse_context *mpsse);
 
diff --git a/src/tss2-tcti/tcti-device.c b/src/tss2-tcti/tcti-device.c
index bfa6a9411..00045c16d 100644
--- a/src/tss2-tcti/tcti-device.c
+++ b/src/tss2-tcti/tcti-device.c
@@ -103,7 +103,7 @@ tcti_device_transmit (
     TSS2_TCTI_DEVICE_CONTEXT *tcti_dev = tcti_device_context_cast (tctiContext);
     TSS2_TCTI_COMMON_CONTEXT *tcti_common = tcti_device_down_cast (tcti_dev);
     TSS2_RC rc = TSS2_RC_SUCCESS;
-    ssize_t size;
+    size_t size;
 
     rc = tcti_common_transmit_checks (tcti_common,
                                       command_buffer,
@@ -118,9 +118,7 @@ tcti_device_transmit (
     size = write_all (tcti_dev->fd,
                       command_buffer,
                       command_size);
-    if (size < 0) {
-        return TSS2_TCTI_RC_IO_ERROR;
-    } else if ((size_t)size != command_size) {
+    if (size != command_size) {
         LOG_ERROR ("wrong number of bytes written. Expected %zu, wrote %zd.",
                    command_size,
                    size);
@@ -467,8 +465,8 @@ Tss2_Tcti_Device_Init (
     struct pollfd fds;
     int rc_poll, nfds = 1;
 
-    ssize_t sz = write_all (tcti_dev->fd, cmd, sizeof(cmd));
-    if (sz < 0 || sz != sizeof(cmd)) {
+    ssize_t sz = (ssize_t) write_all (tcti_dev->fd, cmd, sizeof(cmd));
+    if (sz != sizeof(cmd)) {
         LOG_ERROR ("Could not probe device for partial response read support");
         close_tpm (&tcti_dev->fd);
         return TSS2_TCTI_RC_IO_ERROR;
diff --git a/src/tss2-tcti/tcti-i2c-ftdi.c b/src/tss2-tcti/tcti-i2c-ftdi.c
index dbeae1d30..d07b69de3 100644
--- a/src/tss2-tcti/tcti-i2c-ftdi.c
+++ b/src/tss2-tcti/tcti-i2c-ftdi.c
@@ -124,7 +124,7 @@ platform_i2c_write (void *user_data, uint8_t reg_addr, const void *data, size_t
         goto error;
     }
 
-    if (Write (mpsse, (char *)data, cnt) != MPSSE_OK)
+    if (Write (mpsse, (char *)data, (int) cnt) != MPSSE_OK)
     {
         goto error;
     }
@@ -186,7 +186,7 @@ platform_i2c_read (void *user_data, uint8_t reg_addr, void *data, size_t cnt)
 
     /* Read in (cnt - 1) bytes with ACK */
     SendAcks (mpsse);
-    if ((data_in = Read (mpsse, cnt - 1)) == NULL)
+    if ((data_in = Read (mpsse, (int) cnt - 1)) == NULL)
     {
         goto error;
     }
diff --git a/src/tss2-tcti/tcti-i2c-helper.c b/src/tss2-tcti/tcti-i2c-helper.c
index b7720d64e..8458dffeb 100644
--- a/src/tss2-tcti/tcti-i2c-helper.c
+++ b/src/tss2-tcti/tcti-i2c-helper.c
@@ -86,8 +86,8 @@ static const uint16_t crc16_kermit_lookup[256]= {
     0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
 };
 
-static uint16_t crc_ccitt (const uint8_t *buffer, int size) {
-    int i;
+static uint16_t crc_ccitt (const uint8_t *buffer, size_t size) {
+    size_t i;
     uint16_t result = 0;
 
     for (i = 0; i < size; i++) {
@@ -475,8 +475,6 @@ static TSS2_RC i2c_tpm_helper_wait_for_status (TSS2_TCTI_I2C_HELPER_CONTEXT* ctx
 
 static TSS2_RC i2c_tpm_helper_verify_crc (TSS2_TCTI_I2C_HELPER_CONTEXT* ctx, const uint8_t* buffer, size_t size)
 {
-    (void) buffer;
-    (void) size;
     TSS2_RC rc;
     uint16_t crc_tpm = 0;
     uint16_t crc_host = 0;
diff --git a/src/tss2-tcti/tcti-i2c-helper.h b/src/tss2-tcti/tcti-i2c-helper.h
index 2e545b73b..2028dc660 100644
--- a/src/tss2-tcti/tcti-i2c-helper.h
+++ b/src/tss2-tcti/tcti-i2c-helper.h
@@ -36,7 +36,7 @@ typedef struct {
     TSS2_TCTI_I2C_HELPER_PLATFORM platform;
     bool guard_time_read;
     bool guard_time_write;
-    int  guard_time;
+    uint8_t  guard_time;
     char header[TCTI_I2C_HELPER_RESP_HEADER_SIZE];
 } TSS2_TCTI_I2C_HELPER_CONTEXT;
 
diff --git a/src/tss2-tcti/tcti-libtpms.c b/src/tss2-tcti/tcti-libtpms.c
index 5f4fcb130..517d1684d 100644
--- a/src/tss2-tcti/tcti-libtpms.c
+++ b/src/tss2-tcti/tcti-libtpms.c
@@ -94,7 +94,7 @@ tcti_libtpms_map_state_file(TSS2_TCTI_LIBTPMS_CONTEXT *tcti_libtpms)
     tcti_libtpms->state_mmap_len = (file_len / STATE_MMAP_CHUNK_LEN + 1) * STATE_MMAP_CHUNK_LEN;
 
     /* allocate disk space */
-    ret = posix_fallocate(state_fd, 0, tcti_libtpms->state_mmap_len);
+    ret = posix_fallocate(state_fd, 0, (off_t) tcti_libtpms->state_mmap_len);
     if (ret != 0) {
         LOG_ERROR("fallocate failed on file %s: %d",tcti_libtpms->state_path, ret);
         rc = TSS2_TCTI_RC_IO_ERROR;
@@ -177,7 +177,7 @@ tcti_libtpms_ensure_state_len(
                 return TSS2_TCTI_RC_IO_ERROR;
             }
 
-            ret = posix_fallocate(state_fd, 0, tcti_libtpms->state_mmap_len);
+            ret = posix_fallocate(state_fd, 0, (off_t) tcti_libtpms->state_mmap_len);
             if (ret != 0) {
                 LOG_ERROR("fallocate failed on file %s: %d",tcti_libtpms->state_path, ret);
                 close(state_fd);
@@ -493,7 +493,7 @@ tcti_libtpms_finalize(
 
     if (tcti_libtpms->state_path != NULL) {
         /* truncate state file to its real size */
-        ret = truncate(tcti_libtpms->state_path, tcti_libtpms->state_len);
+        ret = truncate(tcti_libtpms->state_path, (off_t) tcti_libtpms->state_len);
         if (ret != 0) {
             LOG_WARNING("truncate failed on file %s: %s",
                         tcti_libtpms->state_path,
diff --git a/src/tss2-tcti/tcti-mssim.c b/src/tss2-tcti/tcti-mssim.c
index a4df730ea..751716de5 100644
--- a/src/tss2-tcti/tcti-mssim.c
+++ b/src/tss2-tcti/tcti-mssim.c
@@ -68,7 +68,7 @@ TSS2_RC tcti_platform_command (
     uint8_t buf [sizeof (cmd)] = { 0 };
     UINT32 rsp = 0;
     TSS2_RC rc = TSS2_RC_SUCCESS;
-    int ret;
+    size_t ret;
     ssize_t read_ret;
 
     if (tcti_mssim == NULL) {
@@ -89,8 +89,8 @@ TSS2_RC tcti_platform_command (
     LOGBLOB_DEBUG(buf, sizeof (cmd), "Sending %zu bytes to socket %" PRIu32
                   ":", sizeof (cmd), tcti_mssim->platform_sock);
     ret = write_all (tcti_mssim->platform_sock, buf, sizeof (cmd));
-    if (ret < (ssize_t) sizeof (cmd)) {
-        LOG_ERROR("Failed to send platform command %d with error: %d",
+    if (ret < sizeof (cmd)) {
+        LOG_ERROR("Failed to send platform command %d with error: %zd",
                   cmd, ret);
         return TSS2_TCTI_RC_IO_ERROR;
     }
@@ -331,7 +331,6 @@ tcti_mssim_receive (
     TSS2_TCTI_COMMON_CONTEXT *tcti_common = tcti_mssim_down_cast (tcti_mssim);
     TSS2_RC rc;
     UINT32 trash;
-    int ret;
 
     rc = tcti_common_receive_checks (tcti_common,
                                      response_size,
@@ -357,16 +356,15 @@ tcti_mssim_receive (
         /* Receive the size of the response. */
         uint8_t size_buf [sizeof (UINT32)];
 
-        ret = socket_poll(tcti_mssim->tpm_sock, timeout);
-        if (ret != TSS2_RC_SUCCESS) {
-            if (ret == TSS2_TCTI_RC_TRY_AGAIN) {
-                return ret;
+        rc = socket_poll(tcti_mssim->tpm_sock, timeout);
+        if (rc != TSS2_RC_SUCCESS) {
+            if (rc == TSS2_TCTI_RC_TRY_AGAIN) {
+                return rc;
             }
-            rc = ret;
             goto out;
         }
-        ret = socket_recv_buf (tcti_mssim->tpm_sock, size_buf, sizeof(UINT32));
-        if (ret != sizeof (UINT32)) {
+        rc = socket_recv_buf (tcti_mssim->tpm_sock, size_buf, sizeof(UINT32));
+        if (rc != sizeof (UINT32)) {
             rc = TSS2_TCTI_RC_IO_ERROR;
             goto out;
         }
@@ -397,46 +395,50 @@ tcti_mssim_receive (
 
     /* Receive the TPM response. */
     LOG_DEBUG ("Reading response of size %" PRIu32, tcti_common->header.size);
-    ret = socket_poll(tcti_mssim->tpm_sock, timeout);
-    if (ret != TSS2_RC_SUCCESS) {
-        if (ret == TSS2_TCTI_RC_TRY_AGAIN) {
-            return ret;
+    rc = socket_poll(tcti_mssim->tpm_sock, timeout);
+    if (rc != TSS2_RC_SUCCESS) {
+        if (rc == TSS2_TCTI_RC_TRY_AGAIN) {
+            return rc;
         }
-        rc = ret;
         goto out;
     }
-    ret = socket_recv_buf (tcti_mssim->tpm_sock,
+    rc = socket_recv_buf (tcti_mssim->tpm_sock,
                            (unsigned char *)response_buffer,
                            tcti_common->header.size);
-    if (ret < (ssize_t)tcti_common->header.size) {
+    if (rc < (ssize_t)tcti_common->header.size) {
         rc = TSS2_TCTI_RC_IO_ERROR;
         goto out;
     }
     LOGBLOB_DEBUG(response_buffer, tcti_common->header.size,
                   "Response buffer received:");
 
-    ret = socket_poll (tcti_mssim->tpm_sock, timeout);
-    if (ret != TSS2_RC_SUCCESS) {
-        if (ret == TSS2_TCTI_RC_TRY_AGAIN) {
-            return ret;
+    rc = socket_poll (tcti_mssim->tpm_sock, timeout);
+    if (rc != TSS2_RC_SUCCESS) {
+        if (rc == TSS2_TCTI_RC_TRY_AGAIN) {
+            return rc;
         }
-        rc = ret;
         goto out;
     }
 
     /* Receive the appended four bytes of 0's */
-    ret = socket_recv_buf (tcti_mssim->tpm_sock,
+    rc = socket_recv_buf (tcti_mssim->tpm_sock,
                            (unsigned char *)&trash, 4);
-    if (ret != 4) {
-        LOG_DEBUG ("Error reading last 4 bytes %" PRIu32, ret);
+    if (rc != 4) {
+        LOG_DEBUG ("Error reading last 4 bytes %" PRIu32, rc);
         rc = TSS2_TCTI_RC_IO_ERROR;
         goto out;
     }
 
     if (tcti_mssim->cancel) {
         rc = tcti_platform_command (tctiContext, MS_SIM_CANCEL_OFF);
+            if (rc != TSS2_RC_SUCCESS) {
+            return rc;
+        }
         tcti_mssim->cancel = 0;
     }
+
+    rc = TSS2_RC_SUCCESS;
+
     /*
      * Executing code beyond this point transitions the state machine to
      * TRANSMIT. Another call to this function will not be possible until
diff --git a/src/tss2-tcti/tcti-pcap-builder.c b/src/tss2-tcti/tcti-pcap-builder.c
index 6036d0a78..dfa574b5e 100644
--- a/src/tss2-tcti/tcti-pcap-builder.c
+++ b/src/tss2-tcti/tcti-pcap-builder.c
@@ -439,7 +439,7 @@ pcap_write_enhanced_packet_block (
         memcpy (buf, &footer, sizeof (epb_footer));
     }
 
-    return pdu_len;
+    return (int) pdu_len;
 }
 
 static int
@@ -491,7 +491,7 @@ pcap_write_ip_packet (
                                 direction);
     }
 
-    return pdu_len;
+    return (int) pdu_len;
 }
 
 static int
@@ -547,5 +547,5 @@ pcap_write_tcp_segment (
         }
     }
 
-    return pdu_len;
+    return (int) pdu_len;
 }
diff --git a/src/tss2-tcti/tcti-spi-ftdi.c b/src/tss2-tcti/tcti-spi-ftdi.c
index 5c64cd964..e25646748 100644
--- a/src/tss2-tcti/tcti-spi-ftdi.c
+++ b/src/tss2-tcti/tcti-spi-ftdi.c
@@ -97,7 +97,7 @@ platform_timeout_expired (void *user_data, bool *is_timeout_expired)
 TSS2_RC
 platform_spi_transfer (void *user_data, const void *data_out, void *data_in, size_t cnt)
 {
-    int length = cnt;
+    size_t length = cnt;
     PLATFORM_USERDATA *platform_data = (PLATFORM_USERDATA *) user_data;
     struct mpsse_context *mpsse = platform_data->mpsse;
     char *data = NULL;
@@ -106,7 +106,7 @@ platform_spi_transfer (void *user_data, const void *data_out, void *data_in, siz
         return TSS2_TCTI_RC_IO_ERROR;
     }
 
-    if ((data = Transfer (mpsse, (char *)data_out, length)) == NULL) {
+    if ((data = Transfer (mpsse, (char *)data_out, (int) length)) == NULL) {
         Stop (mpsse);
         return TSS2_TCTI_RC_IO_ERROR;
     }
diff --git a/src/tss2-tcti/tcti-spi-ltt2go.c b/src/tss2-tcti/tcti-spi-ltt2go.c
index 1ab4f6f0e..f8fd40351 100644
--- a/src/tss2-tcti/tcti-spi-ltt2go.c
+++ b/src/tss2-tcti/tcti-spi-ltt2go.c
@@ -73,7 +73,7 @@ platform_spi_transfer (void *user_data, const void *data_out, void *data_in, siz
     }
 
     while (transfered != cnt){
-        ret = libusb_bulk_transfer (dev_handle, EP_OUT, spi_dma_buffer+transfered, length, &act_len, TIMEOUT);
+        ret = libusb_bulk_transfer (dev_handle, EP_OUT, spi_dma_buffer+transfered, (int) length, &act_len, TIMEOUT);
         if (ret) {
             LOG_ERROR ("libusb_bulk_transfer write failed with error: %s.", libusb_strerror(ret));
             ret = TSS2_TCTI_RC_IO_ERROR;
@@ -86,7 +86,7 @@ platform_spi_transfer (void *user_data, const void *data_out, void *data_in, siz
     transfered = 0;
     length = cnt;
     while(transfered != cnt){
-        ret = libusb_bulk_transfer (dev_handle, EP_IN, spi_dma_buffer+transfered, length, &act_len, TIMEOUT);
+        ret = libusb_bulk_transfer (dev_handle, EP_IN, spi_dma_buffer+transfered, (int) length, &act_len, TIMEOUT);
         if (ret) {
             if (retry++ > 5) {
                 LOG_ERROR ("libusb_bulk_transfer read failed with error: %s.", libusb_strerror(ret));
diff --git a/src/tss2-tcti/tcti-swtpm.c b/src/tss2-tcti/tcti-swtpm.c
index 74a8971a0..b9e75d26d 100644
--- a/src/tss2-tcti/tcti-swtpm.c
+++ b/src/tss2-tcti/tcti-swtpm.c
@@ -114,7 +114,7 @@ TSS2_RC tcti_control_command (
 {
     TSS2_TCTI_SWTPM_CONTEXT *tcti_swtpm = tcti_swtpm_context_cast(tctiContext);
     TSS2_RC rc = TSS2_RC_SUCCESS;
-    int ret;
+    size_t ret;
     uint32_t response_code;
 
     if (tcti_swtpm == NULL) {
@@ -174,8 +174,8 @@ TSS2_RC tcti_control_command (
     LOGBLOB_DEBUG(req_buf, req_buf_len, "Sending %zu bytes to socket %" PRIu32
                   ":", req_buf_len, tcti_swtpm->ctrl_sock);
     ret = write_all (tcti_swtpm->ctrl_sock, req_buf, req_buf_len);
-    if (ret < (ssize_t) req_buf_len) {
-        LOG_ERROR("Failed to send control command %d with error: %d",
+    if (ret < req_buf_len) {
+        LOG_ERROR("Failed to send control command %d with error: %zd",
                   cmd_code, ret);
         rc = TSS2_TCTI_RC_IO_ERROR;
         goto out;
@@ -393,7 +393,7 @@ tcti_swtpm_receive (
     TSS2_TCTI_SWTPM_CONTEXT *tcti_swtpm = tcti_swtpm_context_cast (tctiContext);
     TSS2_TCTI_COMMON_CONTEXT *tcti_common = tcti_swtpm_down_cast (tcti_swtpm);
     TSS2_RC rc;
-    int ret;
+    size_t ret;
 
     rc = tcti_common_receive_checks (tcti_common, response_size, TCTI_SWTPM_MAGIC);
     if (rc != TSS2_RC_SUCCESS) {
@@ -448,7 +448,7 @@ tcti_swtpm_receive (
         ret = socket_recv_buf (tcti_swtpm->tpm_sock,
                                (unsigned char *)&response_buffer[10],
                                tcti_common->header.size - 10);
-        if (ret < (ssize_t)tcti_common->header.size - 10) {
+        if (ret < tcti_common->header.size - 10) {
             rc = TSS2_TCTI_RC_IO_ERROR;
             goto out;
         }
diff --git a/src/util-io/io.c b/src/util-io/io.c
index 798d523d1..80385b833 100644
--- a/src/util-io/io.c
+++ b/src/util-io/io.c
@@ -41,7 +41,7 @@
  * once all of the requested data has been read, an error occurs, or EOF.
  * On error or EOF, the number of bytes read (if any) will be returned.
  */
-ssize_t
+size_t
 read_all (
     SOCKET fd,
     uint8_t *data,
@@ -81,7 +81,7 @@ read_all (
     return recvd_total;
 }
 
-ssize_t
+size_t
 write_all (
     SOCKET fd,
     const uint8_t *buf,
@@ -117,10 +117,10 @@ write_all (
         }
     } while (written_total < size);
 
-    return (ssize_t)written_total;
+    return written_total;
 }
 
-ssize_t
+size_t
 socket_recv_buf (
     SOCKET sock,
     uint8_t *data,
@@ -135,11 +135,11 @@ socket_xmit_buf (
     const void *buf,
     size_t size)
 {
-    int ret;
+    size_t ret;
 
     LOGBLOB_DEBUG (buf, size, "Writing %zu bytes to socket %d:", size, sock);
     ret = write_all (sock, buf, size);
-    if (ret < (ssize_t) size) {
+    if (ret < size) {
 #ifdef _WIN32
         LOG_ERROR ("write to fd %d failed, errno %d: %s", sock, WSAGetLastError(), strerror (WSAGetLastError()));
 #else
diff --git a/src/util-io/io.h b/src/util-io/io.h
index 42df80161..595177d38 100644
--- a/src/util-io/io.h
+++ b/src/util-io/io.h
@@ -61,7 +61,7 @@ extern "C" {
  * are detected. This is currently limited to interrupted system calls and
  * short reads.
  */
-ssize_t
+size_t
 read_all (
     SOCKET fd,
     uint8_t *data,
@@ -72,7 +72,7 @@ read_all (
  * are detected. This is currently limited to interrupted system calls and
  * short writes.
  */
-ssize_t
+size_t
 write_all (
     SOCKET fd,
     const uint8_t *buf,
@@ -104,7 +104,7 @@ socket_close (
 TSS2_RC
 socket_set_nonblock (
     SOCKET sock);
-ssize_t
+size_t
 socket_recv_buf (
     SOCKET sock,
     uint8_t *data,