qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qerror: add check-qerror.sh to verify alphabetical order

We're supposed to keep qerror definitions and table entries in
alphabetical order. In practice this is not checked.

I haven't found a nice way to integrate this into the makefile yet but
we can at least have this script which verifies that qerrors are in
alphabetical order.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>

authored by

Stefan Hajnoczi and committed by
Luiz Capitulino
9737383b aba2107a

+24 -3
+1 -2
qerror.c
··· 40 40 * "running out of foo: %(foo)%%" 41 41 * 42 42 * Please keep the entries in alphabetical order. 43 - * Use "sed -n '/^static.*qerror_table\[\]/,/^};/s/QERR_/&/gp' qerror.c | sort -c" 44 - * to check. 43 + * Use scripts/check-qerror.sh to check. 45 44 */ 46 45 static const QErrorStringTable qerror_table[] = { 47 46 {
+1 -1
qerror.h
··· 49 49 /* 50 50 * QError class list 51 51 * Please keep the definitions in alphabetical order. 52 - * Use "grep '^#define QERR_' qerror.h | sort -c" to check. 52 + * Use scripts/check-qerror.sh to check. 53 53 */ 54 54 #define QERR_BAD_BUS_FOR_DEVICE \ 55 55 "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
+22
scripts/check-qerror.sh
··· 1 + #!/bin/sh 2 + # This script verifies that qerror definitions and table entries are 3 + # alphabetically ordered. 4 + 5 + check_order() { 6 + errmsg=$1 7 + shift 8 + 9 + # sort -C verifies order but does not print a message. sort -c does print a 10 + # message. These options are both in POSIX. 11 + if ! "$@" | sort -C; then 12 + echo "$errmsg" 13 + "$@" | sort -c 14 + exit 1 15 + fi 16 + return 0 17 + } 18 + 19 + check_order 'Definitions in qerror.h must be in alphabetical order:' \ 20 + grep '^#define QERR_' qerror.h 21 + check_order 'Entries in qerror.c:qerror_table must be in alphabetical order:' \ 22 + sed -n '/^static.*qerror_table\[\]/,/^};/s/QERR_/&/gp' qerror.c