[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 1/9] qemu-binfmt-conf.sh: enforce safe style consistency
From: |
Unai Martinez-Corral |
Subject: |
[PATCH v9 1/9] qemu-binfmt-conf.sh: enforce safe style consistency |
Date: |
Mon, 9 Mar 2020 18:36:51 +0000 |
Spaces are removed before '; then', for consistency.
All the tests are prefixed with 'x', in order to avoid risky comparisons
(i.e. a user deliberately trying to provoke a syntax error).
Signed-off-by: umarcor <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
---
scripts/qemu-binfmt-conf.sh | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
index 9f1580a91c..98401f4e7c 100755
--- a/scripts/qemu-binfmt-conf.sh
+++ b/scripts/qemu-binfmt-conf.sh
@@ -215,7 +215,7 @@ EOF
}
qemu_check_access() {
- if [ ! -w "$1" ] ; then
+ if [ ! -w "$1" ]; then
echo "ERROR: cannot write to $1" 1>&2
exit 1
fi
@@ -224,12 +224,12 @@ qemu_check_access() {
qemu_check_bintfmt_misc() {
# load the binfmt_misc module
if [ ! -d /proc/sys/fs/binfmt_misc ]; then
- if ! /sbin/modprobe binfmt_misc ; then
+ if ! /sbin/modprobe binfmt_misc; then
exit 1
fi
fi
if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
- if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc ; then
+ if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc; then
exit 1
fi
fi
@@ -242,16 +242,16 @@ installed_dpkg() {
}
qemu_check_debian() {
- if [ ! -e /etc/debian_version ] ; then
+ if [ ! -e /etc/debian_version ]; then
echo "WARNING: your system is not a Debian based distro" 1>&2
- elif ! installed_dpkg binfmt-support ; then
+ elif ! installed_dpkg binfmt-support; then
echo "WARNING: package binfmt-support is needed" 1>&2
fi
qemu_check_access "$EXPORTDIR"
}
qemu_check_systemd() {
- if ! systemctl -q is-enabled systemd-binfmt.service ; then
+ if ! systemctl -q is-enabled systemd-binfmt.service; then
echo "WARNING: systemd-binfmt.service is missing or disabled" 1>&2
fi
qemu_check_access "$EXPORTDIR"
@@ -259,10 +259,10 @@ qemu_check_systemd() {
qemu_generate_register() {
flags=""
- if [ "$CREDENTIAL" = "yes" ] ; then
+ if [ "x$CREDENTIAL" = "xyes" ]; then
flags="OC"
fi
- if [ "$PERSISTENT" = "yes" ] ; then
+ if [ "x$PERSISTENT" = "xyes" ]; then
flags="${flags}F"
fi
@@ -295,23 +295,23 @@ qemu_set_binfmts() {
# register the interpreter for each cpu except for the native one
- for cpu in ${qemu_target_list} ; do
+ for cpu in ${qemu_target_list}; do
magic=$(eval echo \$${cpu}_magic)
mask=$(eval echo \$${cpu}_mask)
family=$(eval echo \$${cpu}_family)
- if [ "$magic" = "" ] || [ "$mask" = "" ] || [ "$family" = "" ] ; then
+ if [ "x$magic" = "x" ] || [ "x$mask" = "x" ] || [ "x$family" = "x" ];
then
echo "INTERNAL ERROR: unknown cpu $cpu" 1>&2
continue
fi
qemu="$QEMU_PATH/qemu-$cpu"
- if [ "$cpu" = "i486" ] ; then
+ if [ "x$cpu" = "xi486" ]; then
qemu="$QEMU_PATH/qemu-i386"
fi
qemu="$qemu$QEMU_SUFFIX"
- if [ "$host_family" != "$family" ] ; then
+ if [ "x$host_family" != "x$family" ]; then
$BINFMT_SET
fi
done
@@ -331,7 +331,7 @@ QEMU_SUFFIX=""
options=$(getopt -o ds:Q:S:e:hc:p: -l
debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential:,persistent:
-- "$@")
eval set -- "$options"
-while true ; do
+while true; do
case "$1" in
-d|--debian)
CHECK=qemu_check_debian
@@ -344,14 +344,14 @@ while true ; do
EXPORTDIR=${EXPORTDIR:-$SYSTEMDDIR}
shift
# check given cpu is in the supported CPU list
- if [ "$1" != "ALL" ] ; then
- for cpu in ${qemu_target_list} ; do
- if [ "$cpu" = "$1" ] ; then
+ if [ "$1" != "ALL" ]; then
+ for cpu in ${qemu_target_list}; do
+ if [ "$cpu" = "$1" ]; then
break
fi
done
- if [ "$cpu" = "$1" ] ; then
+ if [ "$cpu" = "$1" ]; then
qemu_target_list="$1"
else
echo "ERROR: unknown CPU \"$1\"" 1>&2
--
2.25.1
- [PATCH v9 0/9] qemu-binfmt-conf.sh, Unai Martinez-Corral, 2020/03/09
- [PATCH v9 1/9] qemu-binfmt-conf.sh: enforce safe style consistency,
Unai Martinez-Corral <=
- [PATCH v9 2/9] qemu-binfmt-conf.sh: make opts -p and -c boolean, Unai Martinez-Corral, 2020/03/09
- [PATCH v9 3/9] qemu-binfmt-conf.sh: add QEMU_CREDENTIAL and QEMU_PERSISTENT, Unai Martinez-Corral, 2020/03/09
- [PATCH v9 4/9] qemu-binfmt-conf.sh: use the same presentation format as for qemu-*, Unai Martinez-Corral, 2020/03/09
- [PATCH v9 5/9] qemu-binfmt-conf.sh: remove 'qemu' prefix from cli options, Unai Martinez-Corral, 2020/03/09
- [PATCH v9 6/9] qemu-binfmt-conf.sh: honour QEMU_PATH and/or QEMU_SUFFIX, Unai Martinez-Corral, 2020/03/09
- [PATCH v9 7/9] qemu-binfmt-conf.sh: generalize <CPU> to positional [TARGETS], Unai Martinez-Corral, 2020/03/09
- [PATCH v9 8/9] qemu-binfmt-conf.sh: add option --clear, Unai Martinez-Corral, 2020/03/09
- [PATCH v9 9/9] qemu-binfmt-conf.sh: add --test, Unai Martinez-Corral, 2020/03/09
- Re: [PATCH v9 0/9] qemu-binfmt-conf.sh, no-reply, 2020/03/09
- Re: [PATCH v9 0/9] qemu-binfmt-conf.sh, no-reply, 2020/03/09