From: Eugene Syromyatnikov Date: Wed, 7 Mar 2018 18:07:59 +0000 (+0100) Subject: Change sorted arrays to be terminated with XLAT_END like unsorted arrays X-Git-Tag: v4.22~109 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9611ebbb97ad639fbb77d200dee4305b834a23b1;p=strace 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 --- diff --git a/defs.h b/defs.h index 69932dfb..6eb4b245 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 a5e61402..b97ec322 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 6db06c51..3c32acd2 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 33645d0c..75267ab2 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 ecddcb0c..2346818b 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 8a46e0d7..6bbaf365 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 d2a77f5a..8ef5aead 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 a642d0b4..44dd5ce5 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 95ca15c4..65b0061a 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 9133e74d..3f3f87ea 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