aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-02-09 14:41:23 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-02-09 16:47:19 +0200
commit02cf9eed46759e019b3aca83f691f1ee31be2db5 (patch)
treead8d082c3c4f7ea8c340f594bf220184b73d1a2f
parent777bd9688099daf5af9d0e41f2df668040e072a9 (diff)
downloadvmod-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.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/tbf.c b/src/tbf.c
index a1b6f9f..1695960 100644
--- a/src/tbf.c
+++ b/src/tbf.c
@@ -488,32 +488,34 @@ static char xdig[] = "0123456789abcdef";
static void
key_to_str(uint8_t key[], char *buf)
{
size_t i;
for (i = 0; i < SHA256_LEN; i++) {
*buf++ = xdig[key[i] >> 4];
*buf++ = xdig[key[i] & 0xf];
}
*buf = 0;
}
+#if 0
static void
node_to_keystr(struct node *node, char *buf)
{
if (node)
key_to_str(node->key, buf);
else
*buf = 0;
}
+#endif
static void
node_dump_ord(struct node *node, FILE *fp)
{
uint32_t *p;
if (node)
p = &node->ord;
else {
uint32_t t = 0;
p = &t;
}
@@ -550,25 +552,24 @@ node_dump(struct node *node, FILE *fp)
if (len) {
char c = 0;
fseek(fp, len-1, SEEK_CUR);
fputc(c, fp);
}
#endif
}
static void
tree_dump_unlocked(struct tree *tree, char const *file)
{
struct node *node;
- char keybuf[3][2*SHA256_LEN+1];
FILE *fp;
int err = 0;
struct dump_header header;
fp = fopen(file, "w");
if (!fp) {
syslog(LOG_DAEMON|LOG_ERR,
"tbf.dump: can't open file %s for output: %m", file);
return;
}
header.version = DUMP_VERSION;
@@ -647,25 +648,24 @@ new_node(struct node **nodes, struct dump_header *hdr,
child = node_alloc(null_key, parent);
nodes[ord] = child;
}
return child;
}
int
tree_load_nodes(struct tree *tree, struct dump_header *hdr,
struct node **nodes, FILE *fp)
{
size_t i;
- uint32_t root_idx;
uint32_t ord[2];
size_t incomplete = 0;
for (i = 0; i < hdr->count; i++) {
struct node node, *np;
uint32_t len;
uint32_t flags;
debug(3,("Load record %lu/%lu %lu", i, hdr->count, incomplete));
if (READREC(fp, len))
return -1;
@@ -754,37 +754,37 @@ tree_load_nodes(struct tree *tree, struct dump_header *hdr,
"tbf.%s: invalid left pointer",
__FUNCTION__);
return -1;
}
if (np->child[CHILD_RIGHT]->status == NST_INCOMPLETE) {
++incomplete;
}
}
lru_link_node(tree, np, tree->tail);
}
if (incomplete) {
- syslog(LOG_DAEMON|LOG_ERR, "tbf.%s: %lu incomplete nodes left",
+ syslog(LOG_DAEMON|LOG_ERR, "tbf.%s: %zu incomplete nodes left",
__FUNCTION__, incomplete);
return 1;
}
tree->root = nodes[hdr->root];
return 0;
}
struct tree *
tree_load(char const *filename)
{
FILE *fp;
- struct tree *tree;
+ struct tree *tree = NULL;
int rc;
struct dump_header header;
fp = fopen(filename, "r");
if (!fp) {
syslog(LOG_DAEMON|LOG_ERR, "can't open file %s: %s",
filename, strerror(errno));
return NULL;
}
if (READREC(fp, header))
rc = -1;
@@ -1010,30 +1010,30 @@ struct traverse_closure
{
int prio;
uint32_t num;
};
static void
log_node(struct node *node, void *data)
{
struct traverse_closure *tc = data;
char kbuf[2*SHA256_LEN+1];
key_to_str(node->key, kbuf);
#ifdef DEBUG
- syslog(tc->prio, "%d: %p(%p,%p): %lu %s: %s", tc->num, node,
+ syslog(tc->prio, "%d: %p(%p,%p): %zu %s: %s", tc->num, node,
node->child[CHILD_LEFT], node->child[CHILD_RIGHT], node->ord,
kbuf,
node->keystr);
#else
- syslog(tc->prio, "%d: %p(%p,%p): %lu %s", tc->num, node,
+ syslog(tc->prio, "%d: %p(%p,%p): %zu %s", tc->num, node,
node->child[CHILD_LEFT], node->child[CHILD_RIGHT], node->ord,
kbuf);
#endif
}
VCL_VOID
vmod_log_tree(VRT_CTX, VCL_INT prio)
{
struct traverse_closure tc;
struct tree *tree = tbf_get_tree();
if (!tree)
@@ -1042,18 +1042,18 @@ vmod_log_tree(VRT_CTX, VCL_INT prio)
tc.prio = prio;
tree_traverse_postorder(tree, log_node, &tc);
tbf_release_tree(&tree);
}
VCL_VOID
vmod_log_stats(VRT_CTX, VCL_INT prio)
{
struct tree_stats st;
struct tree *tree = tbf_get_tree();
tree_compute_stats(tree, &st);
tbf_release_tree(&tree);
- syslog(prio, "Number of nodes: %lu", st.num_nodes);
- syslog(prio, "Number of leaves: %lu", st.num_leaves);
- syslog(prio, "Shortest path: %lu", st.shortest_path);
- syslog(prio, "Longest path: %lu", st.longest_path);
+ syslog(prio, "Number of nodes: %zu", st.num_nodes);
+ syslog(prio, "Number of leaves: %zu", st.num_leaves);
+ syslog(prio, "Shortest path: %zu", st.shortest_path);
+ syslog(prio, "Longest path: %zu", st.longest_path);
syslog(prio, "Avg path: %f", st.avg_path);
}

Return to:

Send suggestions and report system problems to the System administrator.