From db6fa3d89587dfaca2ade58270c29bdbf209af7e Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Wed, 19 Feb 2014 23:15:01 +0900 Subject: [PATCH] Fix two bugs found by PULSE in corfurl_flu.erl, yay! --- prototype/corfurl/src/corfurl_flu.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/prototype/corfurl/src/corfurl_flu.erl b/prototype/corfurl/src/corfurl_flu.erl index 65c3936..1f0dcf6 100644 --- a/prototype/corfurl/src/corfurl_flu.erl +++ b/prototype/corfurl/src/corfurl_flu.erl @@ -294,10 +294,12 @@ check_write(LogicalPN, PageBin, check_is_written(Offset, _PhysicalPN, #state{mem_fh=FH}) -> case file:pread(FH, Offset, 1) of - {ok, <<1:8>>} -> - true; {ok, <<0:8>>} -> false; + {ok, <<1:8>>} -> % written + true; + {ok, <<2:8>>} -> % trimmed + true; eof -> %% We assume that Offset has been bounds-checked false @@ -318,7 +320,7 @@ read_page(LogicalPN, #state{max_mem=MaxMem, mem_fh=FH, io:format("BUMMER: ~s line ~w: incomplete write at ~p\n", [?MODULE, ?LINE, LogicalPN]), error_unwritten; - {ok, <<2:8>>} -> + {ok, <<2:8, _/binary>>} -> error_trimmed; {ok, _} -> error_unwritten;