Skip to content

Commit 496be4b

Browse files
Merge pull request #98 from rust-fuzz/revert-94-rustfmt
Revert "Format with rustfmt"
2 parents c6e81ae + 7197842 commit 496be4b

File tree

7 files changed

+104
-136
lines changed

7 files changed

+104
-136
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: sudo apt-get install --no-install-recommends build-essential binutils-dev libunwind-dev libblocksruntime-dev liblzma-dev
2424
- name: Test
2525
run: ./test.sh
26-
26+
2727
# ubuntu-beta:
2828
# runs-on: ubuntu-24.04
2929
# steps:
@@ -37,7 +37,7 @@ jobs:
3737
# run: sudo apt-get install --no-install-recommends build-essential binutils-dev libunwind-dev libblocksruntime-dev liblzma-dev
3838
# - name: Test
3939
# run: ./test.sh
40-
40+
4141
ubuntu-stable:
4242
runs-on: ubuntu-24.04
4343
steps:

build.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,24 @@ use std::process::{self, Command};
55

66
const VERSION: &str = env!("CARGO_PKG_VERSION");
77

8-
#[cfg(target_family = "windows")]
8+
#[cfg(target_family="windows")]
99
compile_error!("honggfuzz-rs does not currently support Windows but works well under WSL (Windows Subsystem for Linux)");
1010

1111
// TODO: maybe use `make-cmd` crate
12-
#[cfg(not(any(
13-
target_os = "freebsd",
14-
target_os = "dragonfly",
15-
target_os = "bitrig",
16-
target_os = "openbsd",
17-
target_os = "netbsd"
18-
)))]
12+
#[cfg(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "bitrig", target_os = "openbsd", target_os = "netbsd")))]
1913
const GNU_MAKE: &str = "make";
20-
#[cfg(any(
21-
target_os = "freebsd",
22-
target_os = "dragonfly",
23-
target_os = "bitrig",
24-
target_os = "openbsd",
25-
target_os = "netbsd"
26-
))]
14+
#[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "bitrig", target_os = "openbsd", target_os = "netbsd"))]
2715
const GNU_MAKE: &str = "gmake";
2816

2917
fn main() {
3018
// Only build honggfuzz binaries if we are in the process of building an instrumentized binary
3119
let honggfuzz_target = match env::var("CARGO_HONGGFUZZ_TARGET_DIR") {
3220
Ok(path) => path, // path where to place honggfuzz binary. provided by cargo-hfuzz command.
33-
Err(_) => return,
21+
Err(_) => return
3422
};
3523

3624
// check that "cargo hfuzz" command is at the same version as this file
37-
let honggfuzz_build_version =
38-
env::var("CARGO_HONGGFUZZ_BUILD_VERSION").unwrap_or("unknown".to_string());
25+
let honggfuzz_build_version = env::var("CARGO_HONGGFUZZ_BUILD_VERSION").unwrap_or("unknown".to_string());
3926
if VERSION != honggfuzz_build_version {
4027
eprintln!("The version of the honggfuzz library dependency ({0}) and the version of the `cargo-hfuzz` executable ({1}) do not match.\n\
4128
If updating both by running `cargo update` and `cargo install honggfuzz` does not work, you can either:\n\
@@ -65,11 +52,7 @@ fn main() {
6552
assert!(status.success());
6653

6754
fs::copy("honggfuzz/libhfuzz/libhfuzz.a", out_dir.join("libhfuzz.a")).unwrap();
68-
fs::copy(
69-
"honggfuzz/libhfcommon/libhfcommon.a",
70-
out_dir.join("libhfcommon.a"),
71-
)
72-
.unwrap();
55+
fs::copy("honggfuzz/libhfcommon/libhfcommon.a", out_dir.join("libhfcommon.a")).unwrap();
7356
fs::copy("honggfuzz/honggfuzz", honggfuzz_target.join("honggfuzz")).unwrap();
7457

7558
// tell cargo how to link final executable to hfuzz static library

example/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use honggfuzz::fuzz;
22

33
fn main() {
4-
// Here you can parse `std::env::args and
4+
// Here you can parse `std::env::args and
55
// setup / initialize your project
66

77
// You should avoid as much as possible global states.
@@ -28,7 +28,7 @@ fn main() {
2828
if data[2] != b'y' {return}
2929
panic!("BOOM")
3030
});
31-
31+
3232
// The fuzz macro gives an arbitrary object (see `arbitrary crate`)
3333
// to a closure-like block of code if you set the `arbitrary` feature.
3434
// Here, this tuple will contain two "random" values of different type.

example/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh -vex
22
export RUST_BACKTRACE=full
33

4-
CARGO_HFUZZ=${CARGO_HFUZZ:-"cargo hfuzz"} # by default, use regular subcommand. Override to force using another version (for tests)
4+
CARGO_HFUZZ=${CARGO_HFUZZ:-"cargo hfuzz"} # by default, use regular subcommand. Override to force using another version (for tests)
55

66
cargo clean
77

src/bin/cargo-hfuzz.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,15 @@ where
208208

209209
// HACK: temporary fix, see https://github.com/rust-lang/rust/issues/53945#issuecomment-426824324
210210
let use_gold_linker: bool = match Command::new("which") // check if the gold linker is available
211-
.args(&["ld.gold"])
212-
.status()
213-
{
211+
.args(&["ld.gold"])
212+
.status() {
214213
Err(_) => false,
215-
Ok(status) => match status.code() {
216-
Some(0) => true,
217-
_ => false,
218-
},
214+
Ok(status) => {
215+
match status.code() {
216+
Some(0) => true,
217+
_ => false
218+
}
219+
}
219220
};
220221

221222
let mut rustflags = "\
@@ -270,19 +271,15 @@ where
270271
// compilers for which the LLVM version is >= 13.
271272
let version_meta = rustc_version::version_meta().unwrap();
272273
if version_meta.llvm_version.map_or(true, |v| v.major >= 13) {
273-
rustflags.push_str(
274-
"\
274+
rustflags.push_str("\
275275
-C passes=sancov-module \
276-
",
277-
);
276+
");
278277
} else {
279-
rustflags.push_str(
280-
"\
278+
rustflags.push_str("\
281279
-C passes=sancov \
282-
",
283-
);
280+
");
284281
};
285-
282+
286283
rustflags.push_str(
287284
"\
288285
-C llvm-args=-sanitizer-coverage-level=4 \

src/bin/cargo-honggfuzz.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::env;
2-
use std::os::unix::process::CommandExt;
32
use std::process::{self, Command};
3+
use std::os::unix::process::CommandExt;
44

55
const HONGGFUZZ_TARGET: &str = "hfuzz_target";
66

7-
#[cfg(target_family = "windows")]
7+
#[cfg(target_family="windows")]
88
compile_error!("honggfuzz-rs does not currently support Windows but works well under WSL (Windows Subsystem for Linux)");
99

1010
fn main() {
@@ -29,9 +29,6 @@ fn main() {
2929
.exec();
3030

3131
// code flow will only reach here if honggfuzz failed to execute
32-
eprintln!(
33-
"cannot execute {}, try to execute \"cargo hfuzz build\" from fuzzed project directory",
34-
&command,
35-
);
32+
eprintln!("cannot execute {}, try to execute \"cargo hfuzz build\" from fuzzed project directory", &command);
3633
process::exit(1);
3734
}

0 commit comments

Comments
 (0)