From db32317f1b24a5ab72dcf5facfacc9816fc36dc7 Mon Sep 17 00:00:00 2001 From: Tj Date: Wed, 7 Oct 2015 23:55:49 +0100 Subject: [PATCH 1/1] use constants instead of literals for length comparisons --- cfe_generate_password.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cfe_generate_password.c b/cfe_generate_password.c index 0fe8273..967543b 100644 --- a/cfe_generate_password.c +++ b/cfe_generate_password.c @@ -60,11 +60,12 @@ #include #include -static const float VERSION = 1.0f; +static const float VERSION = 1.1f; static const size_t TIMESTAMP_SIZE = 6; static const size_t SEED_SIZE = 12; static const size_t PASSWORD_SIZE = 8; static const size_t MESSAGE_SIZE = 128; +static const size_t MAC_ADDR_SIZE = 17; static void pr_usage() @@ -114,7 +115,7 @@ static unsigned int generate_seed(char *mac, char *timestamp, char *seed) { unsigned int result = 0; - if (mac && strlen(mac) == 17) { + if (mac && strlen(mac) == MAC_ADDR_SIZE) { size_t i; char *mac_ptr = mac + 9; size_t ts_len = strlen(timestamp); @@ -140,7 +141,7 @@ generate_pass(char *seed, char *password) { unsigned int result = 0; - if (seed && strlen(seed) == 12) { + if (seed && strlen(seed) == SEED_SIZE) { unsigned int timestamp, byte, key, pass; timestamp = byte = 0; if(! sscanf(seed, "%06x", ×tamp)) -- 2.17.1