Skip to content

Commit f5e074d

Browse files
committed
devtools: add quiet mode in uAPI script
Most messages from the Linux uAPI script are not useful when running the script in a regular fashion. The quiet mode (option -q) is added to output only error messages if any. Signed-off-by: Thomas Monjalon <[email protected]> Reviewed-by: Maxime Coquelin <[email protected]>
1 parent a4468e5 commit f5e074d

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

devtools/linux-uapi.sh

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ base_path="kernel/linux/uapi/"
1111
version=""
1212
file=""
1313
check_headers=false
14+
quiet=false
1415

1516
print_usage()
1617
{
17-
echo "Usage: $(basename $0) [-h] [-i FILE] [-u VERSION] [-c]"
18+
echo "Usage: $(basename $0) [-h] [-i FILE] [-u VERSION] [-c] [-q]"
1819
echo "-i FILE import Linux header file. E.g. linux/vfio.h"
1920
echo "-u VERSION update imported list of Linux headers to a given version. E.g. v6.10"
2021
echo "-c check headers are valid"
22+
echo "-q quiet mode"
2123
}
2224

2325
version_older_than() {
@@ -43,7 +45,7 @@ update_headers()
4345
{
4446
local header
4547

46-
echo "Updating to $version"
48+
$quiet || echo "Updating to $version"
4749
for filename in $(find $base_path -name "*.h" -type f); do
4850
header=${filename#$base_path}
4951
download_header $header $filename
@@ -65,7 +67,7 @@ import_header()
6567
for include in $(sed -ne 's/^#include <\(.*\)>$/\1/p' $path); do
6668
if [ ! -f "$base_path$include" ]; then
6769
read -p "Import $include (y/n): " import && [ "$import" = 'y' ] || continue
68-
echo "Importing $include for $path"
70+
$quiet || echo "Importing $include for $path"
6971
import_header "$include"
7072
fi
7173
done
@@ -92,13 +94,13 @@ update_all()
9294
{
9395
if [ -n "$version" ]; then
9496
if version_older_than "$version" "$current_version"; then
95-
echo "Headers already up to date ($current_version >= $version)"
97+
$quiet || echo "Headers already up to date ($current_version >= $version)"
9698
version=$current_version
9799
else
98100
update_headers
99101
fi
100102
else
101-
echo "Version not specified, using current version ($current_version)"
103+
$quiet || echo "Version not specified, using current version ($current_version)"
102104
version=$current_version
103105
fi
104106

@@ -115,14 +117,14 @@ update_all()
115117

116118
check_header()
117119
{
118-
echo -n "Checking $1... "
120+
$quiet || echo -n "Checking $1... "
119121

120122
if ! diff -q $1 $2 >/dev/null; then
121-
echo "KO"
122-
diff -u $1 $2
123+
$quiet || echo "KO"
124+
$quiet || diff -u $1 $2
123125
return 1
124126
else
125-
echo "OK"
127+
$quiet || echo "OK"
126128
fi
127129

128130
return 0
@@ -135,26 +137,29 @@ check_all()
135137
tmpheader="$(mktemp -t dpdk.checkuapi.XXXXXX)"
136138
trap "rm -f '$tmpheader'" INT
137139

138-
echo "Checking imported headers for version $version"
140+
$quiet || echo "Checking imported headers for version $version"
139141
for filename in $(find $base_path -name "*.h" -type f); do
140142
header=${filename#$base_path}
141143
download_header $header $tmpheader
142144
fixup_includes $tmpheader
143145
check_header $filename $tmpheader || errors=$((errors+1))
144146
done
145-
echo "$errors error(s) found"
147+
if [ $errors -ne 0 ] || ! $quiet; then
148+
echo "$errors error(s) found in Linux uAPI"
149+
fi
146150

147151
rm -f $tmpheader
148152
trap - INT
149153

150154
return $errors
151155
}
152156

153-
while getopts i:u:ch opt ; do
157+
while getopts i:u:cqh opt ; do
154158
case $opt in
155159
i ) file=$OPTARG ;;
156160
u ) version=$OPTARG ;;
157161
c ) check_headers=true ;;
162+
q ) quiet=true ;;
158163
h ) print_usage ; exit 0 ;;
159164
? ) print_usage ; exit 1 ;;
160165
esac

0 commit comments

Comments
 (0)