Changeset 2193905
- Timestamp:
- 11/29/18 10:12:59 (2 years ago)
- Branches:
- develop
- Children:
- fdf23b8
- Parents:
- d74ca03
- Files:
-
- 2 deleted
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/combiner_ordered.c
rf6f3ae5 r2193905 36 36 static int init_combiner(libtrace_t *t, libtrace_combine_t *c) { 37 37 int i = 0; 38 /*assert(trace_get_perpkt_threads(t) > 0);*/39 38 if (trace_get_perpkt_threads(t) <= 0) { 40 39 trace_set_err(t, TRACE_ERR_INIT_FAILED, "You must have atleast 1 processing thread"); … … 249 248 250 249 for (i = 0; i < trace_get_perpkt_threads(trace); i++) { 251 /*assert(libtrace_deque_get_size(&queues[i]) == 0);*/252 250 if (libtrace_deque_get_size(&queues[i]) != 0) { 253 251 trace_set_err(trace, TRACE_ERR_COMBINER, 254 "Failed to dest ory queues, A thread still has data in destroy()");252 "Failed to destroy queues, A thread still has data in destroy()"); 255 253 return; 256 254 } -
lib/combiner_sorted.c
rf6f3ae5 r2193905 34 34 static int init_combiner(libtrace_t *t, libtrace_combine_t *c) { 35 35 int i = 0; 36 /*assert(trace_get_perpkt_threads(t) > 0);*/37 36 if (trace_get_perpkt_threads(t) <= 0) { 38 37 trace_set_err(t, TRACE_ERR_INIT_FAILED, "You must have atleast 1 processing thread"); … … 109 108 110 109 for (i = 0; i < trace_get_perpkt_threads(trace); i++) { 111 /*assert(libtrace_vector_get_size(&queues[i]) == 0);*/112 110 if (libtrace_vector_get_size(&queues[i]) != 0) { 113 111 trace_set_err(trace, TRACE_ERR_COMBINER, 114 "Failed to dest ory queues, A thread still has data in destroy()");112 "Failed to destroy queues, A thread still has data in destroy()"); 115 113 return; 116 114 } -
lib/combiner_unordered.c
rf6f3ae5 r2193905 34 34 static int init_combiner(libtrace_t *t, libtrace_combine_t *c) { 35 35 int i = 0; 36 /*assert(trace_get_perpkt_threads(t) > 0);*/37 36 if (trace_get_perpkt_threads(t) <= 0) { 38 37 trace_set_err(t, TRACE_ERR_INIT_FAILED, "You must have atleast 1 processing thread"); … … 91 90 92 91 for (i = 0; i < trace_get_perpkt_threads(trace); i++) { 93 /*assert(libtrace_deque_get_size(&queues[i]) == 0);*/94 92 if (libtrace_deque_get_size(&queues[i]) != 0) { 95 93 trace_set_err(trace, TRACE_ERR_COMBINER, -
lib/data-struct/buckets.c
r88b9798 r2193905 26 26 27 27 #include <stdlib.h> 28 #include <assert.h>29 28 #include <string.h> 30 29 #include "buckets.h" … … 183 182 libtrace_bucket_node_t tmp; 184 183 185 /*assert(id != 0);*/186 184 if (id == 0) { 187 185 fprintf(stderr, "bucket ID cannot be 0 in libtrace_release_bucket_id()\n"); … … 191 189 pthread_mutex_lock(&b->lock); 192 190 bnode = b->packets[id]; 193 /*assert(bnode != NULL);*/ 194 if (bnode == NULL) { 191 if (!bnode) { 195 192 fprintf(stderr, "bucket ID %lu is NULL in libtrace_release_bucket_id()\n", id); 196 193 return; … … 204 201 s = id - bnode->startindex; 205 202 } 206 /*assert(s < bnode->slots);*/207 203 if (s >= bnode->slots) { 208 204 fprintf(stderr, "Error in libtrace_release_bucket_id()\n"); 209 205 return; 210 206 } 211 /*assert(bnode->released[s] != 0);*/212 207 if (bnode->released[s] == 0) { 213 208 fprintf(stderr, "Error in libtrace_release_bucket_id()\n"); … … 244 239 break; 245 240 246 /*assert(lnode->next != NULL);*/ 247 if (lnode->next == NULL) { 241 if (!lnode->next) { 248 242 fprintf(stderr, "Error in libtrace_release_bucket_id()\n"); 249 243 return; -
lib/data-struct/deque.c
r88b9798 r2193905 63 63 ASSERT_RET(pthread_mutex_lock(&q->lock), == 0); 64 64 if (q->head == NULL) { 65 /*assert(q->tail == NULL && q->size == 0);*/ 66 if (q->tail != NULL && q->size != 0) { 65 if (q->tail != NULL || q->size != 0) { 67 66 fprintf(stderr, "Error deque head cannot be NULL with a non NULL tail and size of more than 0 in libtrace_deque_push_back()\n"); 68 67 return; … … 71 70 q->head = q->tail = new_node; 72 71 } else { 73 /*assert (q->tail != NULL);*/74 72 if (q->tail == NULL) { 75 73 fprintf(stderr, "Error deque tail cannot be NULL if it contains a head in libtrace_deque_push_back()\n"); … … 94 92 ASSERT_RET(pthread_mutex_lock(&q->lock), == 0); 95 93 if (q->head == NULL) { 96 /*assert(q->tail == NULL && q->size == 0);*/ 97 if (q->tail != NULL && q->size != 0) { 94 if (q->tail != NULL || q->size != 0) { 98 95 fprintf(stderr, "Error deque head cannot be NULL with a non NULL tail and size of more than 0 in libtrace_deque_push_front()\n"); 99 96 return; … … 102 99 q->head = q->tail = new_node; 103 100 } else { 104 /*assert (q->head != NULL);*/105 if (q->head == NULL) {106 fprintf(stderr, "Error deque tail cannot be NULL if it contains a head in libtrace_deque_push_front()\n");107 return;108 }109 101 q->head->prev = new_node; 110 102 new_node->next = q->head; // Done the double link -
lib/data-struct/linked_list.c
r88b9798 r2193905 26 26 #include "linked_list.h" 27 27 28 #include <assert.h>29 28 #include <stddef.h> 30 29 #include <stdlib.h> … … 72 71 /* Create the new node */ 73 72 new = (libtrace_list_node_t *)malloc(sizeof(libtrace_list_node_t)); 74 /*assert(new != NULL);*/75 73 if (!new) { 76 74 fprintf(stderr, "Unable to allocate memory for node in libtrace_list_push_front()\n"); … … 78 76 } 79 77 new->data = malloc(l->element_size); 80 /*assert(new->data != NULL);*/81 78 if (!new->data) { 82 79 fprintf(stderr, "Unable to allocate memory for node data in libtrace_list_push_front()\n"); … … 87 84 88 85 if (l->head == NULL) { 89 /*assert(l->tail == NULL && l->size == 0);*/ 90 if (l->tail != NULL && l->size != 0) { 86 if (l->tail != NULL || l->size != 0) { 91 87 fprintf(stderr, "Error cannot have a NULL head with a non NULL tail and a size of non 0 in libtrace_list_push_front()\n"); 92 88 return; … … 111 107 /* Create the new node */ 112 108 new = (libtrace_list_node_t *)malloc(sizeof(libtrace_list_node_t)); 113 /*assert(new != NULL);*/114 109 if (!new) { 115 110 fprintf(stderr, "Unable to allocate memory for node in libtrace_list_push_back()\n"); … … 117 112 } 118 113 new->data = malloc(l->element_size); 119 /*assert(new->data != NULL);*/120 114 if (!new->data) { 121 115 fprintf(stderr, "Unable to allocate memory for node data in libtrace_list_push_back()\n"); … … 126 120 127 121 if (l->tail == NULL) { 128 /*assert(l->head == NULL && l->size == 0);*/ 129 if (l->head != NULL && l->size != 0) { 122 if (l->head != NULL || l->size != 0) { 130 123 fprintf(stderr, "Error cannot have a NULL tail with a non NULL head and a size of non 0 in libtrace_list_push_back()\n"); 131 124 return; … … 219 212 while (index--) { 220 213 ret = ret->next; 221 /*assert(ret != NULL);*/222 214 if (!ret) { 223 215 fprintf(stderr, "Error encountered NULL index in libtrace_list_get_index()\n"); -
lib/data-struct/message_queue.c
r0a474e3 r2193905 43 43 void libtrace_message_queue_init(libtrace_message_queue_t *mq, size_t message_len) 44 44 { 45 /*assert(message_len);*/46 45 if (!message_len) { 47 46 fprintf(stderr, "Message length cannot be 0 in libtrace_message_queue_init()\n"); … … 73 72 { 74 73 int ret; 75 /*assert(mq->message_len);*/ 76 //if (!mq->message_len) { 77 // fprintf(stderr, "Message queue must be initialised with libtrace_message_queue_init()" 78 // "before inserting messages in libtrace_message_queue_put()\n"); 79 // /* Can we return -1 here as this could imply threads are waiting */ 80 // return -1; 81 //} 74 if (!mq->message_len) { 75 fprintf(stderr, "Message queue must be initialised with libtrace_message_queue_init()" 76 "before inserting messages in libtrace_message_queue_put()\n"); 77 return 0; 78 } 82 79 ASSERT_RET(write(mq->pipefd[1], message, mq->message_len), == (int) mq->message_len); 83 80 // Update after we've written -
lib/data-struct/object_cache.c
rb6ff245 r2193905 143 143 */ 144 144 static void resize_memory_caches(struct local_caches *lcs) { 145 /*assert (lcs->t_mem_caches_total > 0);*/146 145 if (lcs->t_mem_caches_total <= 0) { 147 146 fprintf(stderr, "Expected lcs->t_mem_caches_total to be greater or equal to 0 in resize_memory_caches()\n"); … … 170 169 /* This thread has not been used with a memory pool before */ 171 170 /* Allocate our TLS */ 172 /*assert(lcs == NULL);*/173 171 if (lcs) { 174 172 fprintf(stderr, "Expected lcs to be NULL in get_local_caches()\n"); … … 176 174 } 177 175 lcs = calloc(1, sizeof (struct local_caches)); 178 /*assert(lcs);*/179 176 if (!lcs) { 180 177 fprintf(stderr, "Unable to allocate memory for lcs in get_local_caches()\n"); … … 186 183 lcs->t_mem_caches_total = 0x10; 187 184 lcs->t_mem_caches = calloc(0x10, sizeof(struct local_cache)); 188 /*assert(lcs);*/189 /*assert(lcs->t_mem_caches);*/190 185 if (!lcs->t_mem_caches) { 191 fprintf(stderr, "Unable to allocate memory for lcs->t_mem_caches in get_local_ca hces()\n");186 fprintf(stderr, "Unable to allocate memory for lcs->t_mem_caches in get_local_caches()\n"); 192 187 return NULL; 193 188 } … … 226 221 } 227 222 228 /*assert(!lc->invalid);*/229 223 if (lc->invalid) { 230 224 fprintf(stderr, "lc cache is invalid in find_cache()\n"); … … 266 260 size_t buffer_size, bool limit_size) { 267 261 268 /*assert(buffer_size);*/ 269 if (!buffer_size) { 262 if (buffer_size <= 0) { 270 263 fprintf(stderr, "NULL buffer_size passed into libtrace_ocache_init()\n"); 271 264 return -1; 272 265 } 273 /*assert(alloc);*/274 266 if (!alloc) { 275 267 fprintf(stderr, "NULL alloc passed into libtrace_ocache_init()\n"); 276 268 return -1; 277 269 } 278 /*assert(free);*/279 270 if (!free) { 280 271 fprintf(stderr, "NULL free method passed into libtrace_ocache_init()\n"); … … 398 389 mem_hits.read.miss += nb_buffers - i; 399 390 #endif 400 /*assert(i >= min_nb_buffers);*/401 391 if (i < min_nb_buffers) { 402 392 fprintf(stderr, "Unable to fill remaining cache in libtrace_ocache_alloc_cache()\n"); … … 412 402 bool try_alloc = !(oc->max_allocations && oc->max_allocations <= oc->current_allocations); 413 403 414 assert(oc->max_allocations ? nb_buffers < oc->max_allocations : 1); 404 if (oc->max_allocations) { 405 if(nb_buffers >= oc->max_allocations) { 406 fprintf(stderr, "Expected nb_buffers to be less than or equal to the object cache " 407 "max allocation in libtrace_ocache_alloc()\n"); 408 return ~0U; 409 } 410 } 415 411 min = try_alloc ? 0: min_nb_buffers; 416 412 if (lc) … … 435 431 for (;i < nb; ++i) { 436 432 values[i] = (*oc->alloc)(); 437 /*assert(values[i]);*/438 433 if (!values[i]) { 439 434 fprintf(stderr, "Unable to alloc memory for values[%zu] in libtrace_ocache_alloc()\n", i); … … 441 436 } 442 437 } 443 /*assert (i == nb);*/ 438 444 439 if (i != nb) { 445 440 fprintf(stderr, "Expected i == nb in libtrace_ocache_alloc()\n"); … … 454 449 } 455 450 } 456 /*assert(i >= min_nb_buffers);*/457 451 if (i < min_nb_buffers) { 458 fprintf(stderr, "Expected min_nb_buffers to be equal or less than i in libtrace_ocache_alloc()\n"); 452 fprintf(stderr, "Failed to allocate minimum number of buffers for libtrace " 453 "object cache in libtrace_ocache_alloc()\n"); 459 454 return ~0U; 460 455 } … … 535 530 size_t min; 536 531 537 assert(oc->max_allocations ? nb_buffers < oc->max_allocations : 1); 532 if (oc->max_allocations) { 533 if(nb_buffers >= oc->max_allocations) { 534 fprintf(stderr, "Expected nb_buffers to be less than or equal to the object cache " 535 "max allocation in libtrace_ocache_alloc()\n"); 536 return ~0U; 537 } 538 } 538 539 min = oc->max_allocations ? min_nb_buffers : 0; 539 540 if (lc) -
lib/data-struct/ring_buffer.c
r0a474e3 r2193905 268 268 size_t nb_ready; 269 269 size_t i = 0; 270 271 /*assert(min_nb_buffers <= nb_buffers);*/ 270 272 271 if (min_nb_buffers > nb_buffers) { 273 272 fprintf(stderr, "min_nb_buffers must be greater than or equal to nb_buffers in libtrace_ringbuffer_write_bulk()\n"); … … 351 350 size_t i = 0; 352 351 353 /*assert(min_nb_buffers <= nb_buffers);*/354 352 if (min_nb_buffers > nb_buffers) { 355 353 fprintf(stderr, "min_nb_buffers must be greater than or equal to nb_buffers in libtrace_ringbuffer_write_bulk()\n"); -
lib/data-struct/sliding_window.c
r0a474e3 r2193905 27 27 28 28 #include <stdlib.h> 29 #include <assert.h>30 29 #include <string.h> 31 30 … … 44 43 sw->start = 0; 45 44 sw->elements = calloc(sw->size, sizeof(void*)); 46 /*assert(sw->elements);*/47 45 if (!sw->elements) { 48 46 fprintf(stderr, "Unable to allocate memory for sw->elements in libtrace_slidingwindow_init()\n"); -
lib/data-struct/vector.c
r0a474e3 r2193905 54 54 v->max_size *= 2; 55 55 v->elements = realloc(v->elements, v->max_size * v->element_size); 56 /*assert(v->elements);*/57 56 if (!v->elements) { 58 57 fprintf(stderr, "Unable to allocate memory for v->elements in libtrace_vector_push_back()\n"); … … 108 107 DLLEXPORT void libtrace_vector_append(libtrace_vector_t *dest, libtrace_vector_t *src) 109 108 { 110 /*assert(dest->element_size == src->element_size);*/111 109 if (dest->element_size != src->element_size) { 112 110 fprintf(stderr, "Elements must be the same size in libtrace_vector_append()\n"); -
lib/format_atmhdr.c
r32ee9b2 r2193905 34 34 35 35 #include <sys/stat.h> 36 #include <assert.h>37 36 #include <errno.h> 38 37 #include <fcntl.h> -
lib/format_bpf.c
r2725318 r2193905 128 128 129 129 if (!libtrace->format_data) { 130 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory bpf_init_input()"); 130 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory " 131 "for format data inside bpf_init_input()"); 131 132 return -1; 132 133 } -
lib/format_dag24.c
rf6f3ae5 r2193905 33 33 #include "format_erf.h" 34 34 35 #include <assert.h>36 35 #include <errno.h> 37 36 #include <fcntl.h> … … 326 325 return NULL; 327 326 size = ntohs(erfptr->rlen); 328 /*assert( size >= dag_record_size );*/329 327 if (size < dag_record_size) { 330 fprintf(stderr, "Incorrect dag record size in dag_get_record()\n"); 328 fprintf(stderr, "DAG2.4 rlen is invalid (rlen = %u, must be at least %u)\n", 329 size, dag_record_size); 331 330 return NULL; 332 331 } … … 484 483 } while (1); 485 484 486 487 /* We only want to sleep for a very short time */488 /*assert(data == 0);*/489 if (!data != 0) {490 trace_set_err(trace, TRACE_ERR_BAD_PACKET, "Unexpected data from trace event in trace_event_dag()");491 return NULL;492 }493 485 event.type = TRACE_EVENT_SLEEP; 494 486 event.seconds = 0.0001; -
lib/format_dag25.c
rb6ff245 r2193905 33 33 #include "format_erf.h" 34 34 35 #include <assert.h>36 35 #include <errno.h> 37 36 #include <fcntl.h> … … 245 244 FORMAT_DATA->per_stream = 246 245 libtrace_list_init(sizeof(stream_data)); 247 /*assert(FORMAT_DATA->per_stream != NULL);*/248 246 if (FORMAT_DATA->per_stream == NULL) { 249 247 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, … … 289 287 { 290 288 /* Need to remove from the device list */ 291 /*assert(dev->ref_count == 0);*/292 289 if (dev->ref_count != 0) { 293 290 fprintf(stderr, "Cannot close DAG device with non zero reference in dag_close_device()\n"); … … 1005 1002 1006 1003 size = ntohs(erfptr->rlen); 1007 /*assert( size >= dag_record_size );*/1008 1004 if (size < dag_record_size) { 1009 fprintf(stderr, "Incorrect dag record size in dag_get_record()\n"); 1005 fprintf(stderr, "DAG2.5 rlen is invalid (rlen %u, must be at least %u\n", 1006 size, dag_record_size); 1010 1007 return NULL; 1011 1008 } … … 1239 1236 1240 1237 /* Packet length (rlen includes format overhead) */ 1241 /*assert(trace_get_capture_length(packet) > 0 1242 && trace_get_capture_length(packet) <= 65536);*/ 1243 if (!(trace_get_capture_length(packet) > 0 1244 && trace_get_capture_length(packet) <= 65536)) { 1238 if (trace_get_capture_length(packet) <= 0 1239 || trace_get_capture_length(packet) > 65536) { 1245 1240 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, 1246 1241 "Capture length is out of range in dag_write_packet()"); 1247 1242 return -1; 1248 1243 } 1249 /*assert(erf_get_framing_length(packet) > 0 1250 && trace_get_framing_length(packet) <= 65536);*/ 1251 if (!(erf_get_framing_length(packet) > 0 1252 && trace_get_framing_length(packet) <= 65536)) { 1244 if (erf_get_framing_length(packet) <= 0 1245 || trace_get_framing_length(packet) > 65536) { 1253 1246 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, 1254 1247 "Framing length is out of range in dag_write_packet()"); 1255 1248 return -1; 1256 1249 } 1257 /*assert(trace_get_capture_length(packet) + 1258 erf_get_framing_length(packet) > 0 1259 && trace_get_capture_length(packet) + 1260 erf_get_framing_length(packet) <= 65536);*/ 1261 if (!(trace_get_capture_length(packet) + 1262 erf_get_framing_length(packet) > 0 1263 && trace_get_capture_length(packet) + 1264 erf_get_framing_length(packet) <= 65536)) { 1250 if (trace_get_capture_length(packet) + 1251 erf_get_framing_length(packet) <= 0 1252 || trace_get_capture_length(packet) + 1253 erf_get_framing_length(packet) > 65536) { 1265 1254 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, 1266 1255 "Capture + framing length is out of range in dag_write_packet()"); … … 1516 1505 { 1517 1506 libtrace_list_node_t *tmp; 1518 /*assert(stat && libtrace);*/1519 1507 if (!libtrace) { 1520 1508 fprintf(stderr, "NULL trace passed into dag_get_statistics()\n"); … … 1540 1528 libtrace_stat_t *stat) { 1541 1529 struct dag_per_stream_t *stream_data = t->format_data; 1542 /*assert(stat && libtrace);*/1543 1530 if (!libtrace) { 1544 1531 fprintf(stderr, "NULL trace passed into dag_get_thread_statistics()\n"); -
lib/format_dpdk.c
r2725318 r2193905 51 51 52 52 #include <stdlib.h> 53 #include <assert.h>54 53 #include <unistd.h> 55 54 #include <endian.h> … … 213 212 static int parse_pciaddr(char * str, struct rte_pci_addr * addr, long * core) { 214 213 int matches; 215 assert(str); 214 215 if (!str) { 216 fprintf(stderr, "NULL str passed into parse_pciaddr()\n"); 217 return -1; 218 } 216 219 #if RTE_VERSION >= RTE_VERSION_NUM(17, 8, 0, 1) 217 220 matches = sscanf(str, "%8"SCNx32":%2"SCNx8":%2"SCNx8".%2"SCNx8"-%ld", … … 325 328 int i; 326 329 327 assert (core < RTE_MAX_LCORE); 328 assert (rte_get_master_lcore() == rte_lcore_id()); 330 if (core >= RTE_MAX_LCORE) { 331 fprintf(stderr, "Core must be a value less than the number of cores " 332 "in dpdk_move_master_lcore()\n"); 333 return -1; 334 } 335 if (rte_get_master_lcore() != rte_lcore_id()) { 336 fprintf(stderr, "Master core not equal to core id in dpdk_move_master_lcore()\n"); 337 return -1; 338 } 329 339 330 340 if (core == rte_lcore_id()) … … 332 342 333 343 /* Make sure we are not overwriting someone else */ 334 assert(!rte_lcore_is_enabled(core)); 344 if (rte_lcore_is_enabled(core)) { 345 fprintf(stderr, "Cannot override another core in dpdk_move_master_lcore()\n"); 346 return -1; 347 } 335 348 336 349 /* Move the core */ … … 470 483 int max_node_cpu = -1; 471 484 struct bitmask *mask = numa_allocate_cpumask(); 472 assert(mask); 485 if (!mask) { 486 fprintf(stderr, "Unable to allocate cpu mask in dpdk_init_environment()\n"); 487 return -1; 488 } 473 489 numa_node_to_cpus(format_data->nic_numa_node, mask); 474 490 for (i = 0 ; i < nb_cpu; ++i) { … … 530 546 } 531 547 // Only the master should be running 532 assert(cfg->lcore_count == 1); 548 if (cfg->lcore_count != 1) { 549 fprintf(stderr, "Expected only the master core to be running in dpdk_init_environment()\n"); 550 return -1; 551 } 533 552 534 553 // TODO XXX TODO … … 589 608 590 609 if (!libtrace->format_data) { 591 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory dpdk_init_input()"); 610 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 611 "format data inside dpdk_init_input()"); 592 612 return 1; 593 613 } … … 636 656 637 657 if (!libtrace->format_data) { 638 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory dpdk_init_output()"); 658 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 659 "format data inside dpdk_init_output()"); 639 660 return -1; 640 661 } … … 843 864 struct dpdk_format_data_t * format_data = cb_arg; 844 865 struct rte_eth_link link_info; 845 assert(event == RTE_ETH_EVENT_INTR_LSC); 846 assert(port == format_data->port); 866 if (event != RTE_ETH_EVENT_INTR_LSC) { 867 fprintf(stderr, "Received unexpected event in dpdk_lsc_callback()\n"); 868 #if RTE_VERSION >= RTE_VERSION_NUM(17, 8, 0, 1) 869 return -1; 870 #else 871 return; 872 #endif 873 } 874 if (port != format_data->port) { 875 fprintf(stderr, "Port does not match port in format data in dpdk_lsc_callback()\n"); 876 return -1; 877 } 847 878 848 879 rte_eth_link_get_nowait(port, &link_info); … … 1456 1487 struct rte_config *cfg = rte_eal_get_configuration(); 1457 1488 1458 assert(rte_lcore_id() < RTE_MAX_LCORE); 1489 if (rte_lcore_id() >= RTE_MAX_LCORE) { 1490 fprintf(stderr, "Expected core id less than or equal to RTE_MAX_LCORE in " 1491 "dpdk_punregister_thread()\n"); 1492 return; 1493 } 1459 1494 pthread_mutex_lock(&dpdk_lock); 1460 1495 /* Skip if master */ … … 1469 1504 cfg->lcore_count--; 1470 1505 RTE_PER_LCORE(_lcore_id) = -1; // Might make the world burn if used again 1471 assert(cfg->lcore_count >= 1); // We cannot unregister the master LCORE!! 1506 if (cfg->lcore_count < 1) { 1507 fprintf(stderr, "You cannot unregister the master lcore in dpdk_punregister_thread()\n"); 1508 return; 1509 } 1472 1510 pthread_mutex_unlock(&dpdk_lock); 1473 1511 return; … … 1595 1633 */ 1596 1634 static inline struct dpdk_addt_hdr * get_addt_hdr (const libtrace_packet_t *packet) { 1597 assert(packet); 1598 assert(packet->buffer); 1635 if (!packet) { 1636 fprintf(stderr, "NULL packet passed into dpdk_addt_hdr()\n"); 1637 return NULL; 1638 } 1639 if (!packet->buffer) { 1640 fprintf(stderr, "NULL packet buffer passed into dpdk_addt_hdr()\n"); 1641 return NULL; 1642 } 1599 1643 /* Our header sits straight after the mbuf header */ 1600 1644 return (struct dpdk_addt_hdr *) ((struct rte_mbuf*) packet->buffer + 1); … … 1648 1692 libtrace_packet_t *packet, void *buffer, 1649 1693 libtrace_rt_types_t rt_type, uint32_t flags) { 1650 assert(packet); 1694 if (!packet) { 1695 fprintf(stderr, "NULL packet passed into dpdk_prepare_packet()\n"); 1696 return TRACE_ERR_NULL_PACKET; 1697 } 1651 1698 if (packet->buffer != buffer && 1652 1699 packet->buf_control == TRACE_CTRL_PACKET) { … … 1950 1997 if (packets[i]->buffer != NULL) { 1951 1998 /* The packet should always be finished */ 1952 assert(packets[i]->buf_control == TRACE_CTRL_PACKET); 1999 if (packets[i]->buf_control != TRACE_CTRL_PACKET) { 2000 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Expected packet buffer " 2001 "to be empty in dpdk_pread_packets()\n"); 2002 return -1; 2003 } 1953 2004 free(packets[i]->buffer); 1954 2005 } … … 1975 2026 if (packet->buffer != NULL) { 1976 2027 /* The packet should always be finished */ 1977 assert(packet->buf_control == TRACE_CTRL_PACKET); 2028 if (packet->buf_control != TRACE_CTRL_PACKET) { 2029 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Expected packet buffer to be " 2030 "empty in dpdk_read_packet()\n"); 2031 return -1; 2032 } 1978 2033 free(packet->buffer); 1979 2034 packet->buffer = NULL; … … 2097 2152 if (packet->buffer != NULL) { 2098 2153 /* The packet should always be finished */ 2099 assert(packet->buf_control == TRACE_CTRL_PACKET); 2154 if (packet->buf_control != TRACE_CTRL_PACKET) { 2155 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Expected packet " 2156 "buffer to be empty in dpdk_trace_event()\n"); 2157 return -1; 2158 } 2100 2159 free(packet->buffer); 2101 2160 packet->buffer = NULL; -
lib/format_dpdkndag.c
r0a474e3 r2193905 7 7 #include "format_erf.h" 8 8 9 #include <assert.h>10 9 #include <errno.h> 11 10 #include <fcntl.h> … … 88 87 89 88 if (!libtrace->format_data) { 90 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory dpdknday_init_input()"); 89 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 90 "format data inside dpdknday_init_input()"); 91 91 return -1; 92 92 } -
lib/format_duck.c
rf6f3ae5 r2193905 33 33 34 34 #include <errno.h> 35 #include <assert.h>36 35 #include <stdio.h> 37 36 #include <fcntl.h> … … 70 69 71 70 if (!libtrace->format_data) { 72 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory duck_init_input()"); 71 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 72 "format data inside duck_init_input()"); 73 73 return 1; 74 74 } … … 82 82 83 83 if (!libtrace->format_data) { 84 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory duck_init_output()"); 84 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 85 "format data inside duck_init_output()"); 85 86 return -1; 86 87 } … … 112 113 return -1; 113 114 } 114 /*assert(0);*/115 115 trace_set_err_out(libtrace, TRACE_ERR_UNKNOWN_OPTION, 116 116 "Unknown option in duck_config_output()"); … … 267 267 } 268 268 269 /*assert(OUTPUT->file);*/270 269 if (!OUTPUT->file) { 271 270 trace_set_err_out(libtrace, TRACE_ERR_BAD_IO, 272 "Call init_output before write_packets() in duck_write_packet()"); 271 "Attempted to write DUCK packets to a closed file, must call " 272 "trace_create_output() before calling trace_write_output()"); 273 273 return -1; 274 274 } -
lib/format_erf.c
rf6f3ae5 r2193905 35 35 #include "wandio.h" 36 36 37 #include <assert.h>38 37 #include <errno.h> 39 38 #include <fcntl.h> … … 180 179 exthdr ++; 181 180 firstbyte = (uint8_t *)exthdr; 182 /*assert(extsize <= ntohs(erfptr->rlen));*/183 181 if (extsize > ntohs(erfptr->rlen)) { 184 182 trace_set_err(packet->trace, TRACE_ERR_BAD_PACKET, "Extension size is greater than dag record record length in erf_get_framing_length()"); … … 233 231 234 232 if (!libtrace->format_data) { 235 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory erf_init_input()"); 233 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 234 "format data inside erf_init_input()"); 236 235 return -1; 237 236 } … … 388 387 break; 389 388 case INDEX_UNKNOWN: 390 /*assert(0);*/391 389 trace_set_err(libtrace, TRACE_ERR_SEEK_ERF, "Cannot seek to erf timestamp with unknown index in erf_seek_erf()"); 392 390 return -1; … … 412 410 413 411 if (!libtrace->format_data) { 414 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory erf_init_output()"); 412 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 413 "format data inside erf_init_output()"); 415 414 return -1; 416 415 } … … 475 474 } else 476 475 packet->buf_control = TRACE_CTRL_EXTERNAL; 477 478 476 479 477 packet->type = rt_type; 480 478 packet->buffer = buffer; … … 487 485 } 488 486 489 /*assert(erfptr->rlen != 0);*/490 487 if (erfptr->rlen == 0) { 491 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Packet is empty in erf_prepare_packet()\n"); 488 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "ERF packet has an invalid record " 489 "length: zero, in erf_prepare_packet()\n"); 492 490 return -1; 493 491 } … … 668 666 void *payload = packet->payload; 669 667 670 /*assert(OUTPUT->file);*/671 668 if (!OUTPUT->file) { 672 trace_set_err_out(libtrace, TRACE_ERR_BAD_IO, "Call init_output before write_packet() in erf_write_packet()"); 669 trace_set_err_out(libtrace, TRACE_ERR_BAD_IO, "Attempted to write ERF packets to a " 670 "closed file, must call trace_create_output() before calling trace_write_output()"); 673 671 return -1; 674 672 } … … 722 720 723 721 /* Packet length (rlen includes format overhead) */ 724 /*assert(trace_get_capture_length(packet)>0 725 && trace_get_capture_length(packet)<=65536);*/ 726 if (!(trace_get_capture_length(packet) > 0 727 && trace_get_capture_length(packet) <= 65536)) { 722 if (trace_get_capture_length(packet) <= 0 723 || trace_get_capture_length(packet) > 65536) { 728 724 trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET, 729 725 "Capture length is out of range in erf_write_packet()"); 730 726 return -1; 731 727 } 732 /*assert(trace_get_framing_length(packet)<=65536);*/733 728 if (trace_get_framing_length(packet) > 65536) { 734 729 trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET, … … 743 738 744 739 rlen = trace_get_capture_length(packet) + framing; 745 /*assert(rlen > 0 && rlen <= 65536);*/ 746 if (!(rlen > 0 && rlen <= 65536)) { 740 if (rlen <= 0 || rlen > 65536) { 747 741 trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET, 748 742 "Capture + framing length is out of range in erf_write_packet()"); … … 836 830 uint16_t wlen; 837 831 838 /*assert(packet);*/839 832 if (!packet) { 840 833 fprintf(stderr, "NULL packet passed to erf_set_capture_length()\n"); -
lib/format_etsilive.c
rf6f3ae5 r2193905 37 37 #include <libwandder_etsili.h> 38 38 39 #include <assert.h>40 39 #include <errno.h> 41 40 #include <fcntl.h> … … 214 213 215 214 if (!libtrace->format) { 216 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory etsilive_init_input()"); 215 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 216 "format data inside etsilive_init_input()"); 217 217 return 1; 218 218 } … … 595 595 libtrace_t *libtrace = packet->trace; 596 596 597 /*assert(libtrace);*/598 597 if (!libtrace) { 599 598 fprintf(stderr, "Packet is not associated with a trace in etsilive_get_pdu_length()\n"); 600 599 return TRACE_ERR_NULL_TRACE; 601 600 } 602 /*assert(FORMAT_DATA->shareddec);*/603 601 if (!FORMAT_DATA->shareddec) { 604 602 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Etsilive format data shareddec is NULL in etsilive_get_pdu_length()\n"); -
lib/format_helper.c
rf6f3ae5 r2193905 39 39 #include "format_helper.h" 40 40 41 #include <assert.h>42 41 #include <stdarg.h> 43 42 … … 69 68 struct timeval tv; 70 69 71 /*assert(trace != NULL);*/72 70 if (!trace) { 73 71 fprintf(stderr, "NULL trace passed into trace_event_device()\n"); 74 /* Return empty event on error? */72 event.type = TRACE_EVENT_TERMINATE; 75 73 return event; 76 74 } 77 /*assert(packet != NULL);*/78 75 if (!packet) { 79 76 trace_set_err(trace, TRACE_ERR_NULL_PACKET, "NULL packet passed into trace_event_device()"); 80 /* Return empty event on error? */77 event.type = TRACE_EVENT_TERMINATE; 81 78 return event; 82 79 } … … 300 297 va_list va; 301 298 va_start(va,msg); 302 /*assert(errcode != 0 && "An error occurred, but it is unknown what it is");*/ 299 303 300 if (errcode == 0) { 304 301 fprintf(stderr, "An error occurred, but it is unknown what it is"); 305 302 return; 306 303 } 304 307 305 trace->err.err_num=errcode; 308 306 if (errcode>0) { … … 327 325 va_list va; 328 326 va_start(va,msg); 329 /*assert(errcode != 0 && "An error occurred, but it is unknown what it is");*/330 327 if (errcode == 0) { 331 328 fprintf(stderr, "An error occurred, but is is unknown what is is"); -
lib/format_legacy.c
r25a3255 r2193905 34 34 35 35 #include <sys/stat.h> 36 #include <assert.h>37 36 #include <errno.h> 38 37 #include <fcntl.h> … … 258 257 break; 259 258 default: 260 /*assert(0);*/261 259 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Invalid trace format type in legacy_read_packet()"); 262 260 return -1; … … 394 392 static int legacypos_get_wire_length(const libtrace_packet_t *packet) { 395 393 legacy_pos_t *lpos = (legacy_pos_t *)packet->header; 396 /*assert(ntohl(lpos->wlen)>0);*/ 394 397 395 if (ntohl(lpos->wlen) <= 0) { 398 trace_set_err(packet->trace, TRACE_ERR_BAD_PACKET, "Packet wire length is less than 0 in legacypos_get_wire_length()"); 396 trace_set_err(packet->trace, TRACE_ERR_BAD_PACKET, "Packet wire length is invalid (%d) " 397 "in legacypos_get_wire_length()", ntohl(lpos->wlen)); 399 398 return -1; 400 399 } -
lib/format_linux_common.c
r2725318 r2193905 40 40 #include <unistd.h> 41 41 #include <string.h> 42 #include <assert.h>43 42 44 43 #ifdef HAVE_INTTYPES_H … … 186 185 malloc(sizeof(struct linux_format_data_t)); 187 186 188 /*assert(libtrace->format_data != NULL);*/189 187 if (!libtrace->format_data) { 190 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory linuxcommon_init_input()"); 188 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 189 "format data inside linuxcommon_init_input()"); 191 190 return -1; 192 191 } … … 195 194 libtrace_list_init(sizeof(stream_data)); 196 195 197 /*assert(FORMAT_DATA->per_stream != NULL);*/198 196 if (!FORMAT_DATA->per_stream) { 199 197 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to create list for stream data linuxcommon_init_input()"); … … 222 220 malloc(sizeof(struct linux_format_data_out_t)); 223 221 224 /*assert(libtrace->format_data != NULL);*/225 222 if (!libtrace->format_data) { 226 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory linuxcommon_init_output()"); 223 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 224 "format data inside linuxcommon_init_output()"); 227 225 return -1; 228 226 } -
lib/format_linux_int.c
rf6f3ae5 r2193905 44 44 #include <unistd.h> 45 45 #include <string.h> 46 #include <assert.h>47 46 48 47 #ifdef HAVE_INTTYPES_H … … 451 450 452 451 struct libtrace_linuxnative_header *linux_hdr = NULL; 453 /*assert(packet);*/454 452 if (!packet) { 455 453 fprintf(stderr, "NULL packet passed into linuxnative_set_capture_length()\n"); -
lib/format_linux_ring.c
rf6f3ae5 r2193905 45 45 #include <unistd.h> 46 46 #include <string.h> 47 #include <assert.h>48 47 49 48 #ifdef HAVE_INTTYPES_H … … 149 148 150 149 /* In case we have some silly values*/ 151 /*assert(req->tp_block_size);*/152 150 if (!req->tp_block_size) { 153 fprintf(stderr, "Unexpected value req->tp_block_size in calculate_buffers()\n"); 154 } 155 /*assert(req->tp_block_nr);*/ 151 fprintf(stderr, "Unexpected value of zero for req->tp_block_size in calculate_buffers()\n"); 152 } 156 153 if (!req->tp_block_nr) { 157 fprintf(stderr, "Unexpected value req->tp_block_nr in calculate_buffers()\n"); 158 } 159 /*assert(req->tp_frame_size);*/ 154 fprintf(stderr, "Unexpected value of zero for req->tp_block_nr in calculate_buffers()\n"); 155 } 160 156 if (!req->tp_frame_size) { 161 fprintf(stderr, "Unexpected value req->tp_frame_size in calculate_buffers()\n"); 162 } 163 /*assert(req->tp_frame_nr);*/ 157 fprintf(stderr, "Unexpected value of zero for req->tp_frame_size in calculate_buffers()\n"); 158 } 164 159 if (!req->tp_frame_nr) { 165 fprintf(stderr, "Unexpected value req->tp_frame_nr in calculate_buffers()\n"); 166 } 167 /*assert(req->tp_block_size % req->tp_frame_size == 0);*/ 160 fprintf(stderr, "Unexpected value of zero for req->tp_frame_nr in calculate_buffers()\n"); 161 } 168 162 if (req->tp_block_size % req->tp_frame_size != 0) { 169 fprintf(stderr, "Unexpected value req->tp_block_size %% req->tp_frame_size in calculate_buffers()\n");163 fprintf(stderr, "Unexpected value of zero for req->tp_block_size %% req->tp_frame_size in calculate_buffers()\n"); 170 164 } 171 165 } … … 463 457 size_t size) 464 458 { 465 /*assert(packet);*/466 459 if (!packet) { 467 460 fprintf(stderr, "NULL packet passed into linuxring_set_capture_length()\n"); … … 529 522 /* Fetch the current frame */ 530 523 header = GET_CURRENT_BUFFER(stream); 531 /*assert((((unsigned long) header) & (pagesize - 1)) == 0);*/532 524 if ((((unsigned long) header) & (pagesize - 1)) != 0) { 533 trace_set_err(libtrace, TRACE_ERR_BAD_IO, "Header of pagesize-1 is not zero in linux_read_string()"); 525 trace_set_err(libtrace, TRACE_ERR_BAD_IO, "Linux ring packet is not correctly " 526 "aligned to page size in linux_read_string()"); 534 527 return -1; 535 528 } … … 679 672 if (packet->buffer == NULL) 680 673 return; 681 /*assert(packet->trace);*/682 674 if (!packet->trace) { 683 fprintf(stderr, "Packet contains a NULL trace in linuxring_fin_packet()\n"); 675 fprintf(stderr, "Linux ring packet is not attached to a valid " 676 "trace, Unable to release it, in linuxring_fin_packet()\n"); 684 677 return; 685 678 } -
lib/format_ndag.c
r25a3255 r2193905 35 35 #include "format_erf.h" 36 36 37 #include <assert.h>38 37 #include <errno.h> 39 38 #include <fcntl.h> … … 287 286 288 287 if (!libtrace->format_data) { 289 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory ndag_init_input()"); 288 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 289 "format data inside ndag_init_input()"); 290 290 return -1; 291 291 } … … 658 658 ssock->nextts = 0; 659 659 660 /*assert(ssock->nextread - ssock->saved[nr] <= ssock->savedsize[nr]);*/661 660 if (ssock->nextread - ssock->saved[nr] > ssock->savedsize[nr]) { 662 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Failed to prepare packet stream in ndag_prepare_packet_stream()"); 661 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Walked past the end of the " 662 "nDAG receive buffer, probably due to a invalid rlen, in ndag_prepare_packet_stream()"); 663 663 return -1; 664 664 } … … 689 689 uint32_t flags UNUSED) { 690 690 691 /*assert(0 && "Sending nDAG records over RT doesn't make sense! Please stop.");*/692 691 fprintf(stderr, "Sending nDAG records over RT doesn't make sense! Please stop\n"); 693 692 return 0; … … 873 872 } 874 873 #else 875 /*assert(required > 0);*/876 874 if (required <= 0) { 877 fprintf(stderr, "You are required to have atleast 1 receiver in init_re veivers\n");875 fprintf(stderr, "You are required to have atleast 1 receiver in init_receivers\n"); 878 876 return TRACE_ERR_INIT_FAILED; 879 877 } … … 912 910 ssock->bufavail --; 913 911 914 /*assert(ssock->bufavail >= 0);*/915 912 if (ssock->bufavail < 0) { 916 913 fprintf(stderr, "No space in buffer in check_ndag_received()\n"); … … 1299 1296 src->bufavail += src->bufwaiting; 1300 1297 src->bufwaiting = 0; 1301 /*assert(src->bufavail >= 0 && src->bufavail <= ENCAP_BUFFERS);*/ 1302 if (src->bufavail < 0 && src->bufavail > ENCAP_BUFFERS) { 1298 if (src->bufavail < 0 || src->bufavail > ENCAP_BUFFERS) { 1303 1299 trace_set_err(libtrace, TRACE_ERR_BAD_IO, "Not enough buffer space in ndag_pread_packets()"); 1304 1300 return -1; … … 1392 1388 src->bufavail += src->bufwaiting; 1393 1389 src->bufwaiting = 0; 1394 /*assert(src->bufavail >= 0 && src->bufavail <= ENCAP_BUFFERS);*/ 1395 if (src->bufavail < 0 && src->bufavail > ENCAP_BUFFERS) { 1390 if (src->bufavail < 0 || src->bufavail > ENCAP_BUFFERS) { 1396 1391 trace_set_err(libtrace, TRACE_ERR_BAD_IO, "Not enough buffer space in trace_event_ndag()"); 1397 break; /* breaking here cause error above also does? */1392 break; 1398 1393 } 1399 1394 } -
lib/format_pcap.c
rf6f3ae5 r2193905 31 31 32 32 #include <sys/stat.h> 33 #include <assert.h>34 33 #include <stdio.h> 35 34 #include <stdlib.h> … … 103 102 104 103 if (!libtrace->format_data) { 105 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcap_init_input()"); 104 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 105 "format data inside pcap_init_input()"); 106 106 return -1; 107 107 } … … 178 178 return -1; 179 179 } 180 /*assert(0);*/181 180 return -1; 182 181 } … … 185 184 libtrace->format_data = malloc(sizeof(struct pcap_format_data_out_t)); 186 185 if (!libtrace->format_data) { 187 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcap_init_output()"); 186 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 187 "format data inside pcap_init_output()"); 188 188 return -1; 189 189 } … … 198 198 libtrace->format_data = malloc(sizeof(struct pcap_format_data_out_t)); 199 199 if (!libtrace->format_data) { 200 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapint_init_output()"); 200 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 201 "format data inside pcapint_init_output()"); 201 202 return -1; 202 203 } … … 222 223 libtrace->format_data = malloc(sizeof(struct pcap_format_data_t)); 223 224 if (!libtrace->format_data) { 224 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapint_init_input()"); 225 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 226 "format data inside pcapint_init_input()"); 225 227 return -1; 226 228 } … … 261 263 return -1; 262 264 } 263 /*assert(0);*/264 265 return -1; 265 266 } … … 446 447 uint32_t flags = 0; 447 448 448 /*assert(libtrace->format_data);*/449 449 if (!libtrace->format_data) { 450 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace format data missing, call init_input() before calling pcap_read_packet()"); 450 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace format data missing, " 451 "call trace_create() before calling pcap_read_packet()"); 451 452 return -1; 452 453 } … … 611 612 pcap_pkt_hdr.len = trace_get_wire_length(packet); 612 613 613 /*assert(pcap_pkt_hdr.caplen<65536);*/614 614 if (pcap_pkt_hdr.caplen >= 65536) { 615 615 trace_set_err_out(libtrace, TRACE_ERR_BAD_HEADER, "Header capture length is larger than it should be in pcap_write_packet()"); 616 616 return -1; 617 617 } 618 /*assert(pcap_pkt_hdr.len<65536);*/619 618 if (pcap_pkt_hdr.len >= 65536) { 620 619 trace_set_err_out(libtrace, TRACE_ERR_BAD_HEADER, "Header wire length is larger than it should be pcap_write_packet()"); … … 720 719 struct pcap_pkthdr *pcapptr = 0; 721 720 pcapptr = (struct pcap_pkthdr *)packet->header; 722 /*assert(pcapptr->caplen<=65536);*/723 721 if (pcapptr->caplen > 65536) { 724 722 trace_set_err(packet->trace, TRACE_ERR_BAD_PACKET, "Capture length is to large, Packet may be corrupt in pcap_get_capture_length()"); … … 756 754 static size_t pcap_set_capture_length(libtrace_packet_t *packet,size_t size) { 757 755 struct pcap_pkthdr *pcapptr = 0; 758 /*assert(packet);*/759 756 if (!packet) { 760 757 fprintf(stderr, "NULL packet passed to pcap_set_capture_length()\n"); … … 777 774 return TRACE_ERR_NULL_TRACE; 778 775 } 779 /*assert(trace->format_data);*/780 776 if (!trace->format_data) { 781 777 /* cant do this because trace is a const? */ -
lib/format_pcapfile.c
rf6f3ae5 r2193905 31 31 32 32 #include <sys/stat.h> 33 #include <assert.h>34 33 #include <stdio.h> 35 34 #include <stdlib.h> … … 126 125 libtrace->format_data = malloc(sizeof(struct pcapfile_format_data_t)); 127 126 if (!libtrace->format_data) { 128 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapfile_init_input()"); 127 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 128 "format data inside pcapfile_init_input()"); 129 129 return -1; 130 130 } … … 139 139 malloc(sizeof(struct pcapfile_format_data_out_t)); 140 140 if (!libtrace->format_data) { 141 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapfile_init_output()"); 141 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 142 "format data inside pcapfile_init_output()"); 142 143 return -1; 143 144 } … … 204 205 205 206 DATA(libtrace)->started = true; 206 /*assert(sizeof(DATA(libtrace)->header) > 0);*/207 207 if (!(sizeof(DATA(libtrace)->header) > 0)) { 208 208 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Trace is missing header in pcapfile_start_input()"); … … 352 352 size_t bytes_to_read = 0; 353 353 354 /*assert(libtrace->format_data);*/355 354 if (!libtrace->format_data) { 356 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, 357 " Trace format data missing, call init_input() before calling pcapfile_read_packet()");355 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace format data missing, " 356 "call trace_create() before calling trace_read_packet()"); 358 357 return -1; 359 358 } … … 456 455 TRACE_ERR_NO_CONVERSION, 457 456 "pcap does not support this format"); 458 /*assert(0);*/459 457 return -1; 460 458 } … … 497 495 hdr.ts_usec = (uint32_t)tv.tv_usec; 498 496 hdr.caplen = trace_get_capture_length(packet); 499 /*assert(hdr.caplen < LIBTRACE_PACKET_BUFSIZE);*/500 497 if (hdr.caplen >= LIBTRACE_PACKET_BUFSIZE) { 501 498 trace_set_err_out(out, TRACE_ERR_BAD_PACKET, "Capture length is greater than buffer size in pcap_write_packet()"); … … 579 576 return ts; 580 577 } 581 /*assert(packet->header);*/ 578 582 579 if (!packet->header) { 583 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_get_timeval()"); 580 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to " 581 "pcapfile_get_timeval()"); 584 582 /* Return default timeval on error? */ 585 583 return ts; … … 607 605 return ts; 608 606 } 609 /*assert(packet->header);*/ 607 610 608 if (!packet->header) { 611 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_get_timespec()"); 609 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to " 610 "pcapfile_get_timespec()"); 612 611 /* Return fefault timespec on error? */ 613 612 return ts; … … 632 631 return TRACE_ERR_NULL_PACKET; 633 632 } 634 /*assert(packet->header);*/ 633 635 634 if (!packet->header) { 636 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_get_capture_length()"); 635 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to " 636 "pcapfile_get_capture_length()"); 637 637 return -1; 638 638 } … … 649 649 return TRACE_ERR_NULL_PACKET; 650 650 } 651 /*assert(packet->header); */ 651 652 652 if (!packet->header) { 653 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_get_wire_length()"); 653 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to " 654 "pcapfile_get_wire_length()"); 654 655 return -1; 655 656 } … … 692 693 static size_t pcapfile_set_capture_length(libtrace_packet_t *packet,size_t size) { 693 694 libtrace_pcapfile_pkt_hdr_t *pcapptr = 0; 694 /*assert(packet);*/ 695 695 696 if (!packet) { 696 697 fprintf(stderr, "NULL packet passed into pcapfile_set_capture_length\n"); … … 698 699 return ~0U; 699 700 } 700 /*assert(packet->header);*/ 701 701 702 if (!packet->header) { 702 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_set_capture_length()"); 703 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to " 704 "pcapfile_set_capture_length()"); 703 705 /* Return -1 on error? */ 704 706 return ~0U; -
lib/format_pcapng.c
rf6f3ae5 r2193905 31 31 32 32 #include <sys/stat.h> 33 #include <assert.h>34 33 #include <stdio.h> 35 34 #include <stdlib.h> … … 219 218 libtrace->format_data = malloc(sizeof(struct pcapng_format_data_t)); 220 219 if (!libtrace->format_data) { 221 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapng_init_input()"); 220 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for " 221 "format data inside pcapng_init_input()"); 222 222 return -1; 223 223 } … … 302 302 } 303 303 304 /*assert((char *)blockhdr < *pktbuf);*/ 305 if (!((char *)blockhdr < *pktbuf)) { 304 if ((char *)blockhdr >= *pktbuf) { 306 305 return NULL; 307 306 } … … 459 458 } 460 459 461 /*assert(sechdr->blocktype == PCAPNG_SECTION_TYPE);*/462 460 if (sechdr->blocktype != PCAPNG_SECTION_TYPE) { 463 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, " Section is not a pcapng section type");461 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type in pcapng section block"); 464 462 return -1; 465 463 } … … 538 536 539 537 if (DATA(libtrace)->byteswapped) { 540 /*assert(byteswap32(inthdr->blocktype) == PCAPNG_INTERFACE_TYPE);*/541 538 if (byteswap32(inthdr->blocktype) != PCAPNG_INTERFACE_TYPE) { 542 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "In terface is not a pcapng type");539 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type in pcapng interface"); 543 540 return -1; 544 541 } … … 546 543 newint->linktype = byteswap16(inthdr->linktype); 547 544 } else { 548 /*assert(inthdr->blocktype == PCAPNG_INTERFACE_TYPE);*/549 545 if (inthdr->blocktype != PCAPNG_INTERFACE_TYPE) { 550 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "In terface is not a pcapng type");546 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type in pcapng interface"); 551 547 return -1; 552 548 } … … 621 617 /* Read the rest of the packet into the buffer */ 622 618 if (DATA(libtrace)->byteswapped) { 623 /*assert(byteswap32(hdr->blocktype) == PCAPNG_NAME_RESOLUTION_TYPE);*/624 619 if (byteswap32(hdr->blocktype) != PCAPNG_NAME_RESOLUTION_TYPE) { 625 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not a pcapng name resolution type"); 620 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type in pcapng name " 621 "resolution block"); 626 622 return -1; 627 623 } 628 624 } else { 629 /*assert(hdr->blocktype == PCAPNG_NAME_RESOLUTION_TYPE);*/630 625 if (hdr->blocktype != PCAPNG_NAME_RESOLUTION_TYPE) { 631 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not a pcapng name resolution type"); 626 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type in pcapng name " 627 "resolution block"); 632 628 return -1; 633 629 } … … 663 659 /* Read the rest of the packet into the buffer */ 664 660 if (DATA(libtrace)->byteswapped) { 665 /*assert(byteswap32(hdr->blocktype) == PCAPNG_CUSTOM_TYPE ||666 byteswap32(hdr->blocktype) == PCAPNG_CUSTOM_NONCOPY_TYPE);*/667 661 if (byteswap32(hdr->blocktype) != PCAPNG_CUSTOM_TYPE || 668 662 byteswap32(hdr->blocktype) != PCAPNG_CUSTOM_NONCOPY_TYPE) { 669 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not pcapng custom type"); 663 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid blocktype " 664 "in pcapng custom block"); 670 665 return -1; 671 666 } 672 667 } else { 673 /*assert(hdr->blocktype == PCAPNG_CUSTOM_TYPE ||674 hdr->blocktype == PCAPNG_CUSTOM_NONCOPY_TYPE);*/675 668 if (hdr->blocktype != PCAPNG_CUSTOM_TYPE || 676 669 hdr->blocktype != PCAPNG_CUSTOM_NONCOPY_TYPE) { 677 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not pcapng custom type"); 670 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid blocktype " 671 "in pcapng custom block"); 678 672 return -1; 679 673 } … … 710 704 /* Read the rest of the packet into the buffer */ 711 705 if (DATA(libtrace)->byteswapped) { 712 /*assert(byteswap32(hdr->blocktype) == PCAPNG_INTERFACE_STATS_TYPE);*/713 706 if (byteswap32(hdr->blocktype) != PCAPNG_INTERFACE_STATS_TYPE) { 714 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not a pcapng stats type"); 707 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type " 708 "in pcapng statistics block"); 715 709 return -1; 716 710 } … … 718 712 timestamp = ((uint64_t)(byteswap32(hdr->timestamp_high)) << 32) + byteswap32(hdr->timestamp_low); 719 713 } else { 720 /*assert(hdr->blocktype == PCAPNG_INTERFACE_STATS_TYPE);*/721 if (hdr->blocktype != PCAPNG_INTERFACE_STATS_TYPE) {722 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not a pcapng stats type");714 if (hdr->blocktype != PCAPNG_INTERFACE_STATS_TYPE) { 715 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type " 716 "in pcapng statistics block"); 723 717 return -1; 724 718 } … … 817 811 /* Read the rest of the packet into the buffer */ 818 812 if (DATA(libtrace)->byteswapped) { 819 /*assert(byteswap32(hdr->blocktype) == PCAPNG_SIMPLE_PACKET_TYPE);*/820 813 if (byteswap32(hdr->blocktype) != PCAPNG_SIMPLE_PACKET_TYPE) { 821 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not a pcapng simple type"); 814 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type in " 815 "pcapng simple packet block"); 822 816 return -1; 823 817 } … … 825 819 /* account for trailing length field */ 826 820 } else { 827 /*assert(hdr->blocktype == PCAPNG_SIMPLE_PACKET_TYPE);*/828 821 if (hdr->blocktype != PCAPNG_SIMPLE_PACKET_TYPE) { 829 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not a pcapng simple type"); 822 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type in " 823 "pcapng simple packet block"); 824 return -1; 830 825 } 831 826 caplen = hdr->blocklen - sizeof(pcapng_spkt_t) - 4; … … 874 869 /* Read the rest of the packet into the buffer */ 875 870 if (DATA(libtrace)->byteswapped) { 876 /*assert(byteswap32(hdr->blocktype) == PCAPNG_ENHANCED_PACKET_TYPE);*/877 871 if (byteswap32(hdr->blocktype) != PCAPNG_ENHANCED_PACKET_TYPE) { 878 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not a pcapng enhanced type"); 872 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type in " 873 "pcapng enhanced packet block"); 879 874 return -1; 880 875 } … … 882 877 ifaceid = byteswap32(hdr->interfaceid); 883 878 } else { 884 /*assert(hdr->blocktype == PCAPNG_ENHANCED_PACKET_TYPE);*/885 879 if (hdr->blocktype != PCAPNG_ENHANCED_PACKET_TYPE) { 886 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Blocktype is not a pcapng enhanced type"); 880 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Invalid block type in " 881 "pcapng enhanced packet block"); 887 882 return -1; 888 883 } … … 961 956 } 962 957 if (!packet) { 963 trace_set_err(libtrace, TRACE_ERR_NULL_PACKET, "NULL packet passed into pcapng_read_packet()\n"); 958 trace_set_err(libtrace, TRACE_ERR_NULL_PACKET, "NULL packet passed into " 959 "pcapng_read_packet()\n"); 964 960 return -1; 965 961 } 966 962 967 963 /* Peek to get next block type */ 968 /*assert(libtrace->format_data);*/969 964 if (!libtrace->format_data) { 970 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace has no format data in pcapng_read_packet()"); 965 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace has no format data in " 966 "pcapng_read_packet()"); 971 967 return -1; 972 968 } 973 /*assert(libtrace->io);*/974 969 if (!libtrace->io) { 975 trace_set_err(libtrace, TRACE_ERR_BAD_IO, "Trace has no IO associated with it in pcapng_read_packet()"); 970 trace_set_err(libtrace, TRACE_ERR_BAD_IO, "Trace has no valid file handle " 971 "attached to it in pcapng_read_packet()"); 976 972 return -1; 977 973 } … … 1121 1117 return ts; 1122 1118 } 1123 /*assert(packet->header);*/1124 1119 if (!packet->header) { 1125 1120 trace_set_err(packet->trace, TRACE_ERR_BAD_PACKET, "NULL header in packet in pcapng_get_timespec()"); -
lib/format_rt.c
rf6f3ae5 r2193905 37 37 38 38 #include <sys/stat.h> 39 #include <assert.h>40 39 #include <errno.h> 41 40 #include <fcntl.h> … … 611 610 packet->payload = RT_INFO->buf_read + sizeof(rt_header_t); 612 611 packet->internalid = libtrace_push_into_bucket(RT_INFO->bucket); 613 /*assert(packet->internalid != 0);*/614 612 if (!packet->internalid) { 615 613 trace_set_err(libtrace, TRACE_ERR_RT_FAILURE, "packet->internalid is 0 in rt_get_next_packet()"); … … 760 758 libtrace_err_t read_err; 761 759 762 /*assert(trace);*/763 760 if (!trace) { 764 761 fprintf(stderr, "NULL trace passed into trace_event_rt()\n"); … … 766 763 return event; 767 764 } 768 /*assert(packet);*/769 765 if (!packet) { 770 766 trace_set_err(trace, TRACE_ERR_NULL_PACKET, "NULL packet passed into trace_event_rt()"); -
lib/format_tsh.c
r32ee9b2 r2193905 31 31 #include "format_helper.h" 32 32 33 #include <assert.h>34 33 #include <errno.h> 35 34 #include <fcntl.h> -
lib/linktypes.c
r25a3255 r2193905 28 28 29 29 #include "rt_protocol.h" 30 #include <assert.h>31 30 #include "libtrace_int.h" 32 31 #include <stdlib.h> … … 162 161 163 162 fprintf(stderr, "Error: RT type %u cannot be converted to a pcap DLT\n", rt_type); 164 /*assert(false);*/165 163 return 0; /* satisfy warnings */ 166 164 } -
lib/protocols_l2.c
r25a3255 r2193905 27 27 #include "libtrace.h" 28 28 #include "protocols.h" 29 #include <assert.h>30 29 #include <stdlib.h> 31 30 #include <string.h> … … 196 195 uint32_t *remaining) { 197 196 /* Ensure supplied type is not NULL */ 198 /*assert(type);*/199 197 if (!type) { 200 198 fprintf(stderr, "NULL type passed into trace_get_payload_from_mpls()\n"); … … 332 330 uint32_t *remaining) { 333 331 /* Ensure type supplied is not NULL */ 334 /*assert(type);*/335 332 if (!type) { 336 333 fprintf(stderr, "NULL type passed into trace_get_payload_from_pppoe()\n"); … … 447 444 void *meta = NULL; 448 445 449 /*assert(packet != NULL);*/450 446 if (!packet) { 451 447 fprintf(stderr, "NULL packet passed into trace_get_layer2()\n"); 452 448 return NULL; 453 449 } 454 /*assert(linktype != NULL);*/455 450 if (!linktype) { 456 451 fprintf(stderr, "NULL linktype passed into trace_get_layer2()\n"); … … 727 722 case TRACE_TYPE_80211_RADIO: 728 723 case TRACE_TYPE_ETSILI: 729 /*assert(!"Metadata headers should already be skipped");*/730 724 fprintf(stderr, "Metadata headers should already be skipped in trace_get_source_mac()\n"); 731 725 return NULL; 732 726 } 733 727 fprintf(stderr,"%s not implemented for linktype %i\n", __func__, linktype); 734 /*assert(0);*/735 728 return NULL; 736 729 } … … 785 778 case TRACE_TYPE_80211_RADIO: 786 779 case TRACE_TYPE_ETSILI: 787 /*assert(!"Metadata headers should already be skipped");*/788 780 fprintf(stderr, "Metadata headers should already be skipped in trace_get_destination_mac()\n"); 789 781 return NULL; 790 782 } 791 783 fprintf(stderr,"Not implemented\n"); 792 /*assert(0);*/793 784 return NULL; 794 785 } -
lib/protocols_l3.c
r25a3255 r2193905 29 29 #include "protocols.h" 30 30 #include "checksum.h" 31 #include <assert.h>32 31 #include <stdlib.h> 33 32 #include <arpa/inet.h> … … 103 102 void *trans_ptr = 0; 104 103 105 /*assert(ipptr != NULL);*/106 104 if (!ipptr) { 107 105 fprintf(stderr, "NULL libtrace_ip_t pointer passed into trace_get_payload_from_ip()\n"); … … 146 144 uint16_t len; 147 145 148 /*assert (ipptr != NULL);*/149 146 if (!ipptr) { 150 147 fprintf(stderr, "NULL libtrace_ip6_t passed into trace_get_payload_from_ip6()\n"); … … 350 347 return 1; 351 348 } 352 /*assert(0);*/353 349 } 354 350 … … 356 352 int spacelen) { 357 353 358 /*assert(addrptr && space);*/359 354 if (!addrptr) { 360 355 fprintf(stderr, "NULL sockaddr passed into sockaddr_to_string()\n"); … … 362 357 } 363 358 if (!space) { 364 fprintf(stderr, "NULL space passed into sockaddr_to_string()\n"); 365 return NULL; 366 } 367 /*assert(spacelen > 0);*/ 359 fprintf(stderr, "NULL buffer space passed into sockaddr_to_string()\n"); 360 return NULL; 361 } 368 362 if (spacelen <= 0) { 369 fprintf(stderr, " Spacelenmust be greater than 0 when passed into sockaddr_to_string()\n");363 fprintf(stderr, "Buffer size must be greater than 0 when passed into sockaddr_to_string()\n"); 370 364 return NULL; 371 365 } -
lib/protocols_ospf.c
rf6f3ae5 r2193905 27 27 #include "libtrace.h" 28 28 #include "protocols.h" 29 #include <assert.h>30 29 #include <stdlib.h> 31 30 #include <stdio.h> // fprintf … … 45 44 return NULL; 46 45 } 47 /*assert(version != NULL && "version may not be NULL when calling trace_get_ospf_header!");*/48 46 if (!version) { 49 47 fprintf(stderr, "NULL version passed into trace_get_ospf_version()\n"); … … 70 68 char *ptr; 71 69 72 /*assert(remaining != NULL && "remaining may not be NULL when calling trace_get_ospf_contents!");*/73 70 if (!remaining) { 74 71 fprintf(stderr, "Remaining may not be NULL when calling trace_get_ospf_contents()\n"); … … 86 83 *ospf_type = 0; 87 84 *remaining = 0; 88 fprintf(stderr, "Remaining may not be less than the size of libtrace_ospf_v2_t when calling trace_get_ospf_contents()\n");89 85 return NULL; 90 86 } … … 104 100 105 101 unsigned char *link_ptr = NULL; 106 /*assert(remaining != NULL && "remaining may not be NULL when calling trace_get_first_link_from_router_lsa_v2!");*/107 102 if (!remaining) { 108 103 fprintf(stderr, "Remaining may not be NULL when calling trace_get_first_link_from_router_lsa_v2()\n"); … … 116 111 if (*remaining < sizeof(libtrace_ospf_router_lsa_v2_t)) { 117 112 *remaining = 0; 118 fprintf(stderr, "Remaining may not be less than the size of libtrace_ospf_router_lsa_v2_t when calling trace_get_first_ospf_link_from_router_lsa_v2()\n");119 113 return NULL; 120 114 } … … 132 126 unsigned char *lsa_ptr = NULL; 133 127 134 /*assert(remaining != NULL && "remaining may not be NULL when calling trace_get_first_ospf_v2_lsa!");*/135 128 if (!remaining) { 136 129 fprintf(stderr, "Remaining may not be NULL when calling trace_get_first_ospf_v2_lsa()\n"); … … 144 137 if (*remaining < sizeof(libtrace_ospf_db_desc_v2_t)) { 145 138 *remaining = 0; 146 fprintf(stderr, "Remaining may not be less than the size of libtrace_ospf_db_desc_v2_t when calling trace_get_first_ospf_lsa_from_db_desc_v2()\n");147 139 return NULL; 148 140 } … … 160 152 unsigned char *lsa_ptr = NULL; 161 153 162 /*assert(remaining != NULL && "remaining may not be NULL when calling trace_get_first_ospf_v2_lsa!");*/163 154 if (!remaining) { 164 fprintf(stderr, "Remaining may not be NULL when calling trace_get_first_ospf_v2_lsa()\n"); 155 fprintf(stderr, "Remaining may not be NULL when calling " 156 "trace_get_first_ospf_lsa_from_update_v2()\n"); 165 157 return NULL; 166 158 } 167 159 if (!ls_update) { 168 fprintf(stderr, "ls_update may not be NULL when calling trace_get_first_ospf_v2_lsa()\n"); 160 fprintf(stderr, "ls_update may not be NULL when calling " 161 "trace_get_first_ospf_lsa_from_update_v2()\n"); 169 162 return NULL; 170 163 } … … 172 165 if (*remaining < sizeof(libtrace_ospf_ls_update_t)) { 173 166 *remaining = 0; 174 fprintf(stderr, "Remaining may not be less than the size of an ls_update when calling trace_get_first_ospf_v2_lsa()\n");175 167 return NULL; 176 168 } … … 187 179 uint32_t metric = 0; 188 180 189 /*assert(as_lsa);*/190 181 if (!as_lsa) { 191 182 fprintf(stderr, "NULL as_lsa passed into trace_get_ospf_metric_from_as_external_lsa_v2()\n"); … … 206 197 uint32_t metric = 0; 207 198 208 /*assert(sum_lsa);*/209 199 if (!sum_lsa) { 210 200 fprintf(stderr, "NULL sum_lsa passed into trace_get_ospf_metric_from_summary_lsa_v2()\n"); -
lib/protocols_pktmeta.c
r25a3255 r2193905 27 27 #include "libtrace.h" 28 28 #include "protocols.h" 29 #include <assert.h>30 29 31 30 #ifdef HAVE_WANDDER … … 156 155 uint32_t dummyrem; 157 156 void *pktbuf = NULL; 158 /*assert(packet != NULL);*/159 157 if (!packet) { 160 158 fprintf(stderr, "NULL packet passed into trace_get_packet_meta()"); 161 159 return NULL; 162 160 } 163 /*assert(linktype != NULL);*/164 161 if (!linktype) { 165 162 fprintf(stderr, "NULL linkype passed into trace_get_packet_meta()"); … … 210 207 uint16_t next = 0; 211 208 212 /*assert(meta != NULL);*/213 209 if (!meta) { 214 210 fprintf(stderr, "NULL meta passed into trace_get_payload_from_meta()"); 215 211 return NULL; 216 212 } 217 /*assert(linktype != NULL);*/218 213 if (!linktype) { 219 214 fprintf(stderr, "NULL linktype passed into trace_get_payload_from_meta()"); 220 215 return NULL; 221 216 } 222 /*assert(remaining != NULL);*/223 217 if (!remaining) { 224 218 fprintf(stderr, "NULL remaining passed into trace_get_payload_from_meta()"); -
lib/protocols_transport.c
r54a76f2 r2193905 29 29 #include "protocols.h" 30 30 #include "checksum.h" 31 #include <assert.h>32 31 #include <stdlib.h> 33 32 #include <stdio.h> // fprintf … … 568 567 sum += add_checksum(header, (uint16_t)plen); 569 568 *csum = ntohs(finish_checksum(sum)); 570 //assert(0); 571 569 572 570 return (uint16_t *)csum_ptr; 573 571 } -
lib/trace.c
r1ed3f1e r2193905 201 201 202 202 libtrace->io = wandio_create(filename); 203 if (!libtrace->io) 203 if (!libtrace->io) { 204 trace_set_err(libtrace,TRACE_ERR_URI_NOT_FOUND,"Unable to find URI (%s)", filename); 204 205 return; 206 } 205 207 206 208 /* Try and guess based on file magic */ … … 216 218 * used to probe the file magic */ 217 219 wandio_destroy(libtrace->io); 220 trace_set_err(libtrace,TRACE_ERR_BAD_FORMAT,"Unable to guess format (%s)", filename); 218 221 return; 219 222 } … … 252 255 } 253 256 254 /*assert(uri && "Passing NULL to trace_create makes me a very sad program");*/255 257 if(!uri) { 256 258 trace_set_err(libtrace, TRACE_ERR_URI_NULL, "NULL uri passed to trace_create()"); … … 310 312 /* Could not parse the URI nicely */ 311 313 guess_format(libtrace,uri); 312 if (!libtrace->format) { 313 /* Check if the file exists */ 314 FILE *file; 315 if(!(file=fopen(uri, "r"))) { 316 trace_set_err(libtrace,TRACE_ERR_URI_NOT_FOUND,"Unable to find URI (%s)",uri); 317 } else { 318 fclose(file); 319 trace_set_err(libtrace,TRACE_ERR_BAD_FORMAT,"Unable to guess format (%s)",uri); 320 } 314 if (trace_is_err(libtrace)) { 321 315 return libtrace; 322 316 } … … 350 344 if (libtrace->format->init_input) { 351 345 int err=libtrace->format->init_input(libtrace); 352 /*assert (err==-1 || err==0);*/353 346 if (err==-1) { 354 347 /* init_input should call trace_set_err to set the … … 536 529 DLLEXPORT int trace_start(libtrace_t *libtrace) 537 530 { 538 /*assert(libtrace);*/539 531 if(!libtrace) { 540 532 fprintf(stderr, "NULL trace passed to trace_start()\n"); … … 558 550 DLLEXPORT int trace_start_output(libtrace_out_t *libtrace) 559 551 { 560 /*assert(libtrace);*/561 552 if(!libtrace) { 562 553 fprintf(stderr, "NULL trace passed to trace_start_output()\n"); … … 576 567 DLLEXPORT int trace_pause(libtrace_t *libtrace) 577 568 { 578 /*assert(libtrace);*/579 569 if(!libtrace) { 580 570 fprintf(stderr, "NULL trace passed to trace_pause()\n"); … … 589 579 if (!libtrace_parallel && libtrace->last_packet) 590 580 trace_fin_packet(libtrace->last_packet); 591 /*assert(libtrace->last_packet == NULL);*/592 581 if(libtrace->last_packet != NULL) { 593 582 trace_set_err(libtrace, TRACE_ERR_PAUSE_FIN, "Unable to remove all data stored against trace in trace_pause()"); … … 734 723 int i; 735 724 736 /*assert(libtrace);*/737 725 if(!libtrace) { 738 fprintf(stderr, "NULL trace passed to trace_dest ory()\n");726 fprintf(stderr, "NULL trace passed to trace_destroy()\n"); 739 727 return; 740 728 } … … 759 747 trace_fin_packet(libtrace->last_packet); 760 748 } 761 /*assert(libtrace->last_packet == NULL);*/762 749 if (libtrace->last_packet != NULL) { 763 750 trace_set_err(libtrace, TRACE_ERR_PAUSE_FIN, "Unable to remove all data stored against trace in trace_destroy()"); … … 831 818 832 819 DLLEXPORT void trace_destroy_dead(libtrace_t *libtrace) { 833 /*assert(libtrace);*/834 820 if(!libtrace) { 835 fprintf(stderr, "NULL trace passed to trace_dest ory_dead()\n");821 fprintf(stderr, "NULL trace passed to trace_destroy_dead()\n"); 836 822 return; 837 823 } … … 853 839 */ 854 840 DLLEXPORT void trace_destroy_output(libtrace_out_t *libtrace) { 855 /*assert(libtrace);*/856 841 if(!libtrace) { 857 842 fprintf(stderr, "NULL trace passed to trace_destroy_output()\n"); … … 1002 987 DLLEXPORT int trace_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) { 1003 988 1004 /*assert(libtrace && "You called trace_read_packet() with a NULL libtrace parameter!\n");*/1005 989 if (!libtrace) { 1006 990 fprintf(stderr, "NULL trace passed to trace_read_packet()\n"); … … 1016 1000 } 1017 1001 1018 /*assert(packet);*/1019 1002 if (!packet) { 1020 1003 trace_set_err(libtrace, TRACE_ERR_NULL_PACKET, "NULL packet passed into trace_read_packet()"); … … 1108 1091 void *buffer, libtrace_rt_types_t rt_type, uint32_t flags) { 1109 1092 1110 /*assert(trace);*/1111 1093 if (!trace) { 1112 1094 fprintf(stderr, "NULL trace passed into trace_prepare_packet()\n"); … … 1114 1096 } 1115 1097 1116 /*assert(packet);*/1117 1098 if (!packet) { 1118 1099 trace_set_err(trace, TRACE_ERR_NULL_TRACE, "NULL packet passed into trace_prepare_packet()"); … … 1153 1134 */ 1154 1135 DLLEXPORT int trace_write_packet(libtrace_out_t *libtrace, libtrace_packet_t *packet) { 1155 /*assert(libtrace);*/ 1136 1156 1137 if (!libtrace) { 1157 1138 fprintf(stderr, "NULL trace passed into trace_write_packet()\n"); 1158 1139 return TRACE_ERR_NULL_TRACE; 1159 1140 } 1160 /*assert(packet);*/1161 1141 if (!packet) { 1162 1142 trace_set_err_out(libtrace, TRACE_ERR_NULL_PACKET, "NULL trace passed into trace_write_packet()"); … … 1166 1146 if (!libtrace->started) { 1167 1147 trace_set_err_out(libtrace,TRACE_ERR_BAD_STATE, 1168 "You must call trace_start () before calling trace_write_packet()");1148 "You must call trace_start_output() before calling trace_write_packet()"); 1169 1149 return -1; 1170 1150 } … … 1191 1171 libtrace_linktype_t ltype; 1192 1172 1193 /*assert(packet != NULL);*/1194 1173 if (!packet) { 1195 1174 fprintf(stderr, "NULL packet passed into trace_get_packet_buffer()\n"); … … 1227 1206 wire_len = trace_get_wire_length(packet); 1228 1207 1229 /*assert(cap_len >= 0);*/1230 1208 if (!(cap_len >= 0)) { 1231 1209 fprintf(stderr, "Was expecting capture length of atleast 0 in trace_get_packet_buffer()\n"); … … 1423 1401 } 1424 1402 1425 /*assert(packet->capture_length < LIBTRACE_PACKET_BUFSIZE);*/1426 1403 if (!(packet->capture_length < LIBTRACE_PACKET_BUFSIZE)) { 1427 1404 fprintf(stderr, "Capture length is greater than the buffer size in trace_get_capture_length()\n"); … … 1453 1430 } 1454 1431 1455 /*assert(packet->wire_length < LIBTRACE_PACKET_BUFSIZE);*/1456 1432 if (!(packet->wire_length < LIBTRACE_PACKET_BUFSIZE)) { 1457 1433 fprintf(stderr, "Wire length is greater than the buffer size in trace_get_wire_length()\n"); … … 1523 1499 libtrace_eventobj_t event = {TRACE_EVENT_IOWAIT,0,0.0,0}; 1524 1500 1525 1526 /*assert(trace && "You called trace_event() with a NULL trace object!");*/1527 1501 if (!trace) { 1528 1502 fprintf(stderr, "NULL trace passed into trace_event()"); … … 1530 1504 return event; 1531 1505 } 1532 /*assert(packet && "You called trace_event() with a NULL packet object!");*/1533 1506 if (!packet) { 1534 1507 trace_set_err(trace, TRACE_ERR_NULL_PACKET, "NULL packet passed into trace_event()"); … … 1643 1616 } 1644 1617 1645 /*assert(filter && "You called trace_bpf_compile() with a NULL filter");*/1646 1618 if (!filter) { 1647 1619 trace_set_err(packet->trace, … … 1670 1642 return -1; 1671 1643 } 1672 /*assert (pthread_mutex_lock(&mutex) == 0);*/1673 1644 pthread_mutex_lock(&mutex); 1674 1645 /* Make sure not one bet us to this */ 1675 1646 if (filter->flag) { 1676 /*assert (pthread_mutex_unlock(&mutex) == 0);*/1677 1647 pthread_mutex_unlock(&mutex); 1678 1648 return -1; … … 1682 1652 1500U); 1683 1653 /* build filter */ 1684 /*assert(pcap && "Unable to open pcap_t for compiling filters trace_bpf_compile()");*/1685 1654 if (!pcap) { 1686 1655 trace_set_err(packet->trace, TRACE_ERR_BAD_FILTER, … … 1695 1664 pcap_geterr(pcap)); 1696 1665 pcap_close(pcap); 1697 /*assert (pthread_mutex_unlock(&mutex) == 0);*/1698 1666 pthread_mutex_unlock(&mutex); 1699 1667 return -1; … … 1701 1669 pcap_close(pcap); 1702 1670 filter->flag=1; 1703 /*assert (pthread_mutex_unlock(&mutex) == 0);*/1704 1671 pthread_mutex_unlock(&mutex); 1705 1672 } 1706 1673 return 0; 1707 1674 #else 1708 /*assert(!"Internal bug: This should never be called when BPF not enabled");*/1709 1675 trace_set_err(packet->trace,TRACE_ERR_OPTION_UNAVAIL, 1710 1676 "Feature unavailable"); … … 1726 1692 #endif 1727 1693 1728 /*assert(packet && "You called trace_apply_filter() with a NULL packet");*/1729 1694 if (!packet) { 1730 1695 fprintf(stderr, "NULL packet passed into trace_apply_filter()\n"); 1731 1696 return TRACE_ERR_NULL_PACKET; 1732 1697 } 1733 /*assert(filter && "You called trace_apply_filter() with a NULL filter");*/1734 1698 if (!filter) { 1735 1699 trace_set_err(packet->trace, TRACE_ERR_NULL_FILTER, … … 1806 1770 #endif 1807 1771 1808 /*assert(filter->flag);*/1809 1772 if (!filter->flag) { 1810 1773 trace_set_err(packet->trace, TRACE_ERR_BAD_FILTER, … … 1838 1801 libtrace_direction_t direction) 1839 1802 { 1840 /*assert(packet);*/1841 1803 if (!packet) { 1842 1804 fprintf(stderr, "NULL packet passed into trace_set_direction()\n"); … … 1859 1821 DLLEXPORT libtrace_direction_t trace_get_direction(const libtrace_packet_t *packet) 1860 1822 { 1861 /*assert(packet);*/1862 1823 if (!packet) { 1863 1824 fprintf(stderr, "NULL packet passed into trace_set_direction()\n"); … … 2000 1961 */ 2001 1962 DLLEXPORT size_t trace_set_capture_length(libtrace_packet_t *packet, size_t size) { 2002 /*assert(packet);*/2003 1963 if (!packet) { 2004 1964 fprintf(stderr, "NULL packet passed into trace_set_capture_length()\n"); … … 2045 2005 2046 2006 enum base_format_t trace_get_format(libtrace_packet_t *packet) { 2047 /* Not sure what to do here, can we add a new trace_format for errors? */2048 /*assert(packet);*/2049 2007 if (!packet) { 2050 2008 fprintf(stderr, "NULL packet passed into trace_get_format()\n"); … … 2293 2251 2294 2252 /* Now fill in the libtrace packet itself */ 2295 /*assert(deadtrace);*/2296 2253 if (!deadtrace) { 2297 fprintf(stderr, "Unable to create d ead tracetrace_construct_packet()\n");2254 fprintf(stderr, "Unable to create dummy trace for use within trace_construct_packet()\n"); 2298 2255 return; 2299 2256 } … … 2327 2284 uint64_t ret; 2328 2285 2329 /*assert(trace);*/2330 2286 if (!trace) { 2331 2287 fprintf(stderr, "NULL trace passed to trace_get_received_packets()\n"); … … 2354 2310 uint64_t trace_get_filtered_packets(libtrace_t *trace) 2355 2311 { 2356 /*assert(trace);*/2357 2312 if (!trace) { 2358 2313 fprintf(stderr, "NULL trace passed to trace_get_filtered_packets()\n"); … … 2389 2344 uint64_t trace_get_dropped_packets(libtrace_t *trace) 2390 2345 { 2391 /*assert(trace);*/2392 2346 if (!trace) { 2393 2347 fprintf(stderr, "NULL trace passed into trace_get_dropped_packets()\n"); … … 2416 2370 uint64_t trace_get_accepted_packets(libtrace_t *trace) 2417 2371 { 2418 /*assert(trace);*/2419 2372 if (!trace) { 2420 2373 fprintf(stderr, "NULL trace passed into trace_get_accepted_packets()\n"); … … 2438 2391 uint64_t ret = 0; 2439 2392 int i; 2440 /*assert(trace);*/2441 2393 if (!trace) { 2442 2394 fprintf(stderr, "NULL trace passed into trace_get_statistics()\n"); … … 2448 2400 stat = trace->stats; 2449 2401 } 2450 /*assert(stat->magic == LIBTRACE_STAT_MAGIC && "Please use" 2451 "trace_create_statistics() to allocate statistics");*/ 2452 if (!(stat->magic == LIBTRACE_STAT_MAGIC)) { 2453 trace_set_err(trace, TRACE_ERR_STAT, "Use trace_create_statistics() to allocate statistics in trace_get_statistics()"); 2402 if (stat->magic != LIBTRACE_STAT_MAGIC) { 2403 trace_set_err(trace, TRACE_ERR_STAT, "Use trace_create_statistics() to allocate " 2404 "statistics prior to calling trace_get_statistics()"); 2454 2405 return NULL; 2455 2406 } … … 2499 2450 libtrace_stat_t *stat) 2500 2451 { 2501 /*assert(trace && stat);*/2502 2452 if (!trace) { 2503 2453 fprintf(stderr, "NULL trace passed into trace_get_thread_statistics()\n"); … … 2505 2455 } 2506 2456 if (!stat) { 2507 trace_set_err(trace, TRACE_ERR_STAT, "Stat is NULL trace_get_thread_statistics()"); 2457 trace_set_err(trace, TRACE_ERR_STAT, "NULL statistics structure passed into " 2458 "trace_get_thread_statistics()"); 2508 2459 return; 2509 2460 } 2510 /*assert(stat->magic == LIBTRACE_STAT_MAGIC && "Please use" 2511 "trace_create_statistics() to allocate statistics");*/ 2512 if (!(stat->magic == LIBTRACE_STAT_MAGIC)) { 2513 trace_set_err(trace, TRACE_ERR_STAT, 2514 "Use trace_create_statistics() to allocate statistics in trace_get_thread_statistics()"); 2461 if (stat->magic != LIBTRACE_STAT_MAGIC) { 2462 trace_set_err(trace, TRACE_ERR_STAT, "Use trace_create_statistics() to " 2463 "allocate statistics prior to calling trace_get_thread_statistics()"); 2515 2464 return; 2516 2465 } … … 2547 2496 libtrace_stat_t *c) { 2548 2497 2549 if (!(a->magic == LIBTRACE_STAT_MAGIC) 2550 || !(b->magic == LIBTRACE_STAT_MAGIC) 2551 || !(c->magic == LIBTRACE_STAT_MAGIC)) { 2552 fprintf(stderr, "Use trace_create_statistics() to allocate statistics in trace_subtract_statistics()\n"); 2498 if (a->magic != LIBTRACE_STAT_MAGIC 2499 || b->magic != LIBTRACE_STAT_MAGIC 2500 || c->magic != LIBTRACE_STAT_MAGIC) { 2501 fprintf(stderr, "Use trace_create_statistics() to allocate statistics prior to " 2502 "calling trace_subtract_statistics()\n"); 2553 2503 return; 2554 2504 } 2555 2556 /*assert(a->magic == LIBTRACE_STAT_MAGIC && "Please use"2557 "trace_create_statistics() to allocate statistics");2558 assert(b->magic == LIBTRACE_STAT_MAGIC && "Please use"2559 "trace_create_statistics() to allocate statistics");2560 assert(c->magic == LIBTRACE_STAT_MAGIC && "Please use"2561 "trace_create_statistics() to allocate statistics");*/2562 2505 2563 2506 #define X(x) \ … … 2574 2517 void trace_add_statistics(const libtrace_stat_t *a, const libtrace_stat_t *b, 2575 2518 libtrace_stat_t *c) { 2576 if (!(a->magic == LIBTRACE_STAT_MAGIC) 2577 || !(b->magic == LIBTRACE_STAT_MAGIC) 2578 || !(c->magic == LIBTRACE_STAT_MAGIC)) { 2579 fprintf(stderr, "Use trace_create_statistics() to allocate statistics in trace_add_statistics()\n"); 2519 if (a->magic != LIBTRACE_STAT_MAGIC 2520 || b->magic != LIBTRACE_STAT_MAGIC 2521 || c->magic != LIBTRACE_STAT_MAGIC) { 2522 fprintf(stderr, "Use trace_create_statistics() to allocate statistics prior to " 2523 "calling trace_add_statistics()\n"); 2580 2524 return; 2581 2525 } 2582 2583 /*assert(a->magic == LIBTRACE_STAT_MAGIC && "Please use"2584 "trace_create_statistics() to allocate statistics");2585 assert(b->magic == LIBTRACE_STAT_MAGIC && "Please use"2586 "trace_create_statistics() to allocate statistics");2587 assert(c->magic == LIBTRACE_STAT_MAGIC && "Please use"2588 "trace_create_statistics() to allocate statistics");*/2589 2526 2590 2527 #define X(x) \ … … 2600 2537 2601 2538 int trace_print_statistics(const libtrace_stat_t *s, FILE *f, const char *format) { 2602 /*assert(s->magic == LIBTRACE_STAT_MAGIC && "Please use" 2603 "trace_create_statistics() to allocate statistics");*/ 2604 if (!(s->magic == LIBTRACE_STAT_MAGIC)) { 2605 fprintf(stderr, "Use trace_create_statistics() to allocate statistics in trace_print_statistics\n"); 2539 if (s->magic != LIBTRACE_STAT_MAGIC) { 2540 fprintf(stderr, "Use trace_create_statistics() to allocate statistics prior to " 2541 "calling trace_print_statistics\n"); 2606 2542 return TRACE_ERR_STAT; 2607 2543 } … … 2644 2580 2645 2581 void register_format(struct libtrace_format_t *f) { 2646 /*assert(f->next==NULL);*/ /* Can't register a format twice */ 2647 if (!(f->next==NULL)) { 2582 if (f->next != NULL) { 2648 2583 fprintf(stderr, "You cannot register a format twice in register_format()"); 2649 2584 return; -
lib/trace_parallel.c
rb6ff245 r2193905 271 271 DLLEXPORT bool trace_has_reporter(libtrace_t * libtrace) 272 272 { 273 /*assert(libtrace->state != STATE_NEW);*/274 273 if (!(libtrace->state != STATE_NEW)) { 275 274 trace_set_err(libtrace, TRACE_ERR_BAD_STATE, "Cannot check reporter for the current state in trace_has_reporter()"); … … 372 371 static inline bool trace_supports_parallel(libtrace_t *trace) 373 372 { 374 /*assert(trace);*/375 373 if (!trace) { 376 374 fprintf(stderr, "NULL trace passed into trace_supports_parallel()\n"); 377 375 return false; 378 376 } 379 /*assert(trace->format);*/380 377 if (!trace->format) { 381 378 trace_set_err(trace, TRACE_ERR_BAD_FORMAT, … … 413 410 return &libtrace->perpkt_threads[i]; 414 411 } 415 return NULL;412 pthread_exit(NULL); 416 413 } 417 414 … … 503 500 trace_fin_packet(*packet); 504 501 } else { 505 /*assert((*packet)->error == READ_TICK);*/ 506 if (!((*packet)->error == READ_TICK)) { 502 if ((*packet)->error != READ_TICK) { 507 503 trace_set_err(trace, TRACE_ERR_BAD_STATE, 508 " Packet is not in READ_TICK state in dispath_packet()");504 "dispatch_packet() called with invalid 'packet'"); 509 505 return -1; 510 506 } … … 551 547 } else { 552 548 /* Break early */ 553 /*assert(ret == READ_MESSAGE);*/ 554 if (!(ret == READ_MESSAGE)) { 549 if (ret != READ_MESSAGE) { 555 550 trace_set_err(trace, TRACE_ERR_UNKNOWN_OPTION, 556 " Expected READ_MESSAGE in dispatch_packets()");551 "dispatch_packets() called with at least one invalid packet"); 557 552 return -1; 558 553 } … … 606 601 } else if (ret != READ_MESSAGE) { 607 602 /* Ignore messages we pick these up next loop */ 608 /*assert (ret == READ_EOF || ret == READ_ERROR);*/609 603 if (!(ret == READ_EOF || ret == READ_ERROR)) { 610 604 trace_set_err(trace, TRACE_ERR_PAUSE_PTHREAD, … … 617 611 ASSERT_RET(trace->pread(trace, t, &packet, 1), <= 0); 618 612 // No packets after this should have any data in them 619 /*assert(packet->error <= 0);*/ 620 if (!(packet->error <= 0)) { 621 trace_set_err(trace, TRACE_ERR_BAD_PACKET, 622 "Expected no data from packets however found some in trace_perpkt_thread_pause()"); 613 if (packet->error > 0) { 614 trace_set_err(trace, TRACE_ERR_BAD_PACKET, "Bogus data in " 615 "libtrace ring buffer after pausing perpkt thread"); 623 616 return -1; 624 617 } … … 658 651 ASSERT_RET(pthread_mutex_lock(&trace->libtrace_lock), == 0); 659 652 t = get_thread_table(trace); 660 /*assert(t);*/661 653 if (!t) { 662 654 trace_set_err(trace, TRACE_ERR_THREAD, "Unable to get thread table in perpkt_threads_entry()"); 663 return NULL;655 pthread_exit(NULL); 664 656 } 665 657 if (trace->state == STATE_ERROR) { … … 703 695 goto error; 704 696 } 705 /*assert(ret == 1);*/ 706 if (!(ret == 1)) { 697 if (ret != 1) { 707 698 fprintf(stderr, "Unknown error pausing thread in perpkt_threads_entry()\n"); 708 return NULL;699 pthread_exit(NULL); 709 700 } 710 701 continue; … … 730 721 } 731 722 if (!trace->pread) { 732 /*assert(packets[0]);*/733 723 if (!packets[0]) { 734 fprintf(stderr, " Packet missing in perpkt_threads_entry()\n");735 return NULL;724 fprintf(stderr, "Unable to read into NULL packet structure\n"); 725 pthread_exit(NULL); 736 726 } 737 727 nb_packets = trace_read_packet(trace, packets[0]); … … 826 816 int pkt_skipped = 0; 827 817 828 /*assert(trace_has_dedicated_hasher(trace));*/829 818 if (!trace_has_dedicated_hasher(trace)) { 830 819 fprintf(stderr, "Trace does not have hasher associated with it in hasher_entry()\n"); 831 return NULL;820 pthread_exit(NULL); 832 821 } 833 822 /* Wait until all threads are started and objects are initialised (ring buffers) */ 834 823 ASSERT_RET(pthread_mutex_lock(&trace->libtrace_lock), == 0); 835 824 t = &trace->hasher_thread; 836 /*assert(t->type == THREAD_HASHER && pthread_equal(pthread_self(), t->tid));*/837 825 if (!(t->type == THREAD_HASHER && pthread_equal(pthread_self(), t->tid))) { 838 826 fprintf(stderr, "Incorrect thread type or non matching thread IDs in hasher_entry()\n"); 839 return NULL;827 pthread_exit(NULL); 840 828 } 841 829 … … 857 845 if (!pkt_skipped) 858 846 libtrace_ocache_alloc(&trace->packet_freelist, (void **) &packet, 1, 1); 859 /*assert(packet);*/860 847 if (!packet) { 861 fprintf(stderr, "Cannot hash and queue a NULL packet in hasher_entry()\n"); 862 return NULL; 848 fprintf(stderr, "Hasher thread was unable to get a fresh packet from the " 849 "object cache\n"); 850 pthread_exit(NULL); 863 851 } 864 852 … … 879 867 case MESSAGE_DO_STOP: 880 868 /* Either FINISHED or FINISHING */ 881 /*assert(trace->started == false);*/882 869 if (!(trace->started == false)) { 883 fprintf(stderr, "Expected trace to have not started in hasher_entry()\n"); 884 return NULL; 870 fprintf(stderr, "STOP message received by hasher, but " 871 "trace is still active\n"); 872 pthread_exit(NULL); 885 873 } 886 874 /* Mark the current packet as EOF */ … … 922 910 } 923 911 pkt_skipped = 0; 924 } else {925 /*assert(!"Dropping a packet!!");*/926 fprintf(stderr, "Expected THREAD_FINISHED state in hasher_entry()\n");927 return NULL;928 pkt_skipped = 1; // Reuse that packet no one read it929 912 } 930 913 } … … 1054 1037 sent once*/ 1055 1038 if (packets[i]->error != READ_MESSAGE) { 1056 /*assert(t->format_data == NULL);*/1057 if (!(t->format_data == NULL)) {1058 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT,1059 "Expected format data to be NULL in trace_pread_packet_hasher_thread()");1060 return -1;1061 }1062 1039 t->format_data = packets[i]; 1063 1040 } … … 1219 1196 break; 1220 1197 case MESSAGE_DO_PAUSE: 1221 /*assert(trace->combiner.pause);*/ 1222 if(!(trace->combiner.pause)) { 1223 trace_set_err(trace, TRACE_ERR_COMBINER, 1224 "Expected combiner to be paused in reporter_entry()"); 1225 return NULL; 1198 if(trace->combiner.pause) { 1199 trace->combiner.pause(trace, &trace->combiner); 1226 1200 } 1227 trace->combiner.pause(trace, &trace->combiner);1228 1201 send_message(trace, t, MESSAGE_PAUSING, 1229 1202 (libtrace_generic_t) {0}, t); … … 1247 1220 thread_change_state(trace, &trace->reporter_thread, THREAD_FINISHED, true); 1248 1221 print_memory_stats(); 1249 return NULL;1222 pthread_exit(NULL); 1250 1223 } 1251 1224 … … 1283 1256 libtrace_message_t msg; 1284 1257 libtrace_message_queue_get(&t->messages, &msg); 1285 /*assert(msg.code == MESSAGE_DO_STOP);*/ 1286 if (!(msg.code == MESSAGE_DO_STOP)) { 1258 if (msg.code != MESSAGE_DO_STOP) { 1287 1259 fprintf(stderr, "Unexpected message code in keepalive_entry()\n"); 1288 return NULL;1260 pthread_exit(NULL); 1289 1261 } 1290 1262 goto done; … … 1301 1273 1302 1274 thread_change_state(trace, t, THREAD_FINISHED, true); 1303 return NULL;1275 pthread_exit(NULL); 1304 1276 } 1305 1277 … … 1351 1323 return READ_MESSAGE; 1352 1324 } else { 1353 /*assert(!"trace_delay_packet: Unexpected return from select");*/1354 1325 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Unexpected return from select in delay_tracetime()"); 1355 1326 return -1; … … 1405 1376 size_t nb_packets) { 1406 1377 int i; 1407 /*assert(libtrace && "libtrace is NULL in trace_read_packet()");*/1408 1378 if (!libtrace) { 1409 1379 fprintf(stderr, "NULL trace passed into trace_read_packet()\n"); 1410 1380 return TRACE_ERR_NULL_TRACE; 1411 1381 } 1412 /*assert(nb_packets);*/ 1413 if (!nb_packets) { 1382 if (nb_packets <= 0) { 1414 1383 trace_set_err(libtrace, TRACE_ERR_NULL, 1415 " NULL nb_packets passed intotrace_pread_packet_wrapper()");1384 "nb_packets must be greater than zero in trace_pread_packet_wrapper()"); 1416 1385 return -1; 1417 1386 } … … 1427 1396 int ret; 1428 1397 for (i = 0; i < (int) nb_packets; ++i) { 1429 /*assert(i[packets]); <--- is this ment to be packets[i]?? */1430 1398 if (!i[packets]) { 1431 trace_set_err(libtrace, TRACE_ERR_BAD_STATE, "NULL packets in trace_read_packet()"); 1399 trace_set_err(libtrace, TRACE_ERR_BAD_STATE, "NULL packets in " 1400 "trace_pread_packet_wrapper()"); 1432 1401 return -1; 1433 1402 } … … 1490 1459 } 1491 1460 1492 /*assert(libtrace_parallel);*/1493 1461 if (!libtrace_parallel) { 1494 trace_set_err(libtrace, TRACE_ERR_THREAD, "Expected parallel trace in trace_prestart()"); 1462 trace_set_err(libtrace, TRACE_ERR_THREAD, "Trace_prestart() has been called on a " 1463 "non-parallel libtrace input?"); 1495 1464 return -1; 1496 1465 } 1497 /*assert(!libtrace->perpkt_thread_states[THREAD_RUNNING]);*/1498 if (!(!libtrace->perpkt_thread_states[THREAD_RUNNING])) {1499 trace_set_err(libtrace, TRACE_ERR_THREAD, "Expected no running threads in trace_prestart()");1466 if (libtrace->perpkt_thread_states[THREAD_RUNNING]) { 1467 trace_set_err(libtrace, TRACE_ERR_THREAD, "Cannot restart a parallel libtrace input " 1468 "while it is still running"); 1500 1469 return -1; 1501 1470 } … … 1504 1473 pthread_spin_lock(&libtrace->first_packets.lock); 1505 1474 for (i = 0; i < libtrace->perpkt_thread_count; ++i) { 1506 /*assert(!!libtrace->perpkt_threads[i].recorded_first == !!libtrace->first_packets.packets[i].packet);*/1507 if (!(!!libtrace->perpkt_threads[i].recorded_first == !!libtrace->first_packets.packets[i].packet)) {1508 trace_set_err(libtrace, TRACE_ERR_THREAD, "Expected different first packet in trace_pstart()");1509 return -1;1510 }1511 1475 if (libtrace->first_packets.packets[i].packet) { 1512 1476 trace_destroy_packet(libtrace->first_packets.packets[i].packet); … … 1518 1482 } 1519 1483 } 1520 /*assert(libtrace->first_packets.count == 0);*/ 1521 if (!(libtrace->first_packets.count == 0)) { 1484 if (libtrace->first_packets.count != 0) { 1522 1485 trace_set_err(libtrace, TRACE_ERR_THREAD, "Expected a first packets count of 0 in trace_pstart()"); 1523 1486 return -1; … … 1661 1624 #endif 1662 1625 int ret; 1663 /*assert(t->type == THREAD_EMPTY);*/ 1664 if (!(t->type == THREAD_EMPTY)) { 1626 if (t->type != THREAD_EMPTY) { 1665 1627 trace_set_err(trace, TRACE_ERR_THREAD, 1666 1628 "Expected thread type of THREAD_EMPTY in trace_start_thread()"); … … 1673 1635 t->state = THREAD_RUNNING; 1674 1636 1675 /*assert(name);*/1676 1637 if (!name) { 1677 1638 trace_set_err(trace, TRACE_ERR_THREAD, "NULL thread name in trace_start_thread()"); … … 1800 1761 char name[24]; 1801 1762 sigset_t sig_before, sig_block_all; 1802 /*assert(libtrace);*/1803 1763 if (!libtrace) { 1804 1764 fprintf(stderr, "NULL trace passed to trace_pstart()\n"); … … 2026 1986 ASSERT_RET(pthread_mutex_lock(&libtrace->libtrace_lock), == 0); 2027 1987 libtrace_change_state(libtrace, STATE_NEW, false); 2028 /*assert(libtrace->perpkt_thread_states[THREAD_RUNNING] == 0);*/ 2029 if (!(libtrace->perpkt_thread_states[THREAD_RUNNING] == 0)) { 1988 if (libtrace->perpkt_thread_states[THREAD_RUNNING] != 0) { 2030 1989 trace_set_err(libtrace, TRACE_ERR_THREAD, "Expected 0 running threads in trace_pstart()"); 2031 1990 return -1; … … 2122 2081 libtrace_thread_t *t; 2123 2082 int i; 2124 /*assert(libtrace);*/2125 2083 if (!libtrace) { 2126 2084 fprintf(stderr, "NULL trace passed into trace_ppause()\n"); … … 2259 2217 int i, err; 2260 2218 libtrace_message_t message = {0, {.uint64=0}, NULL}; 2261 /*assert(libtrace);*/2262 2219 if (!libtrace) { 2263 2220 fprintf(stderr, "NULL trace passed into trace_pstop()\n"); … … 2361 2318 // the producer (or any other threads) don't block. 2362 2319 libtrace_packet_t * packet; 2363 /*assert(libtrace->perpkt_threads[i].state == THREAD_FINISHED);*/ 2364 if (!(libtrace->perpkt_threads[i].state == THREAD_FINISHED)) { 2320 if (libtrace->perpkt_threads[i].state != THREAD_FINISHED) { 2365 2321 trace_set_err(libtrace, TRACE_ERR_THREAD_STATE, 2366 "Expected processing thread s state THREAD_FINISHED in trace_join()");2322 "Expected processing thread state to be THREAD_FINISHED in trace_join()"); 2367 2323 return; 2368 2324 } … … 2375 2331 if (trace_has_dedicated_hasher(libtrace)) { 2376 2332 pthread_join(libtrace->hasher_thread.tid, NULL); 2377 /*assert(libtrace->hasher_thread.state == THREAD_FINISHED);*/ 2378 if (!(libtrace->hasher_thread.state == THREAD_FINISHED)) { 2333 if (libtrace->hasher_thread.state != THREAD_FINISHED) { 2379 2334 trace_set_err(libtrace, TRACE_ERR_THREAD_STATE, 2380 "Expected hasher thread state THREAD_FINISHED in trace_join()");2335 "Expected hasher thread state to be THREAD_FINISHED in trace_join()"); 2381 2336 return; 2382 2337 } … … 2392 2347 trace_destroy_packet(packet); 2393 2348 if (trace_has_dedicated_hasher(libtrace)) { 2394 /*assert(libtrace_ringbuffer_is_empty(&libtrace->perpkt_threads[i].rbuffer));*/ 2395 if (!(libtrace_ringbuffer_is_empty(&libtrace->perpkt_threads[i].rbuffer))) { 2349 if (!libtrace_ringbuffer_is_empty(&libtrace->perpkt_threads[i].rbuffer)) { 2396 2350 trace_set_err(libtrace, TRACE_ERR_THREAD, 2397 2351 "Expected processing threads ring buffers to be empty in trace_join()"); … … 2405 2359 if (trace_has_reporter(libtrace)) { 2406 2360 pthread_join(libtrace->reporter_thread.tid, NULL); 2407 /*assert(libtrace->reporter_thread.state == THREAD_FINISHED);*/ 2408 if (!(libtrace->reporter_thread.state == THREAD_FINISHED)) { 2361 if (libtrace->reporter_thread.state != THREAD_FINISHED) { 2409 2362 trace_set_err(libtrace, TRACE_ERR_THREAD_STATE, 2410 2363 "Expected reporting thread state to be THREAD_FINISHED in trace_join()"); … … 2517 2470 res.key = key; 2518 2471 res.value = value; 2519 /*assert(libtrace->combiner.publish);*/2520 2472 if (!libtrace->combiner.publish) { 2521 fprintf(stderr, " Unable to publish result in trace_publish_result()\n");2473 fprintf(stderr, "Combiner has no publish method -- can not publish results!\n"); 2522 2474 return; 2523 2475 } … … 2673 2625 /* Note update documentation on trace_set_configuration */ 2674 2626 static void config_string(struct user_configuration *uc, char *key, size_t nkey, char *value, size_t nvalue) { 2675 /*assert(key);*/2676 2627 if (!key) { 2677 2628 fprintf(stderr, "NULL key passed to config_string()\n"); 2678 2629 return; 2679 2630 } 2680 /*assert(value);*/2681 2631 if (!value) { 2682 2632 fprintf(stderr, "NULL value passed to config_string()\n"); 2683 2633 return; 2684 2634 } 2685 /*assert(uc);*/2686 2635 if (!uc) { 2687 2636 fprintf(stderr, "NULL uc (user_configuration) passed to config_string()\n"); … … 2734 2683 char value[100]; 2735 2684 char *dup; 2736 /*assert(trace);*/2737 2685 if (!trace) { 2738 2686 fprintf(stderr, "NULL trace passed into trace_set_configuration()\n"); 2739 2687 return TRACE_ERR_NULL_TRACE; 2740 2688 } 2741 /*assert(str);*/2742 2689 if (!str) { 2743 2690 trace_set_err(trace, TRACE_ERR_CONFIG, "NULL configuration string passed to trace_set_configuration()"); … … 2754 2701 config_string(&trace->config, key, sizeof(key), value, sizeof(value)); 2755 2702 } else { 2756 fprintf(stderr, "Error parsing option %s\n", pch);2703 fprintf(stderr, "Error: parsing option %s\n", pch); 2757 2704 } 2758 2705 pch = strtok (NULL," ,.-"); … … 2779 2726 2780 2727 DLLEXPORT void trace_free_packet(libtrace_t *libtrace, libtrace_packet_t *packet) { 2781 /*assert(packet);*/2782 2728 if (!packet) { 2783 2729 trace_set_err(libtrace, TRACE_ERR_NULL_PACKET, … … 2815 2761 return &libtrace->format->info; 2816 2762 else 2817 return NULL;2818 } 2763 pthread_exit(NULL); 2764 }
Note: See TracChangeset
for help on using the changeset viewer.