Commit 8a2b85af authored by Shawn Routhier's avatar Shawn Routhier
Browse files

[v4_1_esv]

Tidy up some compiler issues in the debug code
[ISC-Bugs #26460]
parent 1b76531a
......@@ -101,6 +101,9 @@ work on other platforms. Please report any problems and suggested fixes to
enabling it.
[ISC-Bugs #31463]
- Tidy up some compiler issues in the debug code
[ISC-Bugs #26460]
Changes since 4.1-ESV-R6
- Existing legacy unit-tests have been migrated to Automated Test
......
......@@ -327,6 +327,7 @@ int execute_statements (result, packet, lease, client_state,
case set_statement:
case define_statement:
status = 1;
if (!scope) {
log_error("set %s: no scope",
r->data.set.name);
......@@ -418,30 +419,31 @@ int execute_statements (result, packet, lease, client_state,
case let_statement:
#if defined (DEBUG_EXPRESSIONS)
log_debug ("exec: let %s", r -> data.let.name);
log_debug("exec: let %s", r->data.let.name);
#endif
ns = (struct binding_scope *)0;
status = 0;
ns = NULL;
binding_scope_allocate (&ns, MDL);
e = r;
next_let:
if (ns) {
binding = dmalloc (sizeof *binding, MDL);
memset (binding, 0, sizeof *binding);
binding = dmalloc(sizeof(*binding), MDL);
memset(binding, 0, sizeof(*binding));
if (!binding) {
blb:
binding_scope_dereference (&ns, MDL);
binding_scope_dereference(&ns, MDL);
} else {
binding -> name =
dmalloc (strlen
(e -> data.let.name + 1),
binding->name =
dmalloc(strlen
(e->data.let.name + 1),
MDL);
if (binding -> name)
strcpy (binding -> name,
e -> data.let.name);
if (binding->name)
strcpy(binding->name,
e->data.let.name);
else {
dfree (binding, MDL);
binding = (struct binding *)0;
dfree(binding, MDL);
binding = NULL;
goto blb;
}
}
......@@ -450,35 +452,35 @@ int execute_statements (result, packet, lease, client_state,
if (ns && binding) {
status = (evaluate_expression
(&binding -> value, packet, lease,
(&binding->value, packet, lease,
client_state,
in_options, out_options,
scope, e -> data.set.expr, MDL));
binding -> next = ns -> bindings;
ns -> bindings = binding;
scope, e->data.set.expr, MDL));
binding->next = ns->bindings;
ns->bindings = binding;
}
#if defined (DEBUG_EXPRESSIONS)
log_debug ("exec: let %s%s", e -> data.let.name,
log_debug("exec: let %s%s", e->data.let.name,
(binding && status ? "" : "failed"));
#endif
if (!e -> data.let.statements) {
} else if (e -> data.let.statements -> op ==
if (!e->data.let.statements) {
} else if (e->data.let.statements->op ==
let_statement) {
e = e -> data.let.statements;
e = e->data.let.statements;
goto next_let;
} else if (ns) {
if (scope && *scope)
binding_scope_reference (&ns -> outer,
binding_scope_reference(&ns->outer,
*scope, MDL);
execute_statements
(result, packet, lease,
client_state,
in_options, out_options,
&ns, e -> data.let.statements);
&ns, e->data.let.statements);
}
if (ns)
binding_scope_dereference (&ns, MDL);
binding_scope_dereference(&ns, MDL);
break;
case log_statement:
......
......@@ -1217,17 +1217,15 @@ int evaluate_boolean_expression (result, packet, lease, client_state,
return 0;
case expr_not:
sleft = evaluate_boolean_expression (&bleft, packet, lease,
sleft = evaluate_boolean_expression(&bleft, packet, lease,
client_state,
in_options, cfg_options,
scope,
expr -> data.not);
expr->data.not);
#if defined (DEBUG_EXPRESSIONS)
log_debug ("bool: not (%s) = %s",
log_debug("bool: not (%s) = %s",
sleft ? (bleft ? "true" : "false") : "NULL",
((sleft && sright)
? (!bleft ? "true" : "false") : "NULL"));
sleft ? (!bleft ? "true" : "false") : "NULL");
#endif
if (sleft) {
*result = !bleft;
......@@ -2443,24 +2441,26 @@ int evaluate_numeric_expression (result, packet, lease, client_state,
return status;
case expr_extract_int16:
memset (&data, 0, sizeof data);
memset(&data, 0, sizeof(data));
status = (evaluate_data_expression
(&data, packet, lease, client_state, in_options,
cfg_options, scope, expr -> data.extract_int, MDL));
cfg_options, scope, expr->data.extract_int, MDL));
if (status && data.len >= 2) {
*result = getUShort (data.data);
*result = getUShort(data.data);
rc = 1;
}
#if defined (DEBUG_EXPRESSIONS)
if (rc == 1) {
log_debug ("num: extract_int16 (%s) = %ld",
print_hex_1(data.len, data.data, 60)
log_debug("num: extract_int16 (%s) = %ld",
print_hex_1(data.len, data.data, 60),
*result);
} else {
log_debug ("num: extract_int16 (NULL) = NULL");
log_debug("num: extract_int16 (NULL) = NULL");
}
#endif
if (status) data_string_forget (&data, MDL);
if (status)
data_string_forget(&data, MDL);
return (rc);
case expr_extract_int32:
......@@ -2493,22 +2493,22 @@ int evaluate_numeric_expression (result, packet, lease, client_state,
case expr_lease_time:
if (!lease) {
log_error ("data: leased_lease: not available");
return 0;
log_error("data: leased_lease: not available");
return (0);
}
if (lease -> ends < cur_time) {
log_error ("%s %lu when it is now %lu",
if (lease->ends < cur_time) {
log_error("%s %lu when it is now %lu",
"data: lease_time: lease ends at",
(long)(lease -> ends), (long)cur_time);
return 0;
(long)(lease->ends), (long)cur_time);
return (0);
}
*result = lease -> ends - cur_time;
*result = lease->ends - cur_time;
#if defined (DEBUG_EXPRESSIONS)
log_debug ("number: lease-time = (%lu - %lu) = %ld",
lease -> ends,
cur_time, *result);
log_debug("number: lease-time = (%lu - %lu) = %ld",
(long unsigned)lease->ends,
(long unsigned)cur_time, *result);
#endif
return 1;
return (1);
case expr_dns_transaction:
#if !defined (NSUPDATE)
......
......@@ -39,50 +39,50 @@
#if defined (COMPACT_LEASES)
struct lease *free_leases;
# if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
#if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct lease *lease_hunks;
void relinquish_lease_hunks ()
{
struct lease *c, *n, **p, *f;
struct lease *c, *n, **p;
int i;
/* Account for all the leases on the free list. */
for (n = lease_hunks; n; n = n -> next) {
for (i = 1; i < n -> starts + 1; i++) {
for (n = lease_hunks; n; n = n->next) {
for (i = 1; i < n->starts + 1; i++) {
p = &free_leases;
for (c = free_leases; c; c = c -> next) {
if (c == &n [i]) {
*p = c -> next;
n -> ends++;
for (c = free_leases; c; c = c->next) {
if (c == &n[i]) {
*p = c->next;
n->ends++;
break;
}
p = &c -> next;
p = &c->next;
}
if (!c) {
log_info ("lease %s refcnt %d",
piaddr (n [i].ip_addr), n [i].refcnt);
log_info("lease %s refcnt %d",
piaddr (n[i].ip_addr), n[i].refcnt);
#if defined (DEBUG_RC_HISTORY)
dump_rc_history (&n [i]);
dump_rc_history(&n[i]);
#endif
}
}
}
for (c = lease_hunks; c; c = n) {
n = c -> next;
if (c -> ends != c -> starts) {
log_info ("lease hunk %lx leases %ld free %ld",
(unsigned long)c, (unsigned long)c -> starts,
(unsigned long)c -> ends);
n = c->next;
if (c->ends != c->starts) {
log_info("lease hunk %lx leases %ld free %ld",
(unsigned long)c, (unsigned long)(c->starts),
(unsigned long)(c->ends));
}
dfree (c, MDL);
dfree(c, MDL);
}
/* Free all the rogue leases. */
for (c = free_leases; c; c = n) {
n = c -> next;
dfree (c, MDL);
n = c->next;
dfree(c, MDL);
}
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment