Fix integer conversion warnings in psa_constant_names

This commit is contained in:
Darryl Green 2018-10-17 15:01:45 +01:00
parent a3678224b3
commit 1824696681
2 changed files with 12 additions and 12 deletions

View File

@ -83,9 +83,9 @@ static int psa_snprint_status(char *buffer, size_t buffer_size,
size_t length = strlen(name); size_t length = strlen(name);
if (length < buffer_size) { if (length < buffer_size) {
memcpy(buffer, name, length + 1); memcpy(buffer, name, length + 1);
return length; return (int) length;
} else { } 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); size_t length = strlen(name);
if (length < buffer_size) { if (length < buffer_size) {
memcpy(buffer, name, length + 1); memcpy(buffer, name, length + 1);
return length; return (int) length;
} else { } 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")) 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")) 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")) 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")) 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")) 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 { else {
printf("Unknown type: %s\n", argv[1]); printf("Unknown type: %s\n", argv[1]);
return EXIT_FAILURE; return EXIT_FAILURE;

View File

@ -44,7 +44,7 @@ static int psa_snprint_key_type(char *buffer, size_t buffer_size,
break; break;
} }
buffer[0] = 0; buffer[0] = 0;
return required_size; return (int) required_size;
} }
static int psa_snprint_algorithm(char *buffer, size_t buffer_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); append(&buffer, buffer_size, &required_size, ")", 1);
} }
buffer[0] = 0; buffer[0] = 0;
return required_size; return (int) required_size;
} }
static int psa_snprint_key_usage(char *buffer, size_t buffer_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 { } else {
buffer[0] = 0; buffer[0] = 0;
} }
return required_size; return (int) required_size;
} }
/* End of automatically generated file. */ /* End of automatically generated file. */