diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-09 14:41:23 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-02-09 16:47:19 +0200 |
commit | 02cf9eed46759e019b3aca83f691f1ee31be2db5 (patch) | |
tree | ad8d082c3c4f7ea8c340f594bf220184b73d1a2f | |
parent | 777bd9688099daf5af9d0e41f2df668040e072a9 (diff) | |
download | vmod-tbf-02cf9eed46759e019b3aca83f691f1ee31be2db5.tar.gz vmod-tbf-02cf9eed46759e019b3aca83f691f1ee31be2db5.tar.bz2 |
Cleanup
* src/tbf.c: Use %zu to log size_t values; remove unused variables
and functions.
-rw-r--r-- | src/tbf.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -494,20 +494,22 @@ key_to_str(uint8_t key[], char *buf) | |||
494 | *buf++ = xdig[key[i] >> 4]; | 494 | *buf++ = xdig[key[i] >> 4]; |
495 | *buf++ = xdig[key[i] & 0xf]; | 495 | *buf++ = xdig[key[i] & 0xf]; |
496 | } | 496 | } |
497 | *buf = 0; | 497 | *buf = 0; |
498 | } | 498 | } |
499 | 499 | ||
500 | #if 0 | ||
500 | static void | 501 | static void |
501 | node_to_keystr(struct node *node, char *buf) | 502 | node_to_keystr(struct node *node, char *buf) |
502 | { | 503 | { |
503 | if (node) | 504 | if (node) |
504 | key_to_str(node->key, buf); | 505 | key_to_str(node->key, buf); |
505 | else | 506 | else |
506 | *buf = 0; | 507 | *buf = 0; |
507 | } | 508 | } |
509 | #endif | ||
508 | 510 | ||
509 | static void | 511 | static void |
510 | node_dump_ord(struct node *node, FILE *fp) | 512 | node_dump_ord(struct node *node, FILE *fp) |
511 | { | 513 | { |
512 | uint32_t *p; | 514 | uint32_t *p; |
513 | 515 | ||
@@ -556,13 +558,12 @@ node_dump(struct node *node, FILE *fp) | |||
556 | } | 558 | } |
557 | 559 | ||
558 | static void | 560 | static void |
559 | tree_dump_unlocked(struct tree *tree, char const *file) | 561 | tree_dump_unlocked(struct tree *tree, char const *file) |
560 | { | 562 | { |
561 | struct node *node; | 563 | struct node *node; |
562 | char keybuf[3][2*SHA256_LEN+1]; | ||
563 | FILE *fp; | 564 | FILE *fp; |
564 | int err = 0; | 565 | int err = 0; |
565 | struct dump_header header; | 566 | struct dump_header header; |
566 | 567 | ||
567 | fp = fopen(file, "w"); | 568 | fp = fopen(file, "w"); |
568 | if (!fp) { | 569 | if (!fp) { |
@@ -653,13 +654,12 @@ new_node(struct node **nodes, struct dump_header *hdr, | |||
653 | 654 | ||
654 | int | 655 | int |
655 | tree_load_nodes(struct tree *tree, struct dump_header *hdr, | 656 | tree_load_nodes(struct tree *tree, struct dump_header *hdr, |
656 | struct node **nodes, FILE *fp) | 657 | struct node **nodes, FILE *fp) |
657 | { | 658 | { |
658 | size_t i; | 659 | size_t i; |
659 | uint32_t root_idx; | ||
660 | uint32_t ord[2]; | 660 | uint32_t ord[2]; |
661 | size_t incomplete = 0; | 661 | size_t incomplete = 0; |
662 | 662 | ||
663 | for (i = 0; i < hdr->count; i++) { | 663 | for (i = 0; i < hdr->count; i++) { |
664 | struct node node, *np; | 664 | struct node node, *np; |
665 | uint32_t len; | 665 | uint32_t len; |
@@ -760,25 +760,25 @@ tree_load_nodes(struct tree *tree, struct dump_header *hdr, | |||
760 | } | 760 | } |
761 | } | 761 | } |
762 | lru_link_node(tree, np, tree->tail); | 762 | lru_link_node(tree, np, tree->tail); |
763 | } | 763 | } |
764 | 764 | ||
765 | if (incomplete) { | 765 | if (incomplete) { |
766 | syslog(LOG_DAEMON|LOG_ERR, "tbf.%s: %lu incomplete nodes left", | 766 | syslog(LOG_DAEMON|LOG_ERR, "tbf.%s: %zu incomplete nodes left", |
767 | __FUNCTION__, incomplete); | 767 | __FUNCTION__, incomplete); |
768 | return 1; | 768 | return 1; |
769 | } | 769 | } |
770 | tree->root = nodes[hdr->root]; | 770 | tree->root = nodes[hdr->root]; |
771 | return 0; | 771 | return 0; |
772 | } | 772 | } |
773 | 773 | ||
774 | struct tree * | 774 | struct tree * |
775 | tree_load(char const *filename) | 775 | tree_load(char const *filename) |
776 | { | 776 | { |
777 | FILE *fp; | 777 | FILE *fp; |
778 | struct tree *tree; | 778 | struct tree *tree = NULL; |
779 | int rc; | 779 | int rc; |
780 | struct dump_header header; | 780 | struct dump_header header; |
781 | 781 | ||
782 | fp = fopen(filename, "r"); | 782 | fp = fopen(filename, "r"); |
783 | if (!fp) { | 783 | if (!fp) { |
784 | syslog(LOG_DAEMON|LOG_ERR, "can't open file %s: %s", | 784 | syslog(LOG_DAEMON|LOG_ERR, "can't open file %s: %s", |
@@ -1016,18 +1016,18 @@ static void | |||
1016 | log_node(struct node *node, void *data) | 1016 | log_node(struct node *node, void *data) |
1017 | { | 1017 | { |
1018 | struct traverse_closure *tc = data; | 1018 | struct traverse_closure *tc = data; |
1019 | char kbuf[2*SHA256_LEN+1]; | 1019 | char kbuf[2*SHA256_LEN+1]; |
1020 | key_to_str(node->key, kbuf); | 1020 | key_to_str(node->key, kbuf); |
1021 | #ifdef DEBUG | 1021 | #ifdef DEBUG |
1022 | syslog(tc->prio, "%d: %p(%p,%p): %lu %s: %s", tc->num, node, | 1022 | syslog(tc->prio, "%d: %p(%p,%p): %zu %s: %s", tc->num, node, |
1023 | node->child[CHILD_LEFT], node->child[CHILD_RIGHT], node->ord, | 1023 | node->child[CHILD_LEFT], node->child[CHILD_RIGHT], node->ord, |
1024 | kbuf, | 1024 | kbuf, |
1025 | node->keystr); | 1025 | node->keystr); |
1026 | #else | 1026 | #else |
1027 | syslog(tc->prio, "%d: %p(%p,%p): %lu %s", tc->num, node, | 1027 | syslog(tc->prio, "%d: %p(%p,%p): %zu %s", tc->num, node, |
1028 | node->child[CHILD_LEFT], node->child[CHILD_RIGHT], node->ord, | 1028 | node->child[CHILD_LEFT], node->child[CHILD_RIGHT], node->ord, |
1029 | kbuf); | 1029 | kbuf); |
1030 | #endif | 1030 | #endif |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | 1033 | ||
@@ -1048,12 +1048,12 @@ VCL_VOID | |||
1048 | vmod_log_stats(VRT_CTX, VCL_INT prio) | 1048 | vmod_log_stats(VRT_CTX, VCL_INT prio) |
1049 | { | 1049 | { |
1050 | struct tree_stats st; | 1050 | struct tree_stats st; |
1051 | struct tree *tree = tbf_get_tree(); | 1051 | struct tree *tree = tbf_get_tree(); |
1052 | tree_compute_stats(tree, &st); | 1052 | tree_compute_stats(tree, &st); |
1053 | tbf_release_tree(&tree); | 1053 | tbf_release_tree(&tree); |
1054 | syslog(prio, "Number of nodes: %lu", st.num_nodes); | 1054 | syslog(prio, "Number of nodes: %zu", st.num_nodes); |
1055 | syslog(prio, "Number of leaves: %lu", st.num_leaves); | 1055 | syslog(prio, "Number of leaves: %zu", st.num_leaves); |
1056 | syslog(prio, "Shortest path: %lu", st.shortest_path); | 1056 | syslog(prio, "Shortest path: %zu", st.shortest_path); |
1057 | syslog(prio, "Longest path: %lu", st.longest_path); | 1057 | syslog(prio, "Longest path: %zu", st.longest_path); |
1058 | syslog(prio, "Avg path: %f", st.avg_path); | 1058 | syslog(prio, "Avg path: %f", st.avg_path); |
1059 | } | 1059 | } |