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