Skip to content

Commit d5cbd63

Browse files
committed
fix clippy and shellcheck issues
1 parent 106a5cd commit d5cbd63

File tree

41 files changed

+445
-381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+445
-381
lines changed

ci/android-install-ndk.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
33
# file at the top-level directory of this distribution and at
44
# http://rust-lang.org/COPYRIGHT.
@@ -11,10 +11,11 @@
1111

1212
set -ex
1313

14-
curl -O https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip
14+
curl -O \
15+
https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip
1516
unzip -q android-ndk-r15b-linux-x86_64.zip
1617

17-
case "$1" in
18+
case "${1}" in
1819
aarch64)
1920
arch=arm64
2021
;;
@@ -24,14 +25,14 @@ case "$1" in
2425
;;
2526

2627
*)
27-
arch=$1
28+
arch="${1}"
2829
;;
2930
esac;
3031

3132
android-ndk-r15b/build/tools/make_standalone_toolchain.py \
3233
--unified-headers \
33-
--install-dir /android/ndk-$1 \
34-
--arch $arch \
34+
--install-dir "/android/ndk-${1}" \
35+
--arch "${arch}" \
3536
--api 24
3637

3738
rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b

ci/android-install-sdk.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
33
# file at the top-level directory of this distribution and at
44
# http://rust-lang.org/COPYRIGHT.
@@ -56,5 +56,5 @@ echo "yes" | \
5656

5757
echo "no" |
5858
./sdk/tools/bin/avdmanager create avd \
59-
--name $1 \
59+
--name "${1}" \
6060
--package "system-images;android-24;default;$abi"

ci/android-sysimage.sh

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
24
# file at the top-level directory of this distribution and at
35
# http://rust-lang.org/COPYRIGHT.
@@ -13,40 +15,42 @@ set -ex
1315
URL=https://dl.google.com/android/repository/sys-img/android
1416

1517
main() {
16-
local arch=$1
17-
local name=$2
18+
local arch="${1}"
19+
local name="${2}"
1820
local dest=/system
19-
local td=$(mktemp -d)
21+
local td
22+
td="$(mktemp -d)"
2023

2124
apt-get install --no-install-recommends e2tools
2225

23-
pushd $td
24-
curl -O $URL/$name
25-
unzip -q $name
26+
pushd "$td"
27+
curl -O "${URL}/${name}"
28+
unzip -q "${name}"
2629

27-
local system=$(find . -name system.img)
30+
local system
31+
system=$(find . -name system.img)
2832
mkdir -p $dest/{bin,lib,lib64}
2933

3034
# Extract android linker and libraries to /system
3135
# This allows android executables to be run directly (or with qemu)
32-
if [ $arch = "x86_64" -o $arch = "arm64" ]; then
33-
e2cp -p $system:/bin/linker64 $dest/bin/
34-
e2cp -p $system:/lib64/libdl.so $dest/lib64/
35-
e2cp -p $system:/lib64/libc.so $dest/lib64/
36-
e2cp -p $system:/lib64/libm.so $dest/lib64/
36+
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then
37+
e2cp -p "${system}:/bin/linker64" "${dest}/bin/"
38+
e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/"
39+
e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/"
40+
e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/"
3741
else
38-
e2cp -p $system:/bin/linker $dest/bin/
39-
e2cp -p $system:/lib/libdl.so $dest/lib/
40-
e2cp -p $system:/lib/libc.so $dest/lib/
41-
e2cp -p $system:/lib/libm.so $dest/lib/
42+
e2cp -p "${system}:/bin/linker" "${dest}/bin/"
43+
e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/"
44+
e2cp -p "${system}:/lib/libc.so" "${dest}/lib/"
45+
e2cp -p "${system}:/lib/libm.so" "${dest}/lib/"
4246
fi
4347

4448
# clean up
4549
apt-get purge --auto-remove -y e2tools
4650

4751
popd
4852

49-
rm -rf $td
53+
rm -rf "${td}"
5054
}
5155

5256
main "${@}"

ci/dox.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

33
# Builds documentation for all target triples that we have a registered URL for
44
# in liblibc. This scrapes the list of triples to document from `src/lib.rs`
@@ -13,27 +13,27 @@ dox() {
1313
local arch=$1
1414
local target=$2
1515

16-
echo documenting $arch
16+
echo "documenting ${arch}"
1717

1818
if [ "$CI" != "" ]; then
19-
rustup target add $target || true
19+
rustup target add "${target}" || true
2020
fi
2121

22-
rm -rf target/doc/$arch
23-
mkdir target/doc/$arch
22+
rm -rf "target/doc/${arch}"
23+
mkdir "target/doc/${arch}"
2424

25-
cargo build --verbose --target $target --manifest-path crates/stdsimd/Cargo.toml
25+
cargo build --verbose --target "${target}" --manifest-path crates/stdsimd/Cargo.toml
2626

27-
rustdoc --verbose --target $target \
28-
-o target/doc/$arch crates/coresimd/src/lib.rs \
27+
rustdoc --verbose --target "${target}" \
28+
-o "target/doc/${arch}" crates/coresimd/src/lib.rs \
2929
--crate-name coresimd \
30-
--library-path target/$target/debug/deps
31-
rustdoc --verbose --target $target \
32-
-o target/doc/$arch crates/stdsimd/src/lib.rs \
30+
--library-path "target/${target}/debug/deps"
31+
rustdoc --verbose --target "${target}" \
32+
-o "target/doc/${arch}" crates/stdsimd/src/lib.rs \
3333
--crate-name stdsimd \
34-
--library-path target/$target/debug/deps \
35-
--extern cfg_if=`ls target/$target/debug/deps/libcfg_if-*.rlib` \
36-
--extern libc=`ls target/$target/debug/deps/liblibc-*.rlib`
34+
--library-path "target/${target}/debug/deps" \
35+
--extern cfg_if="$(ls target/"${target}"/debug/deps/libcfg_if-*.rlib)" \
36+
--extern libc="$(ls target/"${target}"/debug/deps/liblibc-*.rlib)"
3737
}
3838

3939
dox i686 i686-unknown-linux-gnu
@@ -49,6 +49,6 @@ dox wasm32 wasm32-unknown-unknown
4949
# If we're on travis, not a PR, and on the right branch, publish!
5050
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
5151
pip install ghp_import --install-option="--prefix=$HOME/.local"
52-
$HOME/.local/bin/ghp-import -n target/doc
53-
git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
52+
"${HOME}/.local/bin/ghp-import" -n target/doc
53+
git push -qf "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" gh-pages
5454
fi

ci/run-docker.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1+
#!/usr/bin/env sh
2+
13
# Small script to run tests for a target (or all targets) inside all the
24
# respective docker images.
35

46
set -ex
57

68
run() {
79
echo "Building docker container for TARGET=${1}"
8-
docker build -t stdsimd -f ci/docker/$1/Dockerfile ci/
10+
docker build -t stdsimd -f "ci/docker/${1}/Dockerfile" ci/
911
mkdir -p target
10-
target=$(echo $1 | sed 's/-emulated//')
12+
target=$(echo "${1}" | sed 's/-emulated//')
1113
echo "Running docker"
1214
docker run \
13-
--user `id -u`:`id -g` \
15+
--user "$(id -u)":"$(id -g)" \
1416
--rm \
1517
--init \
16-
--volume $HOME/.cargo:/cargo-h \
18+
--volume "${HOME}"/.cargo:/cargo-h \
1719
--env CARGO_HOME=/cargo-h \
18-
--volume `rustc --print sysroot`:/rust:ro \
19-
--env TARGET=$target \
20+
--volume "$(rustc --print sysroot)":/rust:ro \
21+
--env TARGET="${target}" \
2022
--env STDSIMD_TEST_EVERYTHING \
2123
--env STDSIMD_ASSERT_INSTR_IGNORE \
2224
--env STDSIMD_DISABLE_ASSERT_INSTR \
2325
--env NOSTD \
2426
--env NORUN \
2527
--env STDSIMD_TEST_NORUN \
26-
--volume `pwd`:/checkout:ro \
27-
--volume `pwd`/target:/checkout/target \
28+
--volume "$(pwd)":/checkout:ro \
29+
--volume "$(pwd)"/target:/checkout/target \
2830
--workdir /checkout \
2931
--privileged \
3032
stdsimd \
@@ -33,9 +35,9 @@ run() {
3335
}
3436

3537
if [ -z "$1" ]; then
36-
for d in `ls ci/docker/`; do
37-
run $d
38+
for d in ci/docker/*; do
39+
run "${d}"
3840
done
3941
else
40-
run $1
42+
run "${1}"
4143
fi

ci/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/bin/sh
1+
#!/usr/bin/env sh
22

33
set -ex
44

5-
: ${TARGET?"The TARGET environment variable must be set."}
5+
: "${TARGET?The TARGET environment variable must be set.}"
66

77
# Tests are all super fast anyway, and they fault often enough on travis that
88
# having only one thread increases debuggability to be worth it.

coresimd/aarch64/neon.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ mod tests {
16921692

16931693
#[simd_test(enable = "neon")]
16941694
unsafe fn test_vmaxvq_s8() {
1695-
#[cfg_attr(rustfmt, rustfmt_skip)]
1695+
#[rustfmt::skip]
16961696
let r = vmaxvq_s8(::mem::transmute(i8x16::new(
16971697
1, 2, 3, 4,
16981698
-16, 6, 7, 5,
@@ -1735,7 +1735,7 @@ mod tests {
17351735

17361736
#[simd_test(enable = "neon")]
17371737
unsafe fn test_vmaxvq_u8() {
1738-
#[cfg_attr(rustfmt, rustfmt_skip)]
1738+
#[rustfmt::skip]
17391739
let r = vmaxvq_u8(::mem::transmute(u8x16::new(
17401740
1, 2, 3, 4,
17411741
16, 6, 7, 5,
@@ -1796,7 +1796,7 @@ mod tests {
17961796

17971797
#[simd_test(enable = "neon")]
17981798
unsafe fn test_vminvq_s8() {
1799-
#[cfg_attr(rustfmt, rustfmt_skip)]
1799+
#[rustfmt::skip]
18001800
let r = vminvq_s8(::mem::transmute(i8x16::new(
18011801
1, 2, 3, 4,
18021802
-16, 6, 7, 5,
@@ -1839,7 +1839,7 @@ mod tests {
18391839

18401840
#[simd_test(enable = "neon")]
18411841
unsafe fn test_vminvq_u8() {
1842-
#[cfg_attr(rustfmt, rustfmt_skip)]
1842+
#[rustfmt::skip]
18431843
let r = vminvq_u8(::mem::transmute(u8x16::new(
18441844
1, 2, 3, 4,
18451845
16, 6, 7, 5,

coresimd/macros.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ macro_rules! types {
1010
#[derive(Copy, Clone, Debug)]
1111
#[allow(non_camel_case_types)]
1212
#[repr(simd)]
13+
#[cfg_attr(feature = "cargo-clippy",
14+
allow(clippy::missing_inline_in_public_items))]
1315
pub struct $name($($fields)*);
1416
)*)
1517
}

coresimd/mips/msa.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ mod tests {
4141

4242
#[simd_test(enable = "msa")]
4343
unsafe fn __msa_add_a_b() {
44-
#[cfg_attr(rustfmt, rustfmt_skip)]
44+
#[rustfmt::skip]
4545
let a = i8x16(
4646
1, 2, 3, 4,
4747
1, 2, 3, 4,
4848
1, 2, 3, 4,
4949
1, 2, 3, 4,
5050
);
51-
#[cfg_attr(rustfmt, rustfmt_skip)]
51+
#[rustfmt::skip]
5252
let b = i8x16(
5353
-4, -3, -2, -1,
5454
-4, -3, -2, -1,

coresimd/simd.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Internal `#[repr(simd)]` types
22
3-
#![cfg_attr(rustfmt, rustfmt_skip)]
4-
3+
#![rustfmt::skip]
54
#![allow(non_camel_case_types)]
65

76
macro_rules! simd_ty {

0 commit comments

Comments
 (0)