Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/vndcompress Split guard in offtab_write_window into ...
details: https://anonhg.NetBSD.org/src/rev/9968a80e957e
branches: trunk
changeset: 326203:9968a80e957e
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jan 22 06:16:14 2014 +0000
description:
Split guard in offtab_write_window into offtab_maybe_write_window.
diffstat:
usr.bin/vndcompress/offtab.c | 31 +++++++++++++++++++------------
1 files changed, 19 insertions(+), 12 deletions(-)
diffs (84 lines):
diff -r 2d8b8fe14d9e -r 9968a80e957e usr.bin/vndcompress/offtab.c
--- a/usr.bin/vndcompress/offtab.c Wed Jan 22 06:16:05 2014 +0000
+++ b/usr.bin/vndcompress/offtab.c Wed Jan 22 06:16:14 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: offtab.c,v 1.4 2014/01/22 06:16:05 riastradh Exp $ */
+/* $NetBSD: offtab.c,v 1.5 2014/01/22 06:16:14 riastradh Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -156,17 +156,11 @@
}
static void
-offtab_write_window(struct offtab *offtab, uint32_t start, uint32_t end)
+offtab_write_window(struct offtab *offtab)
{
assert(offtab->ot_mode == OFFTAB_MODE_WRITE);
- /* Don't bother if [start, end) does not cover our window. */
- if (end <= offtab->ot_window_start)
- return;
- if (offtab_current_window_end(offtab) < start)
- return;
-
const uint32_t window_size = offtab_current_window_size(offtab);
__CTASSERT(MAX_WINDOW_SIZE <= (SIZE_MAX / sizeof(uint64_t)));
__CTASSERT(MAX_N_OFFSETS <= (OFF_MAX / sizeof(uint64_t)));
@@ -185,6 +179,19 @@
(size_t)n_written,
(size_t)(window_size * sizeof(uint64_t)));
}
+
+static void
+offtab_maybe_write_window(struct offtab *offtab, uint32_t start, uint32_t end)
+{
+
+ /* Don't bother if [start, end) does not cover our window. */
+ if (end <= offtab->ot_window_start)
+ return;
+ if (offtab_current_window_end(offtab) < start)
+ return;
+
+ offtab_write_window(offtab);
+}
/*
* Initialize an offtab to support the specified number of offsets read
@@ -365,7 +372,7 @@
for (i = 1; i < n_windows; i++) {
/* Change the start but reuse the all-ones buffer. */
offtab->ot_window_start = (i * offtab->ot_window_size);
- offtab_write_window(offtab, 0, offtab->ot_n_offsets);
+ offtab_write_window(offtab);
}
offtab->ot_window_start = 0;
@@ -376,7 +383,7 @@
(offtab->ot_n_offsets * sizeof(uint64_t)));
assert(first_offset <= OFF_MAX);
offtab->ot_window[0] = htobe64(first_offset);
- offtab_write_window(offtab, 0, offtab->ot_n_offsets);
+ offtab_write_window(offtab);
/*
* We could adapt offtab_write_window to use pwrite instead of
@@ -412,7 +419,7 @@
* interrupted before we could move the window.
*/
if (offtab->ot_window != NULL)
- offtab_write_window(offtab, 0, n_offsets);
+ offtab_maybe_write_window(offtab, 0, n_offsets);
if (ISSET(flags, OFFTAB_CHECKPOINT_SYNC)) {
__CTASSERT(MAX_N_OFFSETS <= (OFF_MAX / sizeof(uint64_t)));
@@ -452,7 +459,7 @@
goto win;
/* Otherwise, write out the current window and choose a new one. */
- offtab_write_window(offtab, 0, offtab->ot_n_offsets);
+ offtab_write_window(offtab);
assert(offtab->ot_window_size <= blkno);
assert(offtab->ot_window_start == (blkno - offtab->ot_window_size));
Home |
Main Index |
Thread Index |
Old Index