diff options
author | Werner Koch <wk@gnupg.org> | 2016-04-29 11:05:24 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-04-29 11:05:24 +0200 |
commit | 64bfeafa52a5ed3fa82bdc0ce7ef0edddeef188c (patch) | |
tree | 820e0e686ef9672b4b05c1e644026840e5710b6a /g10 | |
parent | common: Improve log_assert. (diff) | |
download | gnupg2-64bfeafa52a5ed3fa82bdc0ce7ef0edddeef188c.tar.xz gnupg2-64bfeafa52a5ed3fa82bdc0ce7ef0edddeef188c.zip |
gpg: Remove all assert.h and s/assert/log_assert/.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10')
52 files changed, 232 insertions, 285 deletions
diff --git a/g10/armor.c b/g10/armor.c index 98fb1056b..fb7465595 100644 --- a/g10/armor.c +++ b/g10/armor.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include <ctype.h> #include "gpg.h" @@ -137,7 +136,7 @@ release_armor_context (armor_filter_context_t *afx) { if (!afx) return; - assert (afx->refcount); + log_assert (afx->refcount); if ( --afx->refcount ) return; xfree (afx); diff --git a/g10/build-packet.c b/g10/build-packet.c index e244bda38..4d6d4afbb 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include <ctype.h> #include "gpg.h" @@ -91,7 +90,7 @@ build_packet( IOBUF out, PACKET *pkt ) if( DBG_PACKET ) log_debug("build_packet() type=%d\n", pkt->pkttype ); - assert( pkt->pkt.generic ); + log_assert( pkt->pkt.generic ); switch ((pkttype = pkt->pkttype)) { @@ -266,7 +265,7 @@ calc_packet_length( PACKET *pkt ) u32 n=0; int new_ctb = 0; - assert( pkt->pkt.generic ); + log_assert (pkt->pkt.generic); switch( pkt->pkttype ) { case PKT_PLAINTEXT: n = calc_plaintext( pkt->pkt.plaintext ); @@ -465,7 +464,7 @@ do_key (iobuf_t out, int ctb, PKT_public_key *pk) byte *p; unsigned int ndatabits; - assert (gcry_mpi_get_flag (pk->pkey[npkey], GCRYMPI_FLAG_OPAQUE)); + log_assert (gcry_mpi_get_flag (pk->pkey[npkey], GCRYMPI_FLAG_OPAQUE)); p = gcry_mpi_get_opaque (pk->pkey[npkey], &ndatabits); if (p) iobuf_write (a, p, (ndatabits+7)/8 ); @@ -509,7 +508,7 @@ do_symkey_enc( IOBUF out, int ctb, PKT_symkey_enc *enc ) log_assert (ctb_pkttype (ctb) == PKT_SYMKEY_ENC); /* The only acceptable version. */ - assert( enc->version == 4 ); + log_assert( enc->version == 4 ); /* RFC 4880, Section 3.7. */ switch( enc->s2k.mode ) @@ -798,7 +797,7 @@ delete_sig_subpkt (subpktarea_t *area, sigsubpkttype_t reqtype ) if (!okay) log_error ("delete_subpkt: buffer shorter than subpacket\n"); - assert (unused <= area->len); + log_assert (unused <= area->len); area->len -= unused; return !!unused; } @@ -1437,7 +1436,7 @@ do_signature( IOBUF out, int ctb, PKT_signature *sig ) static int do_onepass_sig( IOBUF out, int ctb, PKT_onepass_sig *ops ) { - log_assert (ctb_pkttype (ctb) == PKT_ONEPASS_SIG); + log_assert (ctb_pkttype (ctb) == PKT_ONEPASS_SIG); write_header(out, ctb, 4 + 8 + 1); diff --git a/g10/call-agent.c b/g10/call-agent.c index d9e48598e..c5bd694f0 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -25,7 +25,6 @@ #include <errno.h> #include <unistd.h> #include <time.h> -#include <assert.h> #ifdef HAVE_LOCALE_H #include <locale.h> #endif @@ -712,7 +711,7 @@ learn_status_cb (void *opaque, const char *line) && strchr("1234", keyword[11])) { int no = keyword[11] - '1'; - assert (no >= 0 && no <= 3); + log_assert (no >= 0 && no <= 3); xfree (parm->private_do[no]); parm->private_do[no] = unescape_status_string (line); } @@ -2133,7 +2132,7 @@ agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc, buf = get_membuf (&data, &len); if (!buf) return gpg_error_from_syserror (); - assert (len); /* (we forced Nul termination.) */ + log_assert (len); /* (we forced Nul termination.) */ if (*buf != '(') { diff --git a/g10/call-dirmngr.c b/g10/call-dirmngr.c index b0f249e8c..d35a5cf60 100644 --- a/g10/call-dirmngr.c +++ b/g10/call-dirmngr.c @@ -25,7 +25,6 @@ #include <errno.h> #include <unistd.h> #include <time.h> -#include <assert.h> #ifdef HAVE_LOCALE_H # include <locale.h> #endif @@ -261,7 +260,7 @@ open_context (ctrl_t ctrl, assuan_context_t *r_ctx) if (dml) { /* Found an inactive local session - return that. */ - assert (!dml->is_active); + log_assert (!dml->is_active); /* But first do the per session init if not yet done. */ if (!dml->set_keyservers_done) @@ -804,7 +803,7 @@ record_output (estream_t output, type_str = "sig"; break; default: - assert (! "Unhandled type."); + log_assert (! "Unhandled type."); } if (pub_key_length > 0) diff --git a/g10/card-util.c b/g10/card-util.c index 427671684..be1a593e9 100644 --- a/g10/card-util.c +++ b/g10/card-util.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #ifdef HAVE_LIBREADLINE # define GNUPG_LIBREADLINE_H_INCLUDED # include <readline/readline.h> @@ -901,7 +900,7 @@ change_private_do (const char *args, int nr) int n; int rc; - assert (nr >= 1 && nr <= 4); + log_assert (nr >= 1 && nr <= 4); do_name[11] = '0' + nr; if (args && (args = strchr (args, '<'))) /* Read it from a file */ @@ -1247,7 +1246,7 @@ show_card_key_info (struct agent_card_info_s *info) static int replace_existing_key_p (struct agent_card_info_s *info, int keyno) { - assert (keyno >= 0 && keyno <= 3); + log_assert (keyno >= 0 && keyno <= 3); if ((keyno == 1 && info->fpr1valid) || (keyno == 2 && info->fpr2valid) @@ -1538,8 +1537,8 @@ card_store_subkey (KBNODE node, int use) int rc; gnupg_isotime_t timebuf; - assert (node->pkt->pkttype == PKT_PUBLIC_KEY - || node->pkt->pkttype == PKT_PUBLIC_SUBKEY); + log_assert (node->pkt->pkttype == PKT_PUBLIC_KEY + || node->pkt->pkttype == PKT_PUBLIC_SUBKEY); pk = node->pkt->pkt.public_key; diff --git a/g10/cipher.c b/g10/cipher.c index 41324c37d..ae7ba17e3 100644 --- a/g10/cipher.c +++ b/g10/cipher.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "status.h" @@ -123,7 +122,7 @@ cipher_filter( void *opaque, int control, rc = -1; /* not yet used */ } else if( control == IOBUFCTRL_FLUSH ) { /* encrypt */ - assert(a); + log_assert(a); if( !cfx->header ) { write_header( cfx, a ); } @@ -139,7 +138,7 @@ cipher_filter( void *opaque, int control, (cfx->mdc_hash)); byte temp[22]; - assert( hashlen == 20 ); + log_assert( hashlen == 20 ); /* We must hash the prefix of the MDC packet here. */ temp[0] = 0xd3; temp[1] = 0x14; diff --git a/g10/compress.c b/g10/compress.c index fd1ed6a2d..bdddef134 100644 --- a/g10/compress.c +++ b/g10/compress.c @@ -29,7 +29,6 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <assert.h> #include <errno.h> #ifdef HAVE_ZIP # include <zlib.h> diff --git a/g10/dearmor.c b/g10/dearmor.c index 3fdd57dae..38c3a3c1b 100644 --- a/g10/dearmor.c +++ b/g10/dearmor.c @@ -22,7 +22,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "status.h" diff --git a/g10/decrypt-data.c b/g10/decrypt-data.c index 1380fafdc..96d21774a 100644 --- a/g10/decrypt-data.c +++ b/g10/decrypt-data.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -57,7 +56,7 @@ release_dfx_context (decode_filter_ctx_t dfx) if (!dfx) return; - assert (dfx->refcount); + log_assert (dfx->refcount); if ( !--dfx->refcount ) { gcry_cipher_close (dfx->cipher_hd); @@ -273,8 +272,8 @@ decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek) bytes are appended. */ int datalen = gcry_md_get_algo_dlen (ed->mdc_method); - assert (dfx->cipher_hd); - assert (dfx->mdc_hash); + log_assert (dfx->cipher_hd); + log_assert (dfx->mdc_hash); gcry_cipher_decrypt (dfx->cipher_hd, dfx->defer, 22, NULL, 0); gcry_md_write (dfx->mdc_hash, dfx->defer, 2); gcry_md_final (dfx->mdc_hash); @@ -320,8 +319,8 @@ mdc_decode_filter (void *opaque, int control, IOBUF a, } else if( control == IOBUFCTRL_UNDERFLOW ) { - assert (a); - assert (size > 44); /* Our code requires at least this size. */ + log_assert (a); + log_assert (size > 44); /* Our code requires at least this size. */ /* Get at least 22 bytes and put it ahead in the buffer. */ if (dfx->partial) @@ -414,7 +413,7 @@ mdc_decode_filter (void *opaque, int control, IOBUF a, } else { - assert ( dfx->eof_seen ); + log_assert ( dfx->eof_seen ); rc = -1; /* Return EOF. */ } *ret_len = n; @@ -447,7 +446,7 @@ decode_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len) } else if ( control == IOBUFCTRL_UNDERFLOW ) { - assert(a); + log_assert (a); if (fc->partial) { diff --git a/g10/decrypt.c b/g10/decrypt.c index 068b64aed..27f51f613 100644 --- a/g10/decrypt.c +++ b/g10/decrypt.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "options.h" diff --git a/g10/delkey.c b/g10/delkey.c index 5d0c3dffb..f76277c5a 100644 --- a/g10/delkey.c +++ b/g10/delkey.c @@ -24,7 +24,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include <ctype.h> #include "gpg.h" diff --git a/g10/ecdh.c b/g10/ecdh.c index a1b7ecfdc..af1d84439 100644 --- a/g10/ecdh.c +++ b/g10/ecdh.c @@ -22,7 +22,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -75,7 +74,7 @@ pk_ecdh_default_params (unsigned int qbits) break; } } - assert (i < DIM (kek_params_table)); + log_assert (i < DIM (kek_params_table)); if (DBG_CRYPTO) log_printhex ("ECDH KEK params are", kek_params, sizeof(kek_params) ); @@ -134,7 +133,7 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi, } secret_x_size = (nbits+7)/8; - assert (nbytes >= secret_x_size); + log_assert (nbytes >= secret_x_size); if ((nbytes & 1)) /* Remove the "04" prefix of non-compressed format. */ memmove (secret_x, secret_x+1, secret_x_size); @@ -241,16 +240,16 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi, gcry_md_final (h); - assert( gcry_md_get_algo_dlen (kdf_hash_algo) >= 32 ); + log_assert( gcry_md_get_algo_dlen (kdf_hash_algo) >= 32 ); memcpy (secret_x, gcry_md_read (h, kdf_hash_algo), gcry_md_get_algo_dlen (kdf_hash_algo)); gcry_md_close (h); old_size = secret_x_size; - assert( old_size >= gcry_cipher_get_algo_keylen( kdf_encr_algo ) ); + log_assert( old_size >= gcry_cipher_get_algo_keylen( kdf_encr_algo ) ); secret_x_size = gcry_cipher_get_algo_keylen( kdf_encr_algo ); - assert( secret_x_size <= gcry_md_get_algo_dlen (kdf_hash_algo) ); + log_assert( secret_x_size <= gcry_md_get_algo_dlen (kdf_hash_algo) ); /* We could have allocated more, so clean the tail before returning. */ memset (secret_x+secret_x_size, 0, old_size - secret_x_size); diff --git a/g10/encrypt.c b/g10/encrypt.c index fe18c15ad..57d24bef1 100644 --- a/g10/encrypt.c +++ b/g10/encrypt.c @@ -24,7 +24,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "options.h" @@ -80,7 +79,7 @@ encrypt_seskey (DEK *dek, DEK **seskey, byte *enckey) gcry_cipher_hd_t hd; byte buf[33]; - assert ( dek->keylen <= 32 ); + log_assert ( dek->keylen <= 32 ); if (!*seskey) { *seskey=xmalloc_clear(sizeof(DEK)); diff --git a/g10/export.c b/g10/export.c index 3f0693488..89604b4c7 100644 --- a/g10/export.c +++ b/g10/export.c @@ -24,7 +24,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "options.h" @@ -781,10 +780,10 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk) ski->algo = protect_algo; ski->s2k.mode = s2k_mode; ski->s2k.hash_algo = s2k_algo; - assert (sizeof ski->s2k.salt == sizeof s2k_salt); + log_assert (sizeof ski->s2k.salt == sizeof s2k_salt); memcpy (ski->s2k.salt, s2k_salt, sizeof s2k_salt); ski->s2k.count = s2k_count; - assert (ivlen <= sizeof ski->iv); + log_assert (ivlen <= sizeof ski->iv); memcpy (ski->iv, iv, ivlen); ski->ivlen = ivlen; diff --git a/g10/free-packet.c b/g10/free-packet.c index 670f2565e..8176e368b 100644 --- a/g10/free-packet.c +++ b/g10/free-packet.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -302,7 +301,7 @@ free_attributes(PKT_user_id *uid) void free_user_id (PKT_user_id *uid) { - assert (uid->ref > 0); + log_assert (uid->ref > 0); if (--uid->ref) return; diff --git a/g10/getkey.c b/g10/getkey.c index a3d29f50a..907007b3e 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -23,7 +23,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include <ctype.h> #include "gpg.h" @@ -220,7 +219,7 @@ cache_public_key (PKT_public_key * pk) pk_cache_entries--; } } - assert (pk_cache_entries < MAX_PK_CACHE_ENTRIES); + log_assert (pk_cache_entries < MAX_PK_CACHE_ENTRIES); } pk_cache_entries++; ce = xmalloc (sizeof *ce); @@ -659,8 +658,8 @@ pk_from_block (GETKEY_CTX ctx, PKT_public_key * pk, KBNODE keyblock, (void) ctx; - assert (a->pkt->pkttype == PKT_PUBLIC_KEY - || a->pkt->pkttype == PKT_PUBLIC_SUBKEY); + log_assert (a->pkt->pkttype == PKT_PUBLIC_KEY + || a->pkt->pkttype == PKT_PUBLIC_SUBKEY); copy_public_key (pk, a->pkt->pkt.public_key); } @@ -779,7 +778,7 @@ get_pubkey_fast (PKT_public_key * pk, u32 * keyid) KBNODE keyblock; u32 pkid[2]; - assert (pk); + log_assert (pk); #if MAX_PK_CACHE_ENTRIES { /* Try to get it from the cache */ @@ -817,8 +816,8 @@ get_pubkey_fast (PKT_public_key * pk, u32 * keyid) return GPG_ERR_NO_PUBKEY; } - assert (keyblock && keyblock->pkt - && keyblock->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (keyblock && keyblock->pkt + && keyblock->pkt->pkttype == PKT_PUBLIC_KEY); /* We return the primary key. If KEYID matched a subkey, then we return an error. */ @@ -970,7 +969,7 @@ skip_unusable (void *dummy, u32 * keyid, int uid_no) /* If UID_NO is non-zero, then the keyblock better have at least that many UIDs. */ - assert (uids_seen == uid_no); + log_assert (uids_seen == uid_no); } if (!unusable) @@ -1040,8 +1039,8 @@ key_byname (GETKEY_CTX *retctx, strlist_t namelist, if (retctx) { /* Reset the returned context in case of error. */ - assert (!ret_kdbhd); /* Not allowed because the handle is stored - in the context. */ + log_assert (!ret_kdbhd); /* Not allowed because the handle is stored + in the context. */ *retctx = NULL; } if (ret_kdbhd) @@ -1380,7 +1379,7 @@ get_pubkey_byname (ctrl_t ctrl, GETKEY_CTX * retctx, PKT_public_key * pk, { char fpr_string[MAX_FINGERPRINT_LEN * 2 + 1]; - assert (fpr_len <= MAX_FINGERPRINT_LEN); + log_assert (fpr_len <= MAX_FINGERPRINT_LEN); free_strlist (namelist); namelist = NULL; @@ -1440,7 +1439,7 @@ get_pubkey_byname (ctrl_t ctrl, GETKEY_CTX * retctx, PKT_public_key * pk, if (retctx && *retctx) { - assert (!(*retctx)->extra_list); + log_assert (!(*retctx)->extra_list); (*retctx)->extra_list = namelist; } else @@ -1564,8 +1563,8 @@ get_pubkey_byfprint_fast (PKT_public_key * pk, return GPG_ERR_NO_PUBKEY; } - assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY - || keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY); + log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY + || keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY); if (pk) copy_public_key (pk, keyblock->pkt->pkt.public_key); release_kbnode (keyblock); @@ -3111,7 +3110,7 @@ finish_lookup (GETKEY_CTX ctx, KBNODE keyblock) PKT_public_key *pk; - assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY); if (ctx->exact) /* Get the key or subkey that matched the low-level search @@ -3121,8 +3120,8 @@ finish_lookup (GETKEY_CTX ctx, KBNODE keyblock) { if ((k->flag & 1)) { - assert (k->pkt->pkttype == PKT_PUBLIC_KEY - || k->pkt->pkttype == PKT_PUBLIC_SUBKEY); + log_assert (k->pkt->pkttype == PKT_PUBLIC_KEY + || k->pkt->pkttype == PKT_PUBLIC_SUBKEY); foundk = k; pk = k->pkt->pkt.public_key; pk->flags.exact = 1; @@ -3136,7 +3135,7 @@ finish_lookup (GETKEY_CTX ctx, KBNODE keyblock) { if ((k->flag & 2)) { - assert (k->pkt->pkttype == PKT_USER_ID); + log_assert (k->pkt->pkttype == PKT_USER_ID); foundu = k->pkt->pkt.user_id; break; } @@ -3856,8 +3855,8 @@ have_secret_key_with_kid (u32 *keyid) match a single key or subkey. */ if ((node->flag & 1)) { - assert (node->pkt->pkttype == PKT_PUBLIC_KEY - || node->pkt->pkttype == PKT_PUBLIC_SUBKEY); + log_assert (node->pkt->pkttype == PKT_PUBLIC_KEY + || node->pkt->pkttype == PKT_PUBLIC_SUBKEY); if (!agent_probe_secret_key (NULL, node->pkt->pkt.public_key)) result = 1; /* Secret key available. */ @@ -26,7 +26,6 @@ #include <string.h> #include <ctype.h> #include <unistd.h> -#include <assert.h> #ifdef HAVE_STAT #include <sys/stat.h> /* for stat() */ #endif @@ -1389,7 +1388,7 @@ check_permissions (const char *path, int item) if(opt.no_perm_warn) return 0; - assert(item==0 || item==1 || item==2); + log_assert(item==0 || item==1 || item==2); /* extensions may attach a path */ if(item==2 && path[0]!=DIRSEP_C) diff --git a/g10/import.c b/g10/import.c index e9fc014cc..6707797f5 100644 --- a/g10/import.c +++ b/g10/import.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "options.h" @@ -1835,9 +1834,9 @@ import_revoke_cert (const char *fname, kbnode_t node, (void)fname; - assert( !node->next ); - assert( node->pkt->pkttype == PKT_SIGNATURE ); - assert( node->pkt->pkt.signature->sig_class == 0x20 ); + log_assert (!node->next ); + log_assert (node->pkt->pkttype == PKT_SIGNATURE ); + log_assert (node->pkt->pkt.signature->sig_class == 0x20 ); keyid[0] = node->pkt->pkt.signature->keyid[0]; keyid[1] = node->pkt->pkt.signature->keyid[1]; @@ -2720,7 +2719,7 @@ append_uid (kbnode_t keyblock, kbnode_t node, int *n_sigs, (void)fname; (void)keyid; - assert(node->pkt->pkttype == PKT_USER_ID ); + log_assert (node->pkt->pkttype == PKT_USER_ID ); /* find the position */ for (n = keyblock; n; n_where = n, n = n->next) @@ -2773,8 +2772,8 @@ merge_sigs (kbnode_t dst, kbnode_t src, int *n_sigs, (void)fname; (void)keyid; - assert(dst->pkt->pkttype == PKT_USER_ID ); - assert(src->pkt->pkttype == PKT_USER_ID ); + log_assert (dst->pkt->pkttype == PKT_USER_ID); + log_assert (src->pkt->pkttype == PKT_USER_ID); for (n=src->next; n && n->pkt->pkttype != PKT_USER_ID; n = n->next) { @@ -2821,8 +2820,8 @@ merge_keysigs (kbnode_t dst, kbnode_t src, int *n_sigs, (void)fname; (void)keyid; - assert (dst->pkt->pkttype == PKT_PUBLIC_SUBKEY - || dst->pkt->pkttype == PKT_SECRET_SUBKEY); + log_assert (dst->pkt->pkttype == PKT_PUBLIC_SUBKEY + || dst->pkt->pkttype == PKT_SECRET_SUBKEY); for (n=src->next; n ; n = n->next) { @@ -2882,8 +2881,8 @@ append_key (kbnode_t keyblock, kbnode_t node, int *n_sigs, (void)fname; (void)keyid; - assert( node->pkt->pkttype == PKT_PUBLIC_SUBKEY - || node->pkt->pkttype == PKT_SECRET_SUBKEY ); + log_assert (node->pkt->pkttype == PKT_PUBLIC_SUBKEY + || node->pkt->pkttype == PKT_SECRET_SUBKEY); while (node) { diff --git a/g10/kbnode.c b/g10/kbnode.c index 3337e011b..a1d1f3d77 100644 --- a/g10/kbnode.c +++ b/g10/kbnode.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "util.h" diff --git a/g10/keydb.c b/g10/keydb.c index 960480708..016434817 100644 --- a/g10/keydb.c +++ b/g10/keydb.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> @@ -861,7 +860,7 @@ keydb_new (void) hd->saved_found = -1; hd->is_reset = 1; - assert (used_resources <= MAX_KEYDB_RESOURCES); + log_assert (used_resources <= MAX_KEYDB_RESOURCES); for (i=j=0; ! die && i < used_resources; i++) { switch (all_resources[i].type) @@ -919,7 +918,7 @@ keydb_release (KEYDB_HANDLE hd) if (!hd) return; - assert (active_handles > 0); + log_assert (active_handles > 0); active_handles--; unlock_all (hd); @@ -1521,8 +1520,8 @@ keydb_update_keyblock (KEYDB_HANDLE hd, kbnode_t kb) KEYDB_SEARCH_DESC desc; size_t len; - assert (kb); - assert (kb->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (kb); + log_assert (kb->pkt->pkttype == PKT_PUBLIC_KEY); pk = kb->pkt->pkt.public_key; if (!hd) @@ -1549,7 +1548,7 @@ keydb_update_keyblock (KEYDB_HANDLE hd, kbnode_t kb) err = keydb_search (hd, &desc, 1, NULL); if (err) return gpg_error (GPG_ERR_VALUE_NOT_FOUND); - assert (hd->found >= 0 && hd->found < hd->used); + log_assert (hd->found >= 0 && hd->found < hd->used); switch (hd->active[hd->found].type) { diff --git a/g10/keyedit.c b/g10/keyedit.c index 84f04318e..3fa3a2c8a 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -24,7 +24,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include <ctype.h> #ifdef HAVE_LIBREADLINE # define GNUPG_LIBREADLINE_H_INCLUDED @@ -339,8 +338,8 @@ sig_comparison (const void *av, const void *bv) int ndatab; int i; - assert (an->pkt->pkttype == PKT_SIGNATURE); - assert (bn->pkt->pkttype == PKT_SIGNATURE); + log_assert (an->pkt->pkttype == PKT_SIGNATURE); + log_assert (bn->pkt->pkttype == PKT_SIGNATURE); a = an->pkt->pkt.signature; b = bn->pkt->pkt.signature; @@ -352,7 +351,7 @@ sig_comparison (const void *av, const void *bv) ndataa = pubkey_get_nsig (a->pubkey_algo); ndatab = pubkey_get_nsig (a->pubkey_algo); - assert (ndataa == ndatab); + log_assert (ndataa == ndatab); for (i = 0; i < ndataa; i ++) { @@ -399,7 +398,7 @@ check_all_keysigs (KBNODE kb, int only_selected, int only_selfsigs) int missing_selfsig = 0; int modified = 0; - assert (kb->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (kb->pkt->pkttype == PKT_PUBLIC_KEY); pk = kb->pkt->pkt.public_key; /* First we look for duplicates. */ @@ -431,17 +430,17 @@ check_all_keysigs (KBNODE kb, int only_selected, int only_selfsigs) sigs[i] = n; i ++; } - assert (i == nsigs); + log_assert (i == nsigs); qsort (sigs, nsigs, sizeof (sigs[0]), sig_comparison); last_i = 0; for (i = 1; i < nsigs; i ++) { - assert (sigs[last_i]); - assert (sigs[last_i]->pkt->pkttype == PKT_SIGNATURE); - assert (sigs[i]); - assert (sigs[i]->pkt->pkttype == PKT_SIGNATURE); + log_assert (sigs[last_i]); + log_assert (sigs[last_i]->pkt->pkttype == PKT_SIGNATURE); + log_assert (sigs[i]); + log_assert (sigs[i]->pkt->pkttype == PKT_SIGNATURE); if (sig_comparison (&sigs[last_i], &sigs[i]) == 0) /* They are the same. Kill the latter. */ @@ -519,7 +518,7 @@ check_all_keysigs (KBNODE kb, int only_selected, int only_selfsigs) switch (p->pkttype) { case PKT_PUBLIC_KEY: - assert (p->pkt.public_key == pk); + log_assert (p->pkt.public_key == pk); if (only_selected && ! (n->flag & NODFLG_SELKEY)) { current_component = NULL; @@ -658,9 +657,9 @@ check_all_keysigs (KBNODE kb, int only_selected, int only_selfsigs) } else if (n2) { - assert (n2->pkt->pkttype == PKT_USER_ID - || n2->pkt->pkttype == PKT_PUBLIC_KEY - || n2->pkt->pkttype == PKT_PUBLIC_SUBKEY); + log_assert (n2->pkt->pkttype == PKT_USER_ID + || n2->pkt->pkttype == PKT_PUBLIC_KEY + || n2->pkt->pkttype == PKT_PUBLIC_SUBKEY); if (DBG_PACKET) { @@ -681,7 +680,7 @@ check_all_keysigs (KBNODE kb, int only_selected, int only_selfsigs) after n2. */ /* Unlink the signature. */ - assert (n_prevp); + log_assert (n_prevp); *n_prevp = n->next; /* Insert the sig immediately after the component. */ @@ -1577,7 +1576,7 @@ sign_uids (ctrl_t ctrl, estream_t fp, PKT_signature *sig; struct sign_attrib attrib; - assert (primary_pk); + log_assert (primary_pk); memset (&attrib, 0, sizeof attrib); attrib.non_exportable = local; attrib.non_revocable = nonrevocable; @@ -2639,7 +2638,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, case cmdPREF: { int count = count_selected_uids (keyblock); - assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY); show_names (NULL, keyblock, keyblock->pkt->pkt.public_key, count ? NODFLG_SELUID : 0, 1); } @@ -2648,7 +2647,7 @@ keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr, case cmdSHOWPREF: { int count = count_selected_uids (keyblock); - assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY); show_names (NULL, keyblock, keyblock->pkt->pkt.public_key, count ? NODFLG_SELUID : 0, 2); } @@ -4052,7 +4051,7 @@ menu_adduid (kbnode_t pub_keyblock, int photo, const char *photo_name, } if (!node) /* No subkey. */ pub_where = NULL; - assert (pk); + log_assert (pk); if (photo) { @@ -4349,7 +4348,7 @@ menu_addrevoker (ctrl_t ctrl, kbnode_t pub_keyblock, int sensitive) size_t fprlen; int rc; - assert (pub_keyblock->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (pub_keyblock->pkt->pkttype == PKT_PUBLIC_KEY); pk = pub_keyblock->pkt->pkt.public_key; @@ -4736,7 +4735,7 @@ menu_backsign (KBNODE pub_keyblock) KBNODE node; u32 timestamp; - assert (pub_keyblock->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (pub_keyblock->pkt->pkttype == PKT_PUBLIC_KEY); merge_keys_and_selfsig (pub_keyblock); main_pk = pub_keyblock->pkt->pkt.public_key; @@ -5485,7 +5484,7 @@ menu_select_uid_namehash (KBNODE keyblock, const char *namehash) KBNODE node; int i; - assert (strlen (namehash) == NAMEHASH_LEN * 2); + log_assert (strlen (namehash) == NAMEHASH_LEN * 2); for (i = 0; i < NAMEHASH_LEN; i++) hash[i] = hextobyte (&namehash[i * 2]); @@ -5819,7 +5818,7 @@ menu_revsig (KBNODE keyblock) int rc, any, skip = 1, all = !count_selected_uids (keyblock); struct revocation_reason_info *reason = NULL; - assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (keyblock->pkt->pkttype == PKT_PUBLIC_KEY); /* First check whether we have any signatures at all. */ any = 0; @@ -5960,7 +5959,7 @@ reloop: /* (must use this, because we are modifing the list) */ || node->pkt->pkttype != PKT_SIGNATURE) continue; unode = find_prev_kbnode (keyblock, node, PKT_USER_ID); - assert (unode); /* we already checked this */ + log_assert (unode); /* we already checked this */ memset (&attrib, 0, sizeof attrib); attrib.reason = reason; diff --git a/g10/keygen.c b/g10/keygen.c index 06710eb4b..f9cbf21a8 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -24,7 +24,6 @@ #include <string.h> #include <ctype.h> #include <errno.h> -#include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> @@ -1371,7 +1370,7 @@ gen_elg (int algo, unsigned int nbits, KBNODE pub_root, char *keyparms; char nbitsstr[35]; - assert (is_ELGAMAL (algo)); + log_assert (is_ELGAMAL (algo)); if (nbits < 1024) { @@ -1513,9 +1512,9 @@ gen_ecc (int algo, const char *curve, kbnode_t pub_root, gpg_error_t err; char *keyparms; - assert (algo == PUBKEY_ALGO_ECDSA - || algo == PUBKEY_ALGO_EDDSA - || algo == PUBKEY_ALGO_ECDH); + log_assert (algo == PUBKEY_ALGO_ECDSA + || algo == PUBKEY_ALGO_EDDSA + || algo == PUBKEY_ALGO_ECDH); if (!curve || !*curve) return gpg_error (GPG_ERR_UNKNOWN_CURVE); @@ -1571,7 +1570,7 @@ gen_rsa (int algo, unsigned int nbits, KBNODE pub_root, char nbitsstr[35]; const unsigned maxsize = (opt.flags.large_rsa ? 8192 : 4096); - assert (is_RSA(algo)); + log_assert (is_RSA(algo)); if (!nbits) nbits = DEFAULT_STD_KEYSIZE; @@ -2794,7 +2793,7 @@ generate_user_id (KBNODE keyblock, const char *uidstr) static void append_to_parameter (struct para_data_s *para, struct para_data_s *r) { - assert (para); + log_assert (para); while (para->next) para = para->next; para->next = r; @@ -4034,7 +4033,7 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para, push_armor_filter (outctrl->pub.afx, outctrl->pub.stream); } } - assert( outctrl->pub.stream ); + log_assert( outctrl->pub.stream ); if (opt.verbose) log_info (_("writing public key to '%s'\n"), outctrl->pub.fname ); } @@ -4079,7 +4078,7 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para, if (!err) { pri_psk = pub_root->next->pkt->pkt.public_key; - assert (pri_psk); + log_assert (pri_psk); /* Make sure a few fields are correctly set up before going further. */ @@ -4141,7 +4140,7 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para, for (node = pub_root; node; node = node->next) if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY) sub_psk = node->pkt->pkt.public_key; - assert (sub_psk); + log_assert (sub_psk); if (s) err = card_store_key_with_backup (ctrl, sub_psk, opt.homedir); @@ -4327,7 +4326,7 @@ generate_subkeypair (ctrl_t ctrl, kbnode_t keyblock) xfree (hexgrip); hexgrip = NULL; algo = ask_algo (ctrl, 1, NULL, &use, &hexgrip); - assert (algo); + log_assert (algo); if (hexgrip) nbits = 0; @@ -4392,7 +4391,7 @@ generate_card_subkeypair (kbnode_t pub_keyblock, u32 cur_time; struct para_data_s *para = NULL; - assert (keyno >= 1 && keyno <= 3); + log_assert (keyno >= 1 && keyno <= 3); para = xtrycalloc (1, sizeof *para + strlen (serialno) ); if (!para) @@ -4462,7 +4461,7 @@ generate_card_subkeypair (kbnode_t pub_keyblock, for (node = pub_keyblock; node; node = node->next) if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY) sub_pk = node->pkt->pkt.public_key; - assert (sub_pk); + log_assert (sub_pk); err = write_keybinding (pub_keyblock, pri_pk, sub_pk, use, cur_time, NULL); } diff --git a/g10/keyid.c b/g10/keyid.c index f2a5e0357..bd808d21e 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -26,7 +26,6 @@ #include <string.h> #include <errno.h> #include <time.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -767,7 +766,7 @@ fingerprint_from_pk (PKT_public_key *pk, byte *array, size_t *ret_len) md = do_fingerprint_md(pk); dp = gcry_md_read( md, 0 ); len = gcry_md_get_algo_dlen (gcry_md_get_algo (md)); - assert( len <= MAX_FINGERPRINT_LEN ); + log_assert( len <= MAX_FINGERPRINT_LEN ); if (!array) array = xmalloc ( len ); memcpy (array, dp, len ); @@ -849,7 +848,7 @@ format_hexfingerprint (const char *fingerprint, char *buffer, size_t buflen) buffer[j ++] = fingerprint[i]; } buffer[j ++] = 0; - assert (j == space); + log_assert (j == space); } else { diff --git a/g10/keylist.c b/g10/keylist.c index 0812d9c9b..1649991c7 100644 --- a/g10/keylist.c +++ b/g10/keylist.c @@ -24,9 +24,8 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #ifdef HAVE_DOSISH_SYSTEM -#include <fcntl.h> /* for setmode() */ +# include <fcntl.h> /* for setmode() */ #endif #include "gpg.h" @@ -799,7 +798,7 @@ print_subpackets_colon (PKT_signature * sig) { byte *i; - assert (opt.show_subpackets); + log_assert (opt.show_subpackets); for (i = opt.show_subpackets; *i; i++) { @@ -1788,9 +1787,9 @@ do_reorder_keyblock (KBNODE keyblock, int attr) if (node->pkt->pkttype == PKT_USER_ID) break; } - assert (node); - assert (last); /* The user ID is never the first packet. */ - assert (primary0); /* Ditto (this is the node before primary). */ + log_assert (node); + log_assert (last); /* The user ID is never the first packet. */ + log_assert (primary0); /* Ditto (this is the node before primary). */ if (node == primary) return; /* Already the first one. */ diff --git a/g10/keyring.c b/g10/keyring.c index ee079a95f..843975eaf 100644 --- a/g10/keyring.c +++ b/g10/keyring.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> @@ -243,7 +242,7 @@ keyring_new (void *token) KEYRING_HANDLE hd; KR_RESOURCE resource = token; - assert (resource); + log_assert (resource); hd = xtrycalloc (1, sizeof *hd); if (!hd) @@ -258,7 +257,7 @@ keyring_release (KEYRING_HANDLE hd) { if (!hd) return; - assert (active_handles > 0); + log_assert (active_handles > 0); active_handles--; xfree (hd->word_match.name); xfree (hd->word_match.pattern); @@ -691,7 +690,7 @@ keyring_delete_keyblock (KEYRING_HANDLE hd) int keyring_search_reset (KEYRING_HANDLE hd) { - assert (hd); + log_assert (hd); hd->current.kr = NULL; iobuf_close (hd->current.iobuf); @@ -752,7 +751,7 @@ prepare_search (KEYRING_HANDLE hd) hd->current.eof = 1; return -1; /* keyring not available */ } - assert (!hd->current.iobuf); + log_assert (!hd->current.iobuf); } else { /* EOF */ if (DBG_LOOKUP) @@ -1084,7 +1083,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc, if (desc[n].mode == KEYDB_SEARCH_MODE_WORDS) name = desc[n].u.name; } - assert (name); + log_assert (name); if ( !hd->word_match.name || strcmp (hd->word_match.name, name) ) { /* name changed */ @@ -1713,7 +1712,7 @@ do_copy (int mode, const char *fname, KBNODE root, goto leave; } /* skip this keyblock */ - assert( n_packets ); + log_assert( n_packets ); rc = skip_some_packets( fp, n_packets ); if( rc ) { log_error("%s: skipping %u packets failed: %s\n", diff --git a/g10/keyserver.c b/g10/keyserver.c index 95ef441ef..3486abb51 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -24,7 +24,6 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> -#include <assert.h> #include <errno.h> #include "gpg.h" @@ -243,7 +242,7 @@ parse_keyserver_uri (const char *string,int require_scheme) int count; char *uri,*options; - assert(string!=NULL); + log_assert (string); keyserver=xmalloc_clear(sizeof(struct keyserver_spec)); diff --git a/g10/mainproc.c b/g10/mainproc.c index 5e6b40b3b..d56790bcd 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include <time.h> #include "gpg.h" @@ -855,7 +854,7 @@ do_check_sig (CTX c, kbnode_t node, int *is_selfsig, gcry_md_hd_t md_good = NULL; int algo, rc; - assert (node->pkt->pkttype == PKT_SIGNATURE); + log_assert (node->pkt->pkttype == PKT_SIGNATURE); if (is_selfsig) *is_selfsig = 0; sig = node->pkt->pkt.signature; @@ -1523,7 +1522,7 @@ pka_uri_from_sig (CTX c, PKT_signature *sig) { if (!sig->flags.pka_tried) { - assert (!sig->pka_info); + log_assert (!sig->pka_info); sig->flags.pka_tried = 1; sig->pka_info = get_pka_address (sig); if (sig->pka_info) @@ -1637,7 +1636,7 @@ check_sig_and_print (CTX c, kbnode_t node) /* dump_kbnode (c->list); */ n = c->list; - assert (n); + log_assert (n); if ( n->pkt->pkttype == PKT_SIGNATURE ) { /* This is either "S{1,n}" case (detached signature) or @@ -1864,7 +1863,7 @@ check_sig_and_print (CTX c, kbnode_t node) if (un->pkt->pkt.user_id->attrib_data) continue; - assert (pk); + log_assert (pk); /* Since this is just informational, don't actually ask the user to update any trust information. (Note: we register diff --git a/g10/mdfilter.c b/g10/mdfilter.c index 88b2ee18d..0dbbc3c36 100644 --- a/g10/mdfilter.c +++ b/g10/mdfilter.c @@ -22,7 +22,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "status.h" diff --git a/g10/migrate.c b/g10/migrate.c index 48cbdd08f..f4881b420 100644 --- a/g10/migrate.c +++ b/g10/migrate.c @@ -23,7 +23,6 @@ #include <string.h> #include <errno.h> #include <unistd.h> -#include <assert.h> #include "gpg.h" #include "options.h" diff --git a/g10/misc.c b/g10/misc.c index bdc450575..d2537cf7a 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -69,8 +69,6 @@ #include "i18n.h" #include "zb32.h" -#include <assert.h> - #ifdef ENABLE_SELINUX_HACKS /* A object and a global variable to keep track of files marked as diff --git a/g10/openfile.c b/g10/openfile.c index 859090e8f..006ff35cd 100644 --- a/g10/openfile.c +++ b/g10/openfile.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> diff --git a/g10/parse-packet.c b/g10/parse-packet.c index 3407848bc..c77e409e5 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -24,7 +24,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -487,7 +486,7 @@ parse (IOBUF inp, PACKET * pkt, int onlykeypkts, off_t * retpos, off_t pos; *skip = 0; - assert (!pkt->pkt.generic); + log_assert (!pkt->pkt.generic); if (retpos || list_mode) { pos = iobuf_tell (inp); @@ -1114,7 +1113,7 @@ parse_symkeyenc (IOBUF inp, int pkttype, unsigned long pktlen, log_info (_("WARNING: potentially insecure symmetrically" " encrypted session key\n")); } - assert (!pktlen); + log_assert (!pktlen); if (list_mode) { @@ -2421,7 +2420,7 @@ parse_key (IOBUF inp, int pkttype, unsigned long pktlen, * NOTE: if you change the ivlen above 16, don't forget to * enlarge temp. */ ski->ivlen = openpgp_cipher_blocklen (ski->algo); - assert (ski->ivlen <= sizeof (temp)); + log_assert (ski->ivlen <= sizeof (temp)); if (ski->s2k.mode == 1001) ski->ivlen = 0; @@ -2660,7 +2659,7 @@ parse_user_id (IOBUF inp, int pkttype, unsigned long pktlen, PACKET * packet) void make_attribute_uidname (PKT_user_id * uid, size_t max_namelen) { - assert (max_namelen > 70); + log_assert (max_namelen > 70); if (uid->numattribs <= 0) sprintf (uid->name, "[bad attribute packet of size %lu]", uid->attrib_len); diff --git a/g10/passphrase.c b/g10/passphrase.c index 5eb2562b0..b1d1a05f0 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -24,7 +24,6 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <assert.h> #include <errno.h> #ifdef HAVE_LOCALE_H #include <locale.h> @@ -425,7 +424,7 @@ passphrase_to_dek_ext (u32 *keyid, int pubkey_algo, if ( !s2k ) { - assert (mode != 3 && mode != 4); + log_assert (mode != 3 && mode != 4); /* This is used for the old rfc1991 mode * Note: This must match the code in encode.c with opt.rfc1991 set */ s2k = &help_s2k; diff --git a/g10/pkclist.c b/g10/pkclist.c index d9ada5940..b659cb861 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "options.h" diff --git a/g10/pkglue.c b/g10/pkglue.c index c8a5d24d1..232c489f7 100644 --- a/g10/pkglue.c +++ b/g10/pkglue.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -40,9 +39,9 @@ get_mpi_from_sexp (gcry_sexp_t sexp, const char *item, int mpifmt) gcry_mpi_t data; list = gcry_sexp_find_token (sexp, item, 0); - assert (list); + log_assert (list); data = gcry_sexp_nth_mpi (list, 1, mpifmt); - assert (data); + log_assert (data); gcry_sexp_release (list); return data; } diff --git a/g10/plaintext.c b/g10/plaintext.c index 94ede07ef..e118f6b4d 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include <sys/types.h> #ifdef HAVE_DOSISH_SYSTEM # include <fcntl.h> /* for setmode() */ @@ -636,7 +635,7 @@ ask_for_detached_datafile (gcry_md_hd_t md, gcry_md_hd_t md2, if (opt.verbose) log_info (_("reading stdin ...\n")); fp = iobuf_open (NULL); - assert (fp); + log_assert (fp); } do_hash (md, md2, fp, textmode); iobuf_close (fp); diff --git a/g10/progress.c b/g10/progress.c index f4b46989b..21810a45b 100644 --- a/g10/progress.c +++ b/g10/progress.c @@ -19,7 +19,6 @@ #include <config.h> #include <stdio.h> -#include <assert.h> #include "gpg.h" #include "iobuf.h" @@ -64,7 +63,7 @@ release_progress_context (progress_filter_context_t *pfx) { if (!pfx) return; - assert (pfx->refcount); + log_assert (pfx->refcount); if ( --pfx->refcount ) return; xfree (pfx->what); @@ -143,8 +142,8 @@ handle_progress (progress_filter_context_t *pfx, IOBUF inp, const char *name) if (!pfx) return; - assert (opt.enable_progress_filter); - assert (is_status_enabled ()); + log_assert (opt.enable_progress_filter); + log_assert (is_status_enabled ()); if ( !iobuf_is_pipe_filename (name) && *name ) filesize = iobuf_get_filelength (inp, NULL); diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c index 23a447315..0df9bfac2 100644 --- a/g10/pubkey-enc.c +++ b/g10/pubkey-enc.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -197,7 +196,7 @@ get_it (PKT_pubkey_enc *enc, DEK *dek, PKT_public_key *sk, u32 *keyid) if (sk->pubkey_algo == PUBKEY_ALGO_ECDH) { fingerprint_from_pk (sk, fp, &fpn); - assert (fpn == 20); + log_assert (fpn == 20); } /* Decrypt. */ @@ -267,7 +266,7 @@ get_it (PKT_pubkey_enc *enc, DEK *dek, PKT_public_key *sk, u32 *keyid) goto leave; } nframe -= frame[nframe-1]; /* Remove padding. */ - assert (!n); /* (used just below) */ + log_assert (!n); /* (used just below) */ } else { diff --git a/g10/revoke.c b/g10/revoke.c index a8f765856..3c6e158fe 100644 --- a/g10/revoke.c +++ b/g10/revoke.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include <ctype.h> #include "gpg.h" diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c index 02dbb4859..f61d21bbe 100644 --- a/g10/seckey-cert.c +++ b/g10/seckey-cert.c @@ -24,7 +24,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "util.h" diff --git a/g10/seskey.c b/g10/seskey.c index 561118aa4..c41a1455b 100644 --- a/g10/seskey.c +++ b/g10/seskey.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -106,7 +105,7 @@ encode_session_key (int openpgp_pk_algo, DEK *dek, unsigned int nbits) + 7 ) & (~7)); /* alg+key+csum fit and the size is congruent to 8. */ - assert (!(nframe%8) && nframe > 1 + dek->keylen + 2 ); + log_assert (!(nframe%8) && nframe > 1 + dek->keylen + 2 ); frame = xmalloc_secure (nframe); n = 0; @@ -117,7 +116,7 @@ encode_session_key (int openpgp_pk_algo, DEK *dek, unsigned int nbits) frame[n++] = csum; i = nframe - n; /* Number of padded bytes. */ memset (frame+n, i, i); /* Use it as the value of each padded byte. */ - assert (n+i == nframe); + log_assert (n+i == nframe); if (DBG_CRYPTO) log_debug ("encode_session_key: " @@ -161,7 +160,7 @@ encode_session_key (int openpgp_pk_algo, DEK *dek, unsigned int nbits) /* The number of random bytes are the number of otherwise unused bytes. See diagram above. */ i = nframe - 6 - dek->keylen; - assert( i > 0 ); + log_assert( i > 0 ); p = gcry_random_bytes_secure (i, GCRY_STRONG_RANDOM); /* Replace zero bytes by new values. */ for (;;) @@ -195,7 +194,7 @@ encode_session_key (int openpgp_pk_algo, DEK *dek, unsigned int nbits) n += dek->keylen; frame[n++] = csum >>8; frame[n++] = csum; - assert (n == nframe); + log_assert (n == nframe); if (gcry_mpi_scan( &a, GCRYMPI_FMT_USG, frame, n, &nframe)) BUG(); xfree (frame); @@ -227,12 +226,12 @@ do_encode_md( gcry_md_hd_t md, int algo, size_t len, unsigned nbits, frame[n++] = 0; frame[n++] = 1; /* block type */ i = nframe - len - asnlen -3 ; - assert( i > 1 ); + log_assert( i > 1 ); memset( frame+n, 0xff, i ); n += i; frame[n++] = 0; memcpy( frame+n, asn, asnlen ); n += asnlen; memcpy( frame+n, gcry_md_read (md, algo), len ); n += len; - assert( n == nframe ); + log_assert( n == nframe ); if (gcry_mpi_scan( &a, GCRYMPI_FMT_USG, frame, n, &nframe )) BUG(); @@ -263,8 +262,8 @@ encode_md_value (PKT_public_key *pk, gcry_md_hd_t md, int hash_algo) gcry_mpi_t frame; size_t mdlen; - assert (hash_algo); - assert (pk); + log_assert (hash_algo); + log_assert (pk); if (pk->pubkey_algo == PUBKEY_ALGO_EDDSA) { diff --git a/g10/sig-check.c b/g10/sig-check.c index ee0ebcb2b..290f19a79 100644 --- a/g10/sig-check.c +++ b/g10/sig-check.c @@ -23,7 +23,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -563,8 +562,8 @@ check_revocation_keys (PKT_public_key *pk, PKT_signature *sig) int i; int rc = GPG_ERR_GENERAL; - assert(IS_KEY_REV(sig)); - assert((sig->keyid[0]!=pk->keyid[0]) || (sig->keyid[0]!=pk->keyid[1])); + log_assert (IS_KEY_REV(sig)); + log_assert ((sig->keyid[0]!=pk->keyid[0]) || (sig->keyid[0]!=pk->keyid[1])); /* Avoid infinite recursion. Consider the following: * @@ -857,14 +856,14 @@ check_signature_over_key_or_uid (PKT_public_key *signer, /* Primary key revocation. */ || sig->sig_class == 0x20) { - assert (packet->pkttype == PKT_PUBLIC_KEY); + log_assert (packet->pkttype == PKT_PUBLIC_KEY); hash_public_key (md, packet->pkt.public_key); rc = check_signature_end_simple (signer, sig, md); } else if (/* Primary key binding (made by a subkey). */ sig->sig_class == 0x19) { - assert (packet->pkttype == PKT_PUBLIC_KEY); + log_assert (packet->pkttype == PKT_PUBLIC_KEY); hash_public_key (md, packet->pkt.public_key); hash_public_key (md, signer); rc = check_signature_end_simple (signer, sig, md); @@ -874,7 +873,7 @@ check_signature_over_key_or_uid (PKT_public_key *signer, /* Subkey revocation. */ || sig->sig_class == 0x28) { - assert (packet->pkttype == PKT_PUBLIC_SUBKEY); + log_assert (packet->pkttype == PKT_PUBLIC_SUBKEY); hash_public_key (md, pripk); hash_public_key (md, packet->pkt.public_key); rc = check_signature_end_simple (signer, sig, md); @@ -887,7 +886,7 @@ check_signature_over_key_or_uid (PKT_public_key *signer, /* Certification revocation. */ || sig->sig_class == 0x30) { - assert (packet->pkttype == PKT_USER_ID); + log_assert (packet->pkttype == PKT_USER_ID); hash_public_key (md, pripk); hash_uid_packet (packet->pkt.user_id, md, sig); rc = check_signature_end_simple (signer, sig, md); @@ -964,8 +963,8 @@ check_key_signature2 (kbnode_t root, kbnode_t node, PKT_public_key *check_pk, *r_expiredate = 0; if (r_expired) *r_expired = 0; - assert (node->pkt->pkttype == PKT_SIGNATURE); - assert (root->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (node->pkt->pkttype == PKT_SIGNATURE); + log_assert (root->pkt->pkttype == PKT_PUBLIC_KEY); pk = root->pkt->pkt.public_key; sig = node->pkt->pkt.signature; diff --git a/g10/sign.c b/g10/sign.c index c3ae028ea..364634adc 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "options.h" @@ -66,7 +65,7 @@ mk_notation_policy_etc (PKT_signature *sig, struct notation *nd=NULL; struct expando_args args; - assert(sig->version>=4); + log_assert(sig->version>=4); memset(&args,0,sizeof(args)); args.pk=pk; @@ -1143,7 +1142,7 @@ clearsign_file (ctrl_t ctrl, } } } - assert(any); + log_assert(any); iobuf_writestr(out, LF ); } @@ -1377,9 +1376,9 @@ make_keysig_packet (PKT_signature **ret_sig, PKT_public_key *pk, int sigversion; gcry_md_hd_t md; - assert( (sigclass >= 0x10 && sigclass <= 0x13) || sigclass == 0x1F - || sigclass == 0x20 || sigclass == 0x18 || sigclass == 0x19 - || sigclass == 0x30 || sigclass == 0x28 ); + log_assert ((sigclass >= 0x10 && sigclass <= 0x13) || sigclass == 0x1F + || sigclass == 0x20 || sigclass == 0x18 || sigclass == 0x19 + || sigclass == 0x30 || sigclass == 0x28 ); sigversion = 4; if (sigversion < pksk->version) diff --git a/g10/skclist.c b/g10/skclist.c index 1eb0633fd..4cd7f332e 100644 --- a/g10/skclist.c +++ b/g10/skclist.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "options.h" diff --git a/g10/sqlite.c b/g10/sqlite.c index 599a3ef5d..90490c297 100644 --- a/g10/sqlite.c +++ b/g10/sqlite.c @@ -21,7 +21,6 @@ #include <stdarg.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "util.h" @@ -88,7 +87,7 @@ sqlite3_stepx (sqlite3 *db, stmt = *stmtp; /* Make sure this statement is associated with the supplied db. */ - assert (db == sqlite3_db_handle (stmt)); + log_assert (db == sqlite3_db_handle (stmt)); #if DEBUG_TOFU_CACHE prepares_saved ++; @@ -171,7 +170,7 @@ sqlite3_stepx (sqlite3 *db, } t = va_arg (va, enum sqlite_arg_type); - assert (t == SQLITE_ARG_END); + log_assert (t == SQLITE_ARG_END); va_end (va); for (;;) diff --git a/g10/tdbdump.c b/g10/tdbdump.c index 893c9820a..4c3d7a874 100644 --- a/g10/tdbdump.c +++ b/g10/tdbdump.c @@ -23,7 +23,6 @@ #include <string.h> #include <errno.h> #include <ctype.h> -#include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> diff --git a/g10/tdbio.c b/g10/tdbio.c index 79e1e8323..5fdd94619 100644 --- a/g10/tdbio.c +++ b/g10/tdbio.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -317,7 +316,7 @@ put_record_into_cache (ulong recno, const char *data) } /* Now put into the cache. */ - assert (unused); + log_assert (unused); r = unused; r->flags.used = 1; r->recno = recno; @@ -383,7 +382,7 @@ put_record_into_cache (ulong recno, const char *data) release_write_lock (); /* Now put into the cache. */ - assert (unused); + log_assert (unused); r = unused; r->flags.used = 1; r->recno = recno; @@ -666,7 +665,7 @@ tdbio_set_dbname (const char *new_dbname, int create, int *r_nofile) p = pp; } #endif /*HAVE_W32_SYSTEM*/ - assert (p); + log_assert (p); save_slash = *p; *p = 0; if (access (fname, F_OK)) @@ -751,7 +750,7 @@ open_db () { TRUSTREC rec; - assert( db_fd == -1 ); + log_assert( db_fd == -1 ); #ifdef HAVE_W32CE_SYSTEM { @@ -811,7 +810,7 @@ create_hashtable( TRUSTREC *vr, int type ) if (offset == -1) log_fatal ("trustdb: lseek to end failed: %s\n", strerror(errno)); recnum = offset / TRUST_RECORD_LEN; - assert (recnum); /* This is will never be the first record. */ + log_assert (recnum); /* This is will never be the first record. */ if (!type) vr->r.ver.trusthashtbl = recnum; @@ -1770,7 +1769,7 @@ tdbio_new_recnum () if (offset == (off_t)(-1)) log_fatal ("trustdb: lseek to end failed: %s\n", strerror (errno)); recnum = offset / TRUST_RECORD_LEN; - assert (recnum); /* this is will never be the first record */ + log_assert (recnum); /* this is will never be the first record */ /* We must write a record, so that the next call to this * function returns another recnum. */ memset (&rec, 0, sizeof rec); diff --git a/g10/textfilter.c b/g10/textfilter.c index da303c4cc..5929c5f46 100644 --- a/g10/textfilter.c +++ b/g10/textfilter.c @@ -22,7 +22,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "status.h" @@ -70,7 +69,7 @@ standard( text_filter_context_t *tfx, IOBUF a, size_t len = 0; unsigned maxlen; - assert( size > 10 ); + log_assert( size > 10 ); size -= 2; /* reserve 2 bytes to append CR,LF */ while( !rc && len < size ) { int lf_seen; diff --git a/g10/tofu.c b/g10/tofu.c index 5f381b08e..a24c52ee6 100644 --- a/g10/tofu.c +++ b/g10/tofu.c @@ -26,7 +26,6 @@ #include <config.h> #include <stdio.h> #include <sys/stat.h> -#include <assert.h> #include <stdarg.h> #include <sqlite3.h> @@ -388,7 +387,7 @@ tofu_begin_batch_update (void) void tofu_end_batch_update (void) { - assert (batch_update > 0); + log_assert (batch_update > 0); batch_update --; if (batch_update == 0) @@ -411,7 +410,7 @@ get_single_unsigned_long_cb (void *cookie, int argc, char **argv, (void) azColName; - assert (argc == 1); + log_assert (argc == 1); errno = 0; *count = strtoul (argv[0], &tail, 0); @@ -682,16 +681,16 @@ opendb (char *filename, enum db_type type) if (opt.tofu_db_format == TOFU_DB_FLAT) { - assert (! filename); - assert (type == DB_COMBINED); + log_assert (! filename); + log_assert (type == DB_COMBINED); filename = make_filename (opt.homedir, "tofu.db", NULL); filename_free = 1; } else - assert (type == DB_EMAIL || type == DB_KEY); + log_assert (type == DB_EMAIL || type == DB_KEY); - assert (filename); + log_assert (filename); rc = sqlite3_open (filename, &db); if (rc) @@ -762,9 +761,9 @@ getdb (struct dbs *dbs, const char *name, enum db_type type) sqlite3 *sqlitedb = NULL; gpg_error_t rc; - assert (dbs); - assert (name); - assert (type == DB_EMAIL || type == DB_KEY); + log_assert (dbs); + log_assert (name); + log_assert (type == DB_EMAIL || type == DB_KEY); if (opt.tofu_db_format == TOFU_DB_FLAT) /* When using the flat format, we only have a single DB, the @@ -772,8 +771,8 @@ getdb (struct dbs *dbs, const char *name, enum db_type type) { if (dbs->db) { - assert (dbs->db->type == DB_COMBINED); - assert (! dbs->db->next); + log_assert (dbs->db->type == DB_COMBINED); + log_assert (! dbs->db->next); return dbs->db; } @@ -814,7 +813,7 @@ getdb (struct dbs *dbs, const char *name, enum db_type type) goto out; } - assert (db_cache_count == count); + log_assert (db_cache_count == count); if (type == DB_COMBINED) filename = NULL; @@ -883,18 +882,18 @@ closedb (struct db *db) if (opt.tofu_db_format == TOFU_DB_FLAT) /* If we are using the flat format, then there is only ever the combined DB. */ - assert (! db->next); + log_assert (! db->next); if (db->type == DB_COMBINED) { - assert (opt.tofu_db_format == TOFU_DB_FLAT); - assert (! db->name[0]); + log_assert (opt.tofu_db_format == TOFU_DB_FLAT); + log_assert (! db->name[0]); } else { - assert (opt.tofu_db_format == TOFU_DB_SPLIT); - assert (db->type != DB_COMBINED); - assert (db->name[0]); + log_assert (opt.tofu_db_format == TOFU_DB_SPLIT); + log_assert (db->type != DB_COMBINED); + log_assert (db->name[0]); } if (db->batch_update) @@ -1002,10 +1001,10 @@ closedbs (struct dbs *dbs) /* When we leave batch mode we leave batch mode on any cached connections. */ if (! batch_update) - assert (! db->batch_update); + log_assert (! db->batch_update); } if (! batch_update) - assert (! db->batch_update); + log_assert (! db->batch_update); /* Join the two lists. */ db->next = db_cache; @@ -1060,7 +1059,7 @@ get_single_long_cb (void *cookie, int argc, char **argv, char **azColName) (void) azColName; - assert (argc == 1); + log_assert (argc == 1); errno = 0; *count = strtol (argv[0], &tail, 0); @@ -1203,7 +1202,7 @@ record_binding (struct dbs *dbs, const char *fingerprint, const char *email, if (db_key) /* We also need to update the key DB. */ { - assert (opt.tofu_db_format == TOFU_DB_SPLIT); + log_assert (opt.tofu_db_format == TOFU_DB_SPLIT); rc = sqlite3_stepx (db_key->db, &db_key->s.record_binding_update2, NULL, NULL, &err, @@ -1228,7 +1227,7 @@ record_binding (struct dbs *dbs, const char *fingerprint, const char *email, } } else - assert (opt.tofu_db_format == TOFU_DB_FLAT); + log_assert (opt.tofu_db_format == TOFU_DB_FLAT); out: if (opt.tofu_db_format == TOFU_DB_SPLIT) @@ -1416,7 +1415,7 @@ signature_stats_collect_cb (void *cookie, int argc, char **argv, } i ++; - assert (argc == i); + log_assert (argc == i); signature_stats_prepend (statsp, argv[0], policy, time_ago, count); @@ -1531,13 +1530,13 @@ get_policy (struct dbs *dbs, const char *fingerprint, const char *email, } out: - assert (policy == _tofu_GET_POLICY_ERROR - || policy == TOFU_POLICY_NONE - || policy == TOFU_POLICY_AUTO - || policy == TOFU_POLICY_GOOD - || policy == TOFU_POLICY_UNKNOWN - || policy == TOFU_POLICY_BAD - || policy == TOFU_POLICY_ASK); + log_assert (policy == _tofu_GET_POLICY_ERROR + || policy == TOFU_POLICY_NONE + || policy == TOFU_POLICY_AUTO + || policy == TOFU_POLICY_GOOD + || policy == TOFU_POLICY_UNKNOWN + || policy == TOFU_POLICY_BAD + || policy == TOFU_POLICY_ASK); free_strlist (strlist); @@ -1576,13 +1575,13 @@ get_trust (struct dbs *dbs, const char *fingerprint, const char *email, /* Make sure _tofu_GET_TRUST_ERROR isn't equal to any of the trust levels. */ - assert (_tofu_GET_TRUST_ERROR != TRUST_UNKNOWN - && _tofu_GET_TRUST_ERROR != TRUST_EXPIRED - && _tofu_GET_TRUST_ERROR != TRUST_UNDEFINED - && _tofu_GET_TRUST_ERROR != TRUST_NEVER - && _tofu_GET_TRUST_ERROR != TRUST_MARGINAL - && _tofu_GET_TRUST_ERROR != TRUST_FULLY - && _tofu_GET_TRUST_ERROR != TRUST_ULTIMATE); + log_assert (_tofu_GET_TRUST_ERROR != TRUST_UNKNOWN + && _tofu_GET_TRUST_ERROR != TRUST_EXPIRED + && _tofu_GET_TRUST_ERROR != TRUST_UNDEFINED + && _tofu_GET_TRUST_ERROR != TRUST_NEVER + && _tofu_GET_TRUST_ERROR != TRUST_MARGINAL + && _tofu_GET_TRUST_ERROR != TRUST_FULLY + && _tofu_GET_TRUST_ERROR != TRUST_ULTIMATE); db = getdb (dbs, email, DB_EMAIL); if (! db) @@ -1740,7 +1739,7 @@ get_trust (struct dbs *dbs, const char *fingerprint, const char *email, { /* If we've seen this binding, then we've seen this email and policy couldn't possibly be TOFU_POLICY_NONE. */ - assert (policy == TOFU_POLICY_NONE); + log_assert (policy == TOFU_POLICY_NONE); if (DBG_TRUST) log_debug ("TOFU: New binding <%s, %s>, no conflict.\n", @@ -1772,7 +1771,7 @@ get_trust (struct dbs *dbs, const char *fingerprint, const char *email, there is a conflict. (If the policy was ask (cases #1 and #2) and we weren't allowed to ask, we'd have already exited). */ { - assert (policy == TOFU_POLICY_NONE); + log_assert (policy == TOFU_POLICY_NONE); if (record_binding (dbs, fingerprint, email, user_id, TOFU_POLICY_ASK, 0) != 0) @@ -1893,7 +1892,7 @@ get_trust (struct dbs *dbs, const char *fingerprint, const char *email, char *other_thing; enum tofu_policy other_policy; - assert (strlist_iter->next); + log_assert (strlist_iter->next); strlist_iter = strlist_iter->next; other_thing = strlist_iter->d; @@ -2353,7 +2352,7 @@ show_statistics (struct dbs *dbs, const char *fingerprint, signed long first_seen_ago; signed long most_recent_seen_ago; - assert (strlist_length (strlist) == 3); + log_assert (strlist_length (strlist) == 3); errno = 0; messages = strtol (strlist->d, &tail, 0); @@ -2656,7 +2655,7 @@ tofu_register (PKT_public_key *pk, const char *user_id, log_debug ("TOFU: Saving signature <%s, %s, %s>\n", fingerprint_pp, email, sig_digest); - assert (c == 0); + log_assert (c == 0); rc = sqlite3_stepx (db->db, &db->s.register_insert, NULL, NULL, &err, @@ -2720,20 +2719,20 @@ tofu_wot_trust_combine (int tofu_base, int wot_base) int wot = wot_base & TRUST_MASK; int upper = (tofu_base & ~TRUST_MASK) | (wot_base & ~TRUST_MASK); - assert (tofu == TRUST_UNKNOWN - || tofu == TRUST_EXPIRED - || tofu == TRUST_UNDEFINED - || tofu == TRUST_NEVER - || tofu == TRUST_MARGINAL - || tofu == TRUST_FULLY - || tofu == TRUST_ULTIMATE); - assert (wot == TRUST_UNKNOWN - || wot == TRUST_EXPIRED - || wot == TRUST_UNDEFINED - || wot == TRUST_NEVER - || wot == TRUST_MARGINAL - || wot == TRUST_FULLY - || wot == TRUST_ULTIMATE); + log_assert (tofu == TRUST_UNKNOWN + || tofu == TRUST_EXPIRED + || tofu == TRUST_UNDEFINED + || tofu == TRUST_NEVER + || tofu == TRUST_MARGINAL + || tofu == TRUST_FULLY + || tofu == TRUST_ULTIMATE); + log_assert (wot == TRUST_UNKNOWN + || wot == TRUST_EXPIRED + || wot == TRUST_UNDEFINED + || wot == TRUST_NEVER + || wot == TRUST_MARGINAL + || wot == TRUST_FULLY + || wot == TRUST_ULTIMATE); /* We first consider negative trust policys. These trump positive trust policies. */ @@ -2826,7 +2825,7 @@ tofu_set_policy (kbnode_t kb, enum tofu_policy policy) PKT_public_key *pk; char *fingerprint = NULL; - assert (kb->pkt->pkttype == PKT_PUBLIC_KEY); + log_assert (kb->pkt->pkttype == PKT_PUBLIC_KEY); pk = kb->pkt->pkt.public_key; dbs = opendbs (); @@ -2906,8 +2905,8 @@ tofu_get_policy (PKT_public_key *pk, PKT_user_id *user_id, char *email; /* Make sure PK is a primary key. */ - assert (pk->main_keyid[0] == pk->keyid[0] - && pk->main_keyid[1] == pk->keyid[1]); + log_assert (pk->main_keyid[0] == pk->keyid[0] + && pk->main_keyid[1] == pk->keyid[1]); dbs = opendbs (); if (! dbs) diff --git a/g10/trust.c b/g10/trust.c index f46aeeaeb..82de7cbc2 100644 --- a/g10/trust.c +++ b/g10/trust.c @@ -23,7 +23,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "gpg.h" #include "keydb.h" @@ -561,7 +560,7 @@ clean_sigs_from_uid (kbnode_t keyblock, kbnode_t uidnode, kbnode_t node; u32 keyid[2]; - assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY); + log_assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY); keyid_from_pk (keyblock->pkt->pkt.public_key, keyid); @@ -654,8 +653,8 @@ clean_uid_from_key (kbnode_t keyblock, kbnode_t uidnode, int noisy) PKT_user_id *uid = uidnode->pkt->pkt.user_id; int deleted = 0; - assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY); - assert (uidnode->pkt->pkttype==PKT_USER_ID); + log_assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY); + log_assert (uidnode->pkt->pkttype==PKT_USER_ID); /* Skip valid user IDs, compacted user IDs, and non-self-signed user IDs if --allow-non-selfsigned-uid is set. */ @@ -706,8 +705,8 @@ clean_one_uid (kbnode_t keyblock, kbnode_t uidnode, int noisy, int self_only, { int dummy = 0; - assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY); - assert (uidnode->pkt->pkttype==PKT_USER_ID); + log_assert (keyblock->pkt->pkttype==PKT_PUBLIC_KEY); + log_assert (uidnode->pkt->pkttype==PKT_USER_ID); if (!uids_cleaned) uids_cleaned = &dummy; diff --git a/g10/trustdb.c b/g10/trustdb.c index c7d09daa7..1bdc43085 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #ifndef DISABLE_REGEX #include <sys/types.h> @@ -1079,9 +1078,9 @@ tdb_get_validity_core (PKT_public_key *pk, PKT_user_id *uid, tofu_validity = TRUST_NEVER; else { - assert (tl == TRUST_MARGINAL - || tl == TRUST_FULLY - || tl == TRUST_ULTIMATE); + log_assert (tl == TRUST_MARGINAL + || tl == TRUST_FULLY + || tl == TRUST_ULTIMATE); if (tl > tofu_validity) /* XXX: We we really want the max? */ diff --git a/g10/verify.c b/g10/verify.c index 2efc89d05..5cd0bd7f4 100644 --- a/g10/verify.c +++ b/g10/verify.c @@ -23,7 +23,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "gpg.h" #include "options.h" |