Skip to content

Commit

Permalink
preferring python's black over system black
Browse files Browse the repository at this point in the history
  • Loading branch information
riesentoaster committed Nov 7, 2024
1 parent 3bd914b commit aa8e499
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions scripts/fmt_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ else
cargo run --manifest-path "$LIBAFL_DIR/utils/libafl_fmt/Cargo.toml" --release -- --verbose || exit 1
fi

if command -v black > /dev/null; then
if python3 -m black --version > /dev/null; then
BLACK_COMMAND="python3 -m black"
elif command -v black > /dev/null; then
BLACK_COMMAND="black"
fi

if [ -n "$BLACK_COMMAND" ]; then
echo "[*] Formatting python files"
if [ "$1" = "check" ]; then
black --check --diff "$LIBAFL_DIR" || exit 1
$BLACK_COMMAND --check --diff "$LIBAFL_DIR" || exit 1
else
black "$LIBAFL_DIR" || exit 1
$BLACK_COMMAND "$LIBAFL_DIR" || exit 1
fi
else
echo -e "\n\033[1;33mWarning\033[0m: python black not found. Formatting skipped for python.\n"
Expand Down
6 changes: 3 additions & 3 deletions utils/cfg_builder/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
fnname2SG = dict()
# First, add all the intra-procedural edges

for (fname, v) in module["edges"].items():
for fname, v in module["edges"].items():

if fname not in fname2id:
GG.add_node(f_ids, label=fname)
Expand All @@ -51,8 +51,8 @@
G.add_edge(node_id_list[src], node_id_list[item])

# Next, build inter-procedural edges
for (fname, calls) in module["calls"].items():
for (idx, target_fns) in calls.items():
for fname, calls in module["calls"].items():
for idx, target_fns in calls.items():
# G.nodes isn't sorted

src = sorted(fnname2SG[fname].nodes())[0] + int(idx)
Expand Down

0 comments on commit aa8e499

Please sign in to comment.