summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2018-03-07 19:07:59 +0100
committerDmitry V. Levin <ldv@altlinux.org>2018-03-07 18:13:29 +0000
commit9611ebbb97ad639fbb77d200dee4305b834a23b1 (patch)
tree97e2e0aae2cc04ad19143ceba7d22cafe6d3a81f
parent07a6399dd6ee7ca68d44d15cf020ea1fe8a15497 (diff)
downloadstrace-9611ebbb97ad639fbb77d200dee4305b834a23b1.tar.gz
Change sorted arrays to be terminated with XLAT_END like unsorted arrays
It is quite unwieldy to have this distinction between sorted and unsorted arrays when we can just decrement the size in a wrapper. * defs.h (printxval_search): Decrement array size. * xlat/fsmagic.in (#unterminated): Remove. * xlat/hw_breakpoint_type.in (#unterminated): Remove. * xlat/perf_hw_cache_id.in (#unterminated): Remove. * xlat/perf_hw_cache_op_id.in (#unterminated): Remove. * xlat/perf_hw_cache_op_result_id.in (#unterminated): Remove. * xlat/perf_hw_id.in (#unterminated): Remove. * xlat/perf_sw_ids.in (#unterminated): Remove. * xlat/perf_type_id.in (#unterminated): Remove. * xlat/gen.sh (gen_header): Remove #unterminated support. Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
-rw-r--r--defs.h7
-rw-r--r--xlat/fsmagic.in1
-rwxr-xr-xxlat/gen.sh14
-rw-r--r--xlat/hw_breakpoint_type.in1
-rw-r--r--xlat/perf_hw_cache_id.in1
-rw-r--r--xlat/perf_hw_cache_op_id.in1
-rw-r--r--xlat/perf_hw_cache_op_result_id.in1
-rw-r--r--xlat/perf_hw_id.in1
-rw-r--r--xlat/perf_sw_ids.in1
-rw-r--r--xlat/perf_type_id.in1
10 files changed, 8 insertions, 21 deletions
diff --git a/defs.h b/defs.h
index 69932dfbc..6eb4b2450 100644
--- a/defs.h
+++ b/defs.h
@@ -562,8 +562,13 @@ extern int printxvals(const uint64_t, const char *, const struct xlat *, ...)
ATTRIBUTE_SENTINEL;
extern int printxval_searchn(const struct xlat *xlat, size_t xlat_size,
uint64_t val, const char *dflt);
+/**
+ * Wrapper around printxval_searchn that passes ARRAY_SIZE - 1
+ * as the array size, as all arrays are XLAT_END-terminated and
+ * printxval_searchn expects a size without the terminating record.
+ */
#define printxval_search(xlat__, val__, dflt__) \
- printxval_searchn(xlat__, ARRAY_SIZE(xlat__), val__, dflt__)
+ printxval_searchn(xlat__, ARRAY_SIZE(xlat__) - 1, val__, dflt__)
extern int sprintxval(char *buf, size_t size, const struct xlat *,
unsigned int val, const char *dflt);
extern int printargs(struct tcb *);
diff --git a/xlat/fsmagic.in b/xlat/fsmagic.in
index a5e614027..b97ec3222 100644
--- a/xlat/fsmagic.in
+++ b/xlat/fsmagic.in
@@ -101,4 +101,3 @@
{ 0xf995e849, "HPFS_SUPER_MAGIC" },
{ 0xfe534d42, "SMB2_MAGIC_NUMBER" },
{ 0xff534d42, "CIFS_MAGIC_NUMBER" },
-#unterminated
diff --git a/xlat/gen.sh b/xlat/gen.sh
index 6db06c517..3c32acd2c 100755
--- a/xlat/gen.sh
+++ b/xlat/gen.sh
@@ -131,7 +131,7 @@ gen_header()
echo "/* Generated by $0 from $1; do not edit. */"
- local unconditional= unterminated= line
+ local unconditional= line
# 1st pass: output directives.
while read line; do
LC_COLLATE=C
@@ -148,9 +148,6 @@ gen_header()
'#unconditional')
unconditional=1
;;
- '#unterminated')
- unterminated=1
- ;;
'#val_type '*)
# to be processed during 2nd pass
;;
@@ -209,9 +206,6 @@ gen_header()
'#unconditional')
unconditional=1
;;
- '#unterminated')
- # processed during 1st pass
- ;;
'#val_type '*)
val_type="${line#\#val_type }"
;;
@@ -237,11 +231,7 @@ gen_header()
;;
esac
done < "${input}"
- if [ -n "${unterminated}" ]; then
- echo " /* this array should remain not NULL-terminated */"
- else
- echo " XLAT_END"
- fi
+ echo ' XLAT_END'
cat <<-EOF
};
diff --git a/xlat/hw_breakpoint_type.in b/xlat/hw_breakpoint_type.in
index 33645d0c8..75267ab29 100644
--- a/xlat/hw_breakpoint_type.in
+++ b/xlat/hw_breakpoint_type.in
@@ -3,4 +3,3 @@ HW_BREAKPOINT_R 1
HW_BREAKPOINT_W 2
HW_BREAKPOINT_RW HW_BREAKPOINT_R | HW_BREAKPOINT_W
HW_BREAKPOINT_X 4
-#unterminated
diff --git a/xlat/perf_hw_cache_id.in b/xlat/perf_hw_cache_id.in
index ecddcb0c0..2346818b7 100644
--- a/xlat/perf_hw_cache_id.in
+++ b/xlat/perf_hw_cache_id.in
@@ -5,4 +5,3 @@ PERF_COUNT_HW_CACHE_DTLB 3
PERF_COUNT_HW_CACHE_ITLB 4
PERF_COUNT_HW_CACHE_BPU 5
PERF_COUNT_HW_CACHE_NODE 6
-#unterminated
diff --git a/xlat/perf_hw_cache_op_id.in b/xlat/perf_hw_cache_op_id.in
index 8a46e0d70..6bbaf3657 100644
--- a/xlat/perf_hw_cache_op_id.in
+++ b/xlat/perf_hw_cache_op_id.in
@@ -1,4 +1,3 @@
PERF_COUNT_HW_CACHE_OP_READ 0
PERF_COUNT_HW_CACHE_OP_WRITE 1
PERF_COUNT_HW_CACHE_OP_PREFETCH 2
-#unterminated
diff --git a/xlat/perf_hw_cache_op_result_id.in b/xlat/perf_hw_cache_op_result_id.in
index d2a77f5a1..8ef5aeadd 100644
--- a/xlat/perf_hw_cache_op_result_id.in
+++ b/xlat/perf_hw_cache_op_result_id.in
@@ -1,3 +1,2 @@
PERF_COUNT_HW_CACHE_RESULT_ACCESS 0
PERF_COUNT_HW_CACHE_RESULT_MISS 1
-#unterminated
diff --git a/xlat/perf_hw_id.in b/xlat/perf_hw_id.in
index a642d0b49..44dd5ce57 100644
--- a/xlat/perf_hw_id.in
+++ b/xlat/perf_hw_id.in
@@ -8,4 +8,3 @@ PERF_COUNT_HW_BUS_CYCLES 6
PERF_COUNT_HW_STALLED_CYCLES_FRONTEND 7
PERF_COUNT_HW_STALLED_CYCLES_BACKEND 8
PERF_COUNT_HW_REF_CPU_CYCLES 9
-#unterminated
diff --git a/xlat/perf_sw_ids.in b/xlat/perf_sw_ids.in
index 95ca15c4b..65b0061a7 100644
--- a/xlat/perf_sw_ids.in
+++ b/xlat/perf_sw_ids.in
@@ -9,4 +9,3 @@ PERF_COUNT_SW_ALIGNMENT_FAULTS 7
PERF_COUNT_SW_EMULATION_FAULTS 8
PERF_COUNT_SW_DUMMY 9
PERF_COUNT_SW_BPF_OUTPUT 10
-#unterminated
diff --git a/xlat/perf_type_id.in b/xlat/perf_type_id.in
index 9133e74de..3f3f87ea8 100644
--- a/xlat/perf_type_id.in
+++ b/xlat/perf_type_id.in
@@ -4,4 +4,3 @@ PERF_TYPE_TRACEPOINT 2
PERF_TYPE_HW_CACHE 3
PERF_TYPE_RAW 4
PERF_TYPE_BREAKPOINT 5
-#unterminated