From 1824696681de10a1f01048ef7e3bdd21f407a788 Mon Sep 17 00:00:00 2001 From: Darryl Green Date: Wed, 17 Oct 2018 15:01:45 +0100 Subject: [PATCH] Fix integer conversion warnings in psa_constant_names --- programs/psa/psa_constant_names.c | 18 +++++++++--------- scripts/generate_psa_constants.py | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/programs/psa/psa_constant_names.c b/programs/psa/psa_constant_names.c index 55a70c60d..88821dab5 100644 --- a/programs/psa/psa_constant_names.c +++ b/programs/psa/psa_constant_names.c @@ -83,9 +83,9 @@ static int psa_snprint_status(char *buffer, size_t buffer_size, size_t length = strlen(name); if (length < buffer_size) { memcpy(buffer, name, length + 1); - return length; + return (int) length; } else { - return buffer_size; + return (int) buffer_size; } } } @@ -100,9 +100,9 @@ static int psa_snprint_ecc_curve(char *buffer, size_t buffer_size, size_t length = strlen(name); if (length < buffer_size) { memcpy(buffer, name, length + 1); - return length; + return (int) length; } else { - return buffer_size; + return (int) buffer_size; } } } @@ -144,15 +144,15 @@ int main(int argc, char *argv[]) } if (!strcmp(argv[1], "error") || !strcmp(argv[1], "status")) - psa_snprint_status(buffer, sizeof(buffer), value); + psa_snprint_status(buffer, sizeof(buffer), (psa_status_t) value); else if (!strcmp(argv[1], "alg") || !strcmp(argv[1], "algorithm")) - psa_snprint_algorithm(buffer, sizeof(buffer), value); + psa_snprint_algorithm(buffer, sizeof(buffer), (psa_algorithm_t) value); else if (!strcmp(argv[1], "curve") || !strcmp(argv[1], "ecc_curve")) - psa_snprint_ecc_curve(buffer, sizeof(buffer), value); + psa_snprint_ecc_curve(buffer, sizeof(buffer), (psa_ecc_curve_t) value); else if (!strcmp(argv[1], "type") || !strcmp(argv[1], "key_type")) - psa_snprint_key_type(buffer, sizeof(buffer), value); + psa_snprint_key_type(buffer, sizeof(buffer), (psa_key_type_t) value); else if (!strcmp(argv[1], "usage") || !strcmp(argv[1], "key_usage")) - psa_snprint_key_usage(buffer, sizeof(buffer), value); + psa_snprint_key_usage(buffer, sizeof(buffer), (psa_key_usage_t) value); else { printf("Unknown type: %s\n", argv[1]); return EXIT_FAILURE; diff --git a/scripts/generate_psa_constants.py b/scripts/generate_psa_constants.py index 85bfe3ae9..7e4420b69 100755 --- a/scripts/generate_psa_constants.py +++ b/scripts/generate_psa_constants.py @@ -44,7 +44,7 @@ static int psa_snprint_key_type(char *buffer, size_t buffer_size, break; } buffer[0] = 0; - return required_size; + return (int) required_size; } static int psa_snprint_algorithm(char *buffer, size_t buffer_size, @@ -84,7 +84,7 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size, append(&buffer, buffer_size, &required_size, ")", 1); } buffer[0] = 0; - return required_size; + return (int) required_size; } static int psa_snprint_key_usage(char *buffer, size_t buffer_size, @@ -110,7 +110,7 @@ static int psa_snprint_key_usage(char *buffer, size_t buffer_size, } else { buffer[0] = 0; } - return required_size; + return (int) required_size; } /* End of automatically generated file. */