diff --git a/psftp.c b/psftp.c index 04a85458..21c57365 100644 --- a/psftp.c +++ b/psftp.c @@ -2116,7 +2116,7 @@ const struct sftp_cmd_lookup *lookup_command(const char *name) int i, j, k, cmp; i = -1; - j = sizeof(sftp_lookup) / sizeof(*sftp_lookup); + j = lenof(sftp_lookup); while (j - i > 1) { k = (j + i) / 2; cmp = strcmp(name, sftp_lookup[k].name); @@ -2140,7 +2140,7 @@ static int sftp_cmd_help(struct sftp_command *cmd) */ int maxlen; maxlen = 0; - for (i = 0; i < sizeof(sftp_lookup) / sizeof(*sftp_lookup); i++) { + for (i = 0; i < lenof(sftp_lookup); i++) { int len; if (!sftp_lookup[i].listed) continue; @@ -2148,7 +2148,7 @@ static int sftp_cmd_help(struct sftp_command *cmd) if (maxlen < len) maxlen = len; } - for (i = 0; i < sizeof(sftp_lookup) / sizeof(*sftp_lookup); i++) { + for (i = 0; i < lenof(sftp_lookup); i++) { const struct sftp_cmd_lookup *lookup; if (!sftp_lookup[i].listed) continue; diff --git a/sftp.c b/sftp.c index de02a1ad..3bd4d15e 100644 --- a/sftp.c +++ b/sftp.c @@ -213,8 +213,7 @@ static int fxp_got_status(struct sftp_packet *pktin) fxp_error_message = "malformed FXP_STATUS packet"; fxp_errtype = -1; } else { - if (fxp_errtype < 0 || - fxp_errtype >= sizeof(messages) / sizeof(*messages)) + if (fxp_errtype < 0 || fxp_errtype >= lenof(messages)) fxp_error_message = "unknown error code"; else fxp_error_message = messages[fxp_errtype]; diff --git a/sshaes.c b/sshaes.c index 92b476a2..40f3341e 100644 --- a/sshaes.c +++ b/sshaes.c @@ -1157,10 +1157,7 @@ static const ssh2_cipheralg *const aes_list[] = { &ssh_aes128, }; -const ssh2_ciphers ssh2_aes = { - sizeof(aes_list) / sizeof(*aes_list), - aes_list -}; +const ssh2_ciphers ssh2_aes = { lenof(aes_list), aes_list }; /* * Implementation of AES for PuTTY using AES-NI diff --git a/ssharcf.c b/ssharcf.c index 63eebdd0..53d79b6a 100644 --- a/ssharcf.c +++ b/ssharcf.c @@ -124,7 +124,4 @@ static const ssh2_cipheralg *const arcfour_list[] = { &ssh_arcfour128_ssh2, }; -const ssh2_ciphers ssh2_arcfour = { - sizeof(arcfour_list) / sizeof(*arcfour_list), - arcfour_list -}; +const ssh2_ciphers ssh2_arcfour = { lenof(arcfour_list), arcfour_list }; diff --git a/sshblowf.c b/sshblowf.c index 7a56aa43..54742a74 100644 --- a/sshblowf.c +++ b/sshblowf.c @@ -702,7 +702,4 @@ static const ssh2_cipheralg *const blowfish_list[] = { &ssh_blowfish_ssh2 }; -const ssh2_ciphers ssh2_blowfish = { - sizeof(blowfish_list) / sizeof(*blowfish_list), - blowfish_list -}; +const ssh2_ciphers ssh2_blowfish = { lenof(blowfish_list), blowfish_list }; diff --git a/sshccp.c b/sshccp.c index cb1739a1..5616c620 100644 --- a/sshccp.c +++ b/sshccp.c @@ -1047,7 +1047,4 @@ static const ssh2_cipheralg *const ccp_list[] = { &ssh2_chacha20_poly1305 }; -const ssh2_ciphers ssh2_ccp = { - sizeof(ccp_list) / sizeof(*ccp_list), - ccp_list -}; +const ssh2_ciphers ssh2_ccp = { lenof(ccp_list), ccp_list }; diff --git a/sshdes.c b/sshdes.c index bda4300f..333ee2d4 100644 --- a/sshdes.c +++ b/sshdes.c @@ -1115,20 +1115,14 @@ static const ssh2_cipheralg *const des3_list[] = { &ssh_3des_ssh2 }; -const ssh2_ciphers ssh2_3des = { - sizeof(des3_list) / sizeof(*des3_list), - des3_list -}; +const ssh2_ciphers ssh2_3des = { lenof(des3_list), des3_list }; static const ssh2_cipheralg *const des_list[] = { &ssh_des_ssh2, &ssh_des_sshcom_ssh2 }; -const ssh2_ciphers ssh2_des = { - sizeof(des_list) / sizeof(*des_list), - des_list -}; +const ssh2_ciphers ssh2_des = { lenof(des_list), des_list }; const ssh1_cipheralg ssh1_3des = { des3_ssh1_new, des3_ssh1_free, des3_ssh1_sesskey, diff --git a/sshdh.c b/sshdh.c index 36131777..8e822199 100644 --- a/sshdh.c +++ b/sshdh.c @@ -42,10 +42,7 @@ static const ssh_kex *const group1_list[] = { &ssh_diffiehellman_group1_sha1 }; -const ssh_kexes ssh_diffiehellman_group1 = { - sizeof(group1_list) / sizeof(*group1_list), - group1_list -}; +const ssh_kexes ssh_diffiehellman_group1 = { lenof(group1_list), group1_list }; static const struct dh_extra extra_group14 = { false, dh_group14_construct, @@ -67,8 +64,7 @@ static const ssh_kex *const group14_list[] = { }; const ssh_kexes ssh_diffiehellman_group14 = { - sizeof(group14_list) / sizeof(*group14_list), - group14_list + lenof(group14_list), group14_list }; static const struct dh_extra extra_gex = { true }; @@ -88,10 +84,7 @@ static const ssh_kex *const gex_list[] = { &ssh_diffiehellman_gex_sha1 }; -const ssh_kexes ssh_diffiehellman_gex = { - sizeof(gex_list) / sizeof(*gex_list), - gex_list -}; +const ssh_kexes ssh_diffiehellman_gex = { lenof(gex_list), gex_list }; /* * Suffix on GSSAPI SSH protocol identifiers that indicates Kerberos 5 @@ -129,8 +122,7 @@ static const ssh_kex *const gssk5_sha1_kex_list[] = { }; const ssh_kexes ssh_gssk5_sha1_kex = { - sizeof(gssk5_sha1_kex_list) / sizeof(*gssk5_sha1_kex_list), - gssk5_sha1_kex_list + lenof(gssk5_sha1_kex_list), gssk5_sha1_kex_list }; /* diff --git a/sshecc.c b/sshecc.c index 977e3087..f18a4b37 100644 --- a/sshecc.c +++ b/sshecc.c @@ -1444,10 +1444,7 @@ static const ssh_kex *const ec_kex_list[] = { &ssh_ec_kex_nistp521, }; -const ssh_kexes ssh_ecdh_kex = { - sizeof(ec_kex_list) / sizeof(*ec_kex_list), - ec_kex_list -}; +const ssh_kexes ssh_ecdh_kex = { lenof(ec_kex_list), ec_kex_list }; /* ---------------------------------------------------------------------- * Helper functions for finding key algorithms and returning auxiliary diff --git a/sshrand.c b/sshrand.c index cde35eef..d3ca45c8 100644 --- a/sshrand.c +++ b/sshrand.c @@ -140,7 +140,7 @@ static void random_stir(void) * digest. */ - for (k = 0; k < sizeof(digest) / sizeof(*digest); k++) + for (k = 0; k < lenof(digest); k++) digest[k] ^= ((uint32_t *) (pool.pool + j))[k]; /* @@ -153,7 +153,7 @@ static void random_stir(void) * Stick the result back into the pool. */ - for (k = 0; k < sizeof(digest) / sizeof(*digest); k++) + for (k = 0; k < lenof(digest); k++) ((uint32_t *) (pool.pool + j))[k] = digest[k]; } diff --git a/sshrsa.c b/sshrsa.c index a9741d06..32842939 100644 --- a/sshrsa.c +++ b/sshrsa.c @@ -927,7 +927,4 @@ static const ssh_kex *const rsa_kex_list[] = { &ssh_rsa_kex_sha1 }; -const ssh_kexes ssh_rsa_kex = { - sizeof(rsa_kex_list) / sizeof(*rsa_kex_list), - rsa_kex_list -}; +const ssh_kexes ssh_rsa_kex = { lenof(rsa_kex_list), rsa_kex_list }; diff --git a/sshsh256.c b/sshsh256.c index 1d43127c..0dd271c4 100644 --- a/sshsh256.c +++ b/sshsh256.c @@ -360,7 +360,7 @@ int main(void) { errors = 0; - for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) { + for (i = 0; i < lenof(tests); i++) { SHA256_Simple(tests[i].teststring, strlen(tests[i].teststring), digest); for (j = 0; j < 32; j++) { diff --git a/sshsh512.c b/sshsh512.c index d8bc1ccd..38981220 100644 --- a/sshsh512.c +++ b/sshsh512.c @@ -407,7 +407,7 @@ int main(void) { errors = 0; - for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) { + for (i = 0; i < lenof(tests); i++) { if (tests[i].teststring) { SHA512_Simple(tests[i].teststring, strlen(tests[i].teststring), digest); diff --git a/sshzlib.c b/sshzlib.c index 3bb86298..52a5feee 100644 --- a/sshzlib.c +++ b/sshzlib.c @@ -510,7 +510,7 @@ static void zlib_match(struct LZ77Context *ectx, int distance, int len) * transmitting. */ i = -1; - j = sizeof(lencodes) / sizeof(*lencodes); + j = lenof(lencodes); while (1) { assert(j - i >= 2); k = (j + i) / 2; @@ -546,7 +546,7 @@ static void zlib_match(struct LZ77Context *ectx, int distance, int len) * transmitting. */ i = -1; - j = sizeof(distcodes) / sizeof(*distcodes); + j = lenof(distcodes); while (1) { assert(j - i >= 2); k = (j + i) / 2;