Skip to content

Commit 063548f

Browse files
committed
Fix SC2181 issues in kdump-udev-throttler
Fix the issues found by shellcheck, In kdump-udev-throttler line 30: if [ $? -ne 0 ]; then ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. In kdump-udev-throttler line 37: if [ $? -ne 0 ]; then ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. Also add kdump-udev-throttler to shellcheck list for Github Action. Signed-off-by: Coiby Xu <[email protected]>
1 parent 5395875 commit 063548f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- run: dnf install shellcheck -y
2020
# Currently, for kdump-utils, there is need for shellcheck to require
2121
# the sourced file to give correct warnings about the checked file
22-
- run: shellcheck -x *.sh kdumpctl mk*dumprd
22+
- run: shellcheck -x *.sh kdumpctl mk*dumprd kdump-udev-throttler
2323
- run: shellcheck -x dracut/*/*.sh
2424
- run: shellcheck -x tests/*/*/*.sh tools/*.sh
2525
# disable the follow checks for unit tests

kdump-udev-throttler

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ unuse_luks_keys()
2626

2727
[[ -f $LUKS_CONFIGFS_REUSE ]] || echo 0 > $LUKS_CONFIGFS_REUSE
2828
}
29-
exec 9> $throttle_lock
30-
if [ $? -ne 0 ]; then
29+
30+
if ! exec 9> $throttle_lock; then
3131
echo "Failed to create the lock file! Fallback to non-throttled kdump service restart"
3232
/bin/kdumpctl reload
3333
exit 1
3434
fi
3535

36-
flock -n 9
37-
if [ $? -ne 0 ]; then
36+
if ! flock -n 9; then
3837
echo "Throttling kdump restart for concurrent udev event"
3938
exit 0
4039
fi

0 commit comments

Comments
 (0)