summaryrefslogtreecommitdiff
path: root/krl.c
diff options
context:
space:
mode:
authorderaadt@openbsd.org <deraadt@openbsd.org>2016-09-12 01:22:38 +0000
committerDarren Tucker <dtucker@zip.com.au>2016-09-12 13:46:29 +1000
commit9136ec134c97a8aff2917760c03134f52945ff3c (patch)
treebfcab357e6e0f510d9b63bac43b18097e89fa58a /krl.c
parentf219fc8f03caca7ac82a38ed74bbd6432a1195e7 (diff)
upstream commit
Add MAXIMUM(), MINIMUM(), and ROUNDUP() to misc.h, then use those definitions rather than pulling <sys/param.h> and unknown namespace pollution. ok djm markus dtucker Upstream-ID: 712cafa816c9f012a61628b66b9fbd5687223fb8
Diffstat (limited to 'krl.c')
-rw-r--r--krl.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/krl.c b/krl.c
index fff1a3f7c..e271a1934 100644
--- a/krl.c
+++ b/krl.c
@@ -14,11 +14,10 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17/* $OpenBSD: krl.c,v 1.37 2015/12/31 00:33:52 djm Exp $ */ 17/* $OpenBSD: krl.c,v 1.38 2016/09/12 01:22:38 deraadt Exp $ */
18 18
19#include "includes.h" 19#include "includes.h"
20 20
21#include <sys/param.h> /* MIN */
22#include <sys/types.h> 21#include <sys/types.h>
23#include <openbsd-compat/sys-tree.h> 22#include <openbsd-compat/sys-tree.h>
24#include <openbsd-compat/sys-queue.h> 23#include <openbsd-compat/sys-queue.h>
@@ -121,7 +120,7 @@ blob_cmp(struct revoked_blob *a, struct revoked_blob *b)
121 int r; 120 int r;
122 121
123 if (a->len != b->len) { 122 if (a->len != b->len) {
124 if ((r = memcmp(a->blob, b->blob, MIN(a->len, b->len))) != 0) 123 if ((r = memcmp(a->blob, b->blob, MINIMUM(a->len, b->len))) != 0)
125 return r; 124 return r;
126 return a->len > b->len ? 1 : -1; 125 return a->len > b->len ? 1 : -1;
127 } else 126 } else
@@ -458,9 +457,9 @@ choose_next_state(int current_state, u_int64_t contig, int final,
458 * Avoid unsigned overflows. 457 * Avoid unsigned overflows.
459 * The limits are high enough to avoid confusing the calculations. 458 * The limits are high enough to avoid confusing the calculations.
460 */ 459 */
461 contig = MIN(contig, 1ULL<<31); 460 contig = MINIMUM(contig, 1ULL<<31);
462 last_gap = MIN(last_gap, 1ULL<<31); 461 last_gap = MINIMUM(last_gap, 1ULL<<31);
463 next_gap = MIN(next_gap, 1ULL<<31); 462 next_gap = MINIMUM(next_gap, 1ULL<<31);
464 463
465 /* 464 /*
466 * Calculate the cost to switch from the current state to candidates. 465 * Calculate the cost to switch from the current state to candidates.
@@ -486,8 +485,8 @@ choose_next_state(int current_state, u_int64_t contig, int final,
486 /* Estimate base cost in bits of each section type */ 485 /* Estimate base cost in bits of each section type */
487 cost_list += 64 * contig + (final ? 0 : 8+64); 486 cost_list += 64 * contig + (final ? 0 : 8+64);
488 cost_range += (2 * 64) + (final ? 0 : 8+64); 487 cost_range += (2 * 64) + (final ? 0 : 8+64);
489 cost_bitmap += last_gap + contig + (final ? 0 : MIN(next_gap, 8+64)); 488 cost_bitmap += last_gap + contig + (final ? 0 : MINIMUM(next_gap, 8+64));
490 cost_bitmap_restart += contig + (final ? 0 : MIN(next_gap, 8+64)); 489 cost_bitmap_restart += contig + (final ? 0 : MINIMUM(next_gap, 8+64));
491 490
492 /* Convert to byte costs for actual comparison */ 491 /* Convert to byte costs for actual comparison */
493 cost_list = (cost_list + 7) / 8; 492 cost_list = (cost_list + 7) / 8;