aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-28 16:21:34 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-28 16:21:34 +0000
commitde30f210414a1f1f296c0cfb4406b171c1fc7b62 (patch)
tree570cc93d141bb7e250c4e73fafc53eba7d6e70bc /src
parent652e255add3511262060f3a13517716a72e3cb52 (diff)
downloadgnunet-de30f210414a1f1f296c0cfb4406b171c1fc7b62.tar.gz
gnunet-de30f210414a1f1f296c0cfb4406b171c1fc7b62.zip
generally use GNUNET_assert() instead of GNUNET_abort() to also log the error
Diffstat (limited to 'src')
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c6
-rw-r--r--src/cadet/test_cadet.c2
-rw-r--r--src/consensus/test_consensus_api.c2
-rw-r--r--src/core/test_core_api_mq.c4
-rw-r--r--src/include/gnunet_common.h8
-rw-r--r--src/mysql/mysql.c2
-rw-r--r--src/regex/gnunet-regex-profiler.c6
-rw-r--r--src/rps/gnunet-service-rps_sampler.c2
-rw-r--r--src/util/common_allocation.c6
-rw-r--r--src/util/common_logging.c4
-rw-r--r--src/util/crypto_random.c2
-rw-r--r--src/util/mq.c4
-rw-r--r--src/util/network.c2
-rw-r--r--src/util/os_installation.c4
-rw-r--r--src/util/scheduler.c4
-rw-r--r--src/util/test_mq_client.c2
16 files changed, 31 insertions, 29 deletions
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index 3d9db4d4c..bfb11fc7f 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -519,7 +519,7 @@ core_init (void *cls,
519 GNUNET_NO, /* For header-only out notification */ 519 GNUNET_NO, /* For header-only out notification */
520 core_handlers); /* Register these handlers */ 520 core_handlers); /* Register these handlers */
521 if (10 < i++) 521 if (10 < i++)
522 GNUNET_abort(); 522 GNUNET_assert (0);
523 } 523 }
524 GML_start (); 524 GML_start ();
525 return; 525 return;
@@ -1069,7 +1069,7 @@ fill_buf (struct CadetPeerQueue *queue, void *buf, size_t size, uint32_t *pid)
1069 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY: 1069 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY:
1070 /* This should be encapsulted */ 1070 /* This should be encapsulted */
1071 msg_size = 0; 1071 msg_size = 0;
1072 GNUNET_abort (); 1072 GNUNET_assert (0);
1073 break; 1073 break;
1074 default: 1074 default:
1075 GNUNET_break (0); 1075 GNUNET_break (0);
@@ -1340,7 +1340,7 @@ GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1340 GCC_2s (c), c, GC_f2s (fwd), GCP_2s (peer), size); 1340 GCC_2s (c), c, GC_f2s (fwd), GCP_2s (peer), size);
1341 1341
1342 if (error_level == GNUNET_ERROR_TYPE_ERROR) 1342 if (error_level == GNUNET_ERROR_TYPE_ERROR)
1343 GNUNET_abort (); 1343 GNUNET_assert (0);
1344 if (NULL == peer->connections) 1344 if (NULL == peer->connections)
1345 { 1345 {
1346 /* We are not connected to this peer, ignore request. */ 1346 /* We are not connected to this peer, ignore request. */
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index 432369bd2..4c8b3e354 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -599,7 +599,7 @@ data_callback (void *cls, struct GNUNET_CADET_Channel *channel,
599 break; 599 break;
600 default: 600 default:
601 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Client %li not valid.\n", client); 601 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Client %li not valid.\n", client);
602 GNUNET_abort (); 602 GNUNET_assert (0);
603 } 603 }
604 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal); 604 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
605 data = (uint32_t *) &message[1]; 605 data = (uint32_t *) &message[1];
diff --git a/src/consensus/test_consensus_api.c b/src/consensus/test_consensus_api.c
index bfd73c655..631215f14 100644
--- a/src/consensus/test_consensus_api.c
+++ b/src/consensus/test_consensus_api.c
@@ -40,7 +40,7 @@ conclude_done (void *cls)
40{ 40{
41 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "conclude over\n"); 41 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "conclude over\n");
42 if (2 != elements_received) 42 if (2 != elements_received)
43 GNUNET_abort (); 43 GNUNET_assert (0);
44 GNUNET_SCHEDULER_shutdown (); 44 GNUNET_SCHEDULER_shutdown ();
45} 45}
46 46
diff --git a/src/core/test_core_api_mq.c b/src/core/test_core_api_mq.c
index 9b2603a6c..b9ef9ea05 100644
--- a/src/core/test_core_api_mq.c
+++ b/src/core/test_core_api_mq.c
@@ -88,7 +88,7 @@ handle_test (void *cls,
88 } 88 }
89 if (num_received > NUM_MSG) 89 if (num_received > NUM_MSG)
90 { 90 {
91 GNUNET_abort (); 91 GNUNET_assert (0);
92 return GNUNET_SYSERR; 92 return GNUNET_SYSERR;
93 } 93 }
94 return GNUNET_OK; 94 return GNUNET_OK;
@@ -127,7 +127,7 @@ run (void *cls,
127 GNUNET_NO, handlers); 127 GNUNET_NO, handlers);
128 if (NULL == core) 128 if (NULL == core)
129 { 129 {
130 GNUNET_abort (); 130 GNUNET_assert (0);
131 return; 131 return;
132 } 132 }
133 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); 133 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL);
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index f2fa4b16f..fc5cb80d9 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -443,9 +443,11 @@ GNUNET_log_config_invalid (enum GNUNET_ErrorType kind,
443/** 443/**
444 * @ingroup logging 444 * @ingroup logging
445 * Abort the process, generate a core dump if possible. 445 * Abort the process, generate a core dump if possible.
446 * Most code should use `GNUNET_assert (0)` instead to
447 * first log the location of the failure.
446 */ 448 */
447void 449void
448GNUNET_abort (void) GNUNET_NORETURN; 450GNUNET_abort_ (void) GNUNET_NORETURN;
449 451
450 452
451/** 453/**
@@ -585,14 +587,14 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
585 * @ingroup logging 587 * @ingroup logging
586 * Use this for fatal errors that cannot be handled 588 * Use this for fatal errors that cannot be handled
587 */ 589 */
588#define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); GNUNET_abort(); } } while(0) 590#define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); GNUNET_abort_(); } } while(0)
589 591
590 592
591/** 593/**
592 * @ingroup logging 594 * @ingroup logging
593 * Use this for fatal errors that cannot be handled 595 * Use this for fatal errors that cannot be handled
594 */ 596 */
595#define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), f, l); GNUNET_abort(); } } while(0) 597#define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), f, l); GNUNET_abort_(); } } while(0)
596 598
597 599
598/** 600/**
diff --git a/src/mysql/mysql.c b/src/mysql/mysql.c
index 6ee685b34..2955bcf9c 100644
--- a/src/mysql/mysql.c
+++ b/src/mysql/mysql.c
@@ -38,7 +38,7 @@
38 * a failure of the command 'cmd' with the message given 38 * a failure of the command 'cmd' with the message given
39 * by strerror(errno). 39 * by strerror(errno).
40 */ 40 */
41#define DIE_MYSQL(cmd, dbh) do { GNUNET_log_from (GNUNET_ERROR_TYPE__ERROR, "mysql", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); GNUNET_abort(); } while(0); 41#define DIE_MYSQL(cmd, dbh) do { GNUNET_log_from (GNUNET_ERROR_TYPE__ERROR, "mysql", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_error((dbh)->dbf)); GNUNET_assert (0); } while(0);
42 42
43/** 43/**
44 * Log an error message at log-level 'level' that indicates 44 * Log an error message at log-level 'level' that indicates
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c
index aa482d672..5bbae2730 100644
--- a/src/regex/gnunet-regex-profiler.c
+++ b/src/regex/gnunet-regex-profiler.c
@@ -927,7 +927,7 @@ daemon_started (void *cls, struct GNUNET_TESTBED_Operation *op,
927 { 927 {
928 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 928 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
929 "Failed to start/stop daemon at peer %u: %s\n", peer->id, emsg); 929 "Failed to start/stop daemon at peer %u: %s\n", peer->id, emsg);
930 GNUNET_abort (); 930 GNUNET_assert (0);
931 } 931 }
932 else 932 else
933 { 933 {
@@ -942,7 +942,7 @@ daemon_started (void *cls, struct GNUNET_TESTBED_Operation *op,
942 { 942 {
943 search_peer = (search_peer + 1) % num_peers; 943 search_peer = (search_peer + 1) % num_peers;
944 if (i > num_peers) 944 if (i > num_peers)
945 GNUNET_abort (); /* we ran out of peers, must be a bug */ 945 GNUNET_assert (0); /* we ran out of peers, must be a bug */
946 } 946 }
947 peers[search_peer].search_str = search_strings[peer->id]; 947 peers[search_peer].search_str = search_strings[peer->id];
948 peers[search_peer].search_str_matched = GNUNET_NO; 948 peers[search_peer].search_str_matched = GNUNET_NO;
@@ -1038,7 +1038,7 @@ dht_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
1038 if (NULL != emsg || NULL == op || NULL == ca_result) 1038 if (NULL != emsg || NULL == op || NULL == ca_result)
1039 { 1039 {
1040 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DHT connect failed: %s\n", emsg); 1040 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "DHT connect failed: %s\n", emsg);
1041 GNUNET_abort (); 1041 GNUNET_assert (0);
1042 } 1042 }
1043 1043
1044 GNUNET_assert (NULL != peer->dht_handle); 1044 GNUNET_assert (NULL != peer->dht_handle);
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c
index 27c65fff6..0cbfc901b 100644
--- a/src/rps/gnunet-service-rps_sampler.c
+++ b/src/rps/gnunet-service-rps_sampler.c
@@ -748,7 +748,7 @@ RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler,
748 else if (GNUNET_NO == for_client) 748 else if (GNUNET_NO == for_client)
749 gpc->get_peer_task = GNUNET_SCHEDULER_add_now (&sampler_get_rand_peer2, gpc); 749 gpc->get_peer_task = GNUNET_SCHEDULER_add_now (&sampler_get_rand_peer2, gpc);
750 else 750 else
751 GNUNET_abort (); 751 GNUNET_assert (0);
752 752
753 GNUNET_CONTAINER_DLL_insert (gpc_head, gpc_tail, gpc); 753 GNUNET_CONTAINER_DLL_insert (gpc_head, gpc_tail, gpc);
754 } 754 }
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c
index f89af191c..c31ad6253 100644
--- a/src/util/common_allocation.c
+++ b/src/util/common_allocation.c
@@ -72,7 +72,7 @@ GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber)
72 if (ret == NULL) 72 if (ret == NULL)
73 { 73 {
74 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); 74 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc");
75 GNUNET_abort (); 75 GNUNET_assert (0);
76 } 76 }
77 return ret; 77 return ret;
78} 78}
@@ -108,7 +108,7 @@ GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
108 if (ret == NULL) 108 if (ret == NULL)
109 { 109 {
110 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); 110 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc");
111 GNUNET_abort (); 111 GNUNET_assert (0);
112 } 112 }
113#ifdef W32_MEM_LIMIT 113#ifdef W32_MEM_LIMIT
114 *((size_t *) ret) = size; 114 *((size_t *) ret) = size;
@@ -178,7 +178,7 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber)
178 if ((NULL == ptr) && (n > 0)) 178 if ((NULL == ptr) && (n > 0))
179 { 179 {
180 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc"); 180 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc");
181 GNUNET_abort (); 181 GNUNET_assert (0);
182 } 182 }
183#ifdef W32_MEM_LIMIT 183#ifdef W32_MEM_LIMIT
184 ptr = &((size_t *) ptr)[1]; 184 ptr = &((size_t *) ptr)[1];
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 747b80a63..695b49913 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -281,7 +281,7 @@ resize_logdefs ()
281 * Abort the process, generate a core dump if possible. 281 * Abort the process, generate a core dump if possible.
282 */ 282 */
283void 283void
284GNUNET_abort () 284GNUNET_abort_ ()
285{ 285{
286#if WINDOWS 286#if WINDOWS
287 DebugBreak (); 287 DebugBreak ();
@@ -1253,7 +1253,7 @@ GNUNET_util_cl_init ()
1253#endif 1253#endif
1254#if WINDOWS 1254#if WINDOWS
1255 if (!InitializeCriticalSectionAndSpinCount (&output_message_cs, 0x00000400)) 1255 if (!InitializeCriticalSectionAndSpinCount (&output_message_cs, 0x00000400))
1256 GNUNET_abort (); 1256 GNUNET_abort_ ();
1257#endif 1257#endif
1258} 1258}
1259 1259
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c
index 616f5534c..2960af17e 100644
--- a/src/util/crypto_random.c
+++ b/src/util/crypto_random.c
@@ -283,7 +283,7 @@ GNUNET_CRYPTO_random_init ()
283 FPRINTF (stderr, 283 FPRINTF (stderr,
284 _("libgcrypt has not the expected version (version %s is required).\n"), 284 _("libgcrypt has not the expected version (version %s is required).\n"),
285 NEED_LIBGCRYPT_VERSION); 285 NEED_LIBGCRYPT_VERSION);
286 GNUNET_abort (); 286 GNUNET_assert (0);
287 } 287 }
288 if ((rc = gcry_control (GCRYCTL_DISABLE_SECMEM, 0))) 288 if ((rc = gcry_control (GCRYCTL_DISABLE_SECMEM, 0)))
289 FPRINTF (stderr, 289 FPRINTF (stderr,
diff --git a/src/util/mq.c b/src/util/mq.c
index b73cf176f..14e0816e2 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -398,9 +398,9 @@ const struct GNUNET_MessageHeader *
398GNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq) 398GNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq)
399{ 399{
400 if (NULL == mq->current_envelope) 400 if (NULL == mq->current_envelope)
401 GNUNET_abort (); 401 GNUNET_assert (0);
402 if (NULL == mq->current_envelope->mh) 402 if (NULL == mq->current_envelope->mh)
403 GNUNET_abort (); 403 GNUNET_assert (0);
404 return mq->current_envelope->mh; 404 return mq->current_envelope->mh;
405} 405}
406 406
diff --git a/src/util/network.c b/src/util/network.c
index 22e77818d..63dfe330b 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -1923,7 +1923,7 @@ GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
1923 wfds ? awrite.fd_count : 0, 1923 wfds ? awrite.fd_count : 0,
1924 aexcept.fd_count, 1924 aexcept.fd_count,
1925 GetLastError ()); 1925 GetLastError ());
1926 GNUNET_abort (); 1926 GNUNET_assert (0);
1927 } 1927 }
1928 1928
1929 /* Check aexcept, if something is in there and we copied that 1929 /* Check aexcept, if something is in there and we copied that
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index cf3c027e9..bc7e49512 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -173,7 +173,7 @@ get_path_from_module_filename ()
173 real_pathlen = GetModuleFileNameW (dll_instance, modulepath, pathlen * sizeof (wchar_t)); 173 real_pathlen = GetModuleFileNameW (dll_instance, modulepath, pathlen * sizeof (wchar_t));
174 } while (real_pathlen >= pathlen && pathlen < 16*1024); 174 } while (real_pathlen >= pathlen && pathlen < 16*1024);
175 if (real_pathlen >= pathlen) 175 if (real_pathlen >= pathlen)
176 GNUNET_abort (); 176 GNUNET_assert (0);
177 /* To be safe */ 177 /* To be safe */
178 modulepath[real_pathlen] = '\0'; 178 modulepath[real_pathlen] = '\0';
179 179
@@ -215,7 +215,7 @@ get_path_from_module_filename ()
215 /* modulepath is GNUNET_PREFIX */ 215 /* modulepath is GNUNET_PREFIX */
216 u8_string = u16_to_u8 (modulepath, wcslen (modulepath), NULL, &u8_string_length); 216 u8_string = u16_to_u8 (modulepath, wcslen (modulepath), NULL, &u8_string_length);
217 if (NULL == u8_string) 217 if (NULL == u8_string)
218 GNUNET_abort (); 218 GNUNET_assert (0);
219 219
220 upath = GNUNET_malloc (u8_string_length + 1); 220 upath = GNUNET_malloc (u8_string_length + 1);
221 memcpy (upath, u8_string, u8_string_length); 221 memcpy (upath, u8_string, u8_string_length);
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 351b20f22..d78de9468 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -580,7 +580,7 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs,
580 if ((0 != (tc.reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) && 580 if ((0 != (tc.reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) &&
581 (-1 != pos->write_fd) && 581 (-1 != pos->write_fd) &&
582 (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd))) 582 (!GNUNET_NETWORK_fdset_test_native (ws, pos->write_fd)))
583 GNUNET_abort (); // added to ready in previous select loop! 583 GNUNET_assert (0); // added to ready in previous select loop!
584 LOG (GNUNET_ERROR_TYPE_DEBUG, 584 LOG (GNUNET_ERROR_TYPE_DEBUG,
585 "Running task: %p\n", 585 "Running task: %p\n",
586 pos); 586 pos);
@@ -801,7 +801,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task,
801 "system"); 801 "system");
802#endif 802#endif
803#endif 803#endif
804 GNUNET_abort (); 804 GNUNET_assert (0);
805 break; 805 break;
806 } 806 }
807 if ( (0 == ret) && 807 if ( (0 == ret) &&
diff --git a/src/util/test_mq_client.c b/src/util/test_mq_client.c
index a8a1a64a0..61e027df5 100644
--- a/src/util/test_mq_client.c
+++ b/src/util/test_mq_client.c
@@ -105,7 +105,7 @@ send_cb (void *cls)
105static void 105static void
106send_trap_cb (void *cls) 106send_trap_cb (void *cls)
107{ 107{
108 GNUNET_abort (); 108 GNUNET_assert (0);
109} 109}
110 110
111 111