Improve const char declarations

Declare C string constants using array syntax, avoid pointer syntax
when possible. They are different, the array syntax generates smaller,
faster code.

Also, const char[] should usually be static, again to avoid poor
compilation and runtime performance where compilers tend to
initialize the const declaration for every call instead of using
.rodata for the string.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
This commit is contained in:
Dimitri Papadopoulos
2021-12-08 22:37:51 +01:00
parent 78c26b6f21
commit a5d79fc230
5 changed files with 15 additions and 16 deletions

View File

@@ -258,13 +258,13 @@ void generate_config_files(const char *output_folder, cjose_jwk_t * key,
int main(int argc, char **argv)
{
char working_directory[1024];
const char audience[] = "SomeAudience";
const char issuer[] = "SomeIssuer";
const char user_name_claim[] = "preferred_user_name";
static const char audience[] = "SomeAudience";
static const char issuer[] = "SomeIssuer";
static const char user_name_claim[] = "preferred_user_name";
char kid[64];
const char user_name[] = "SomeUser";
const char typ[] = "JWT";
const char alg[] = "ES256";
static const char user_name[] = "SomeUser";
static const char typ[] = "JWT";
static const char alg[] = "ES256";
time_t now = time(NULL);
snprintf(kid, sizeof(kid), "key_%ld", now);