Skip to content

Commit

Permalink
Refine code-style in format.rs
Browse files Browse the repository at this point in the history
Signed-off-by: Lucasliang <[email protected]>
  • Loading branch information
LykxSassinator committed Aug 2, 2022
1 parent dbfd99f commit 6717f8f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/file_pipe_log/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ impl LogFileFormat {

/// Decodes a slice of bytes into a `LogFileFormat`.
pub fn decode(buf: &mut &[u8]) -> Result<LogFileFormat> {
#[cfg(feature = "failpoints")]
{
// Set parsed abnormal DataLayout for `payload`.
fail::fail_point!("log_file_header::abnormal_decoded_payload", |_| Err(
Error::InvalidArgument("abnormal_decoded_payload".to_string())
));
}
let buf_len = buf.len();
if buf_len < Self::header_len() {
return Err(Error::Corruption("log file header too short".to_owned()));
Expand Down Expand Up @@ -182,13 +189,6 @@ impl LogFileFormat {
data_layout: DataLayout::NoAlignment,
});
}
#[cfg(feature = "failpoints")]
{
// Set parsed abnormal DataLayout for `payload`.
fail::fail_point!("log_file_header::abnormal_decoded_payload", |_| Err(
Error::InvalidArgument("abnormal_decoded_payload".to_string())
));
}
if_chain::if_chain! {
if payload_len > 0;
if buf_len >= Self::header_len() + payload_len;
Expand Down

0 comments on commit 6717f8f

Please sign in to comment.