summaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2017-04-13 05:54:52 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2017-04-13 05:54:52 +0200
commit74258278efacd7069e8c1df8ff6fc3f4675d713e (patch)
tree9d524e133a7715f4836e5e6351455a42b897e20c /g10
parentdirmngr: More fix for Windows. (diff)
downloadgnupg2-74258278efacd7069e8c1df8ff6fc3f4675d713e.tar.xz
gnupg2-74258278efacd7069e8c1df8ff6fc3f4675d713e.zip
common, g10: Fix enumeration types.
* common/openpgpdefs.h (CIPHER_ALGO_PRIVATE10, PUBKEY_ALGO_PRIVATE10) (DIGEST_ALGO_PRIVATE10, COMPRESS_ALGO_PRIVATE10): New. * g10/misc.c (map_pk_gcry_to_openpgp): Add type conversion. (map_cipher_openpgp_to_gcry, openpgp_cipher_algo_name) (openpgp_pk_test_algo2, map_md_openpgp_to_gcry) (pubkey_get_npkey): Add default handling. -- Compilers may emit code assuming the maximum value of enum type. According to OpenPGP specification, there are cases for private uses. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'g10')
-rw-r--r--g10/misc.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 0ecdb0478..abae6c960 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -473,8 +473,8 @@ map_cipher_openpgp_to_gcry (cipher_algo_t algo)
#else
case CIPHER_ALGO_CAMELLIA256: return 0;
#endif
+ default: return 0;
}
- return 0;
}
/* The inverse function of above. */
@@ -509,7 +509,7 @@ map_pk_gcry_to_openpgp (enum gcry_pk_algos algo)
{
case GCRY_PK_ECDSA: return PUBKEY_ALGO_ECDSA;
case GCRY_PK_ECDH: return PUBKEY_ALGO_ECDH;
- default: return algo < 110 ? algo : 0;
+ default: return algo < 110 ? (pubkey_algo_t)algo : 0;
}
}
@@ -565,7 +565,6 @@ openpgp_cipher_algo_name (cipher_algo_t algo)
{
switch (algo)
{
- case CIPHER_ALGO_NONE: break;
case CIPHER_ALGO_IDEA: return "IDEA";
case CIPHER_ALGO_3DES: return "3DES";
case CIPHER_ALGO_CAST5: return "CAST5";
@@ -577,8 +576,9 @@ openpgp_cipher_algo_name (cipher_algo_t algo)
case CIPHER_ALGO_CAMELLIA128: return "CAMELLIA128";
case CIPHER_ALGO_CAMELLIA192: return "CAMELLIA192";
case CIPHER_ALGO_CAMELLIA256: return "CAMELLIA256";
+ case CIPHER_ALGO_NONE:
+ default: return "?";
}
- return "?";
}
@@ -636,6 +636,9 @@ openpgp_pk_test_algo2 (pubkey_algo_t algo, unsigned int use)
if (RFC2440)
ga = GCRY_PK_ELG;
break;
+
+ default:
+ break;
}
if (!ga)
return gpg_error (GPG_ERR_PUBKEY_ALGO);
@@ -699,8 +702,8 @@ openpgp_pk_algo_name (pubkey_algo_t algo)
case PUBKEY_ALGO_ECDH: return "ECDH";
case PUBKEY_ALGO_ECDSA: return "ECDSA";
case PUBKEY_ALGO_EDDSA: return "EDDSA";
+ default: return "?";
}
- return "?";
}
@@ -832,8 +835,8 @@ map_md_openpgp_to_gcry (digest_algo_t algo)
#else
case DIGEST_ALGO_SHA512: return 0;
#endif
+ default: return 0;
}
- return 0;
}
@@ -1652,8 +1655,8 @@ pubkey_get_npkey (pubkey_algo_t algo)
case PUBKEY_ALGO_ECDSA: return 2;
case PUBKEY_ALGO_ELGAMAL: return 3;
case PUBKEY_ALGO_EDDSA: return 2;
+ default: return 0;
}
- return 0;
}
@@ -1672,8 +1675,8 @@ pubkey_get_nskey (pubkey_algo_t algo)
case PUBKEY_ALGO_ECDSA: return 3;
case PUBKEY_ALGO_ELGAMAL: return 4;
case PUBKEY_ALGO_EDDSA: return 3;
+ default: return 0;
}
- return 0;
}
/* Temporary helper. */
@@ -1691,8 +1694,8 @@ pubkey_get_nsig (pubkey_algo_t algo)
case PUBKEY_ALGO_ECDSA: return 2;
case PUBKEY_ALGO_ELGAMAL: return 2;
case PUBKEY_ALGO_EDDSA: return 2;
+ default: return 0;
}
- return 0;
}
@@ -1711,8 +1714,8 @@ pubkey_get_nenc (pubkey_algo_t algo)
case PUBKEY_ALGO_ECDSA: return 0;
case PUBKEY_ALGO_ELGAMAL: return 2;
case PUBKEY_ALGO_EDDSA: return 0;
+ default: return 0;
}
- return 0;
}