]> granicus.if.org Git - strace/commitdiff
Change sorted arrays to be terminated with XLAT_END like unsorted arrays
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 7 Mar 2018 18:07:59 +0000 (19:07 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 7 Mar 2018 18:13:29 +0000 (18:13 +0000)
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>
defs.h
xlat/fsmagic.in
xlat/gen.sh
xlat/hw_breakpoint_type.in
xlat/perf_hw_cache_id.in
xlat/perf_hw_cache_op_id.in
xlat/perf_hw_cache_op_result_id.in
xlat/perf_hw_id.in
xlat/perf_sw_ids.in
xlat/perf_type_id.in

diff --git a/defs.h b/defs.h
index 69932dfbc96d22fba70a46d12e9df7ff37a7a8dc..6eb4b2450d8a1babbaa05f059e1660488af8cb82 100644 (file)
--- 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 *);
index a5e6140276bb475e2ea267a9529ff5bcc63e56e6..b97ec3222194fde24346364a65bb52019c682b66 100644 (file)
 { 0xf995e849,  "HPFS_SUPER_MAGIC"      },
 { 0xfe534d42,  "SMB2_MAGIC_NUMBER"     },
 { 0xff534d42,  "CIFS_MAGIC_NUMBER"     },
-#unterminated
index 6db06c517c90ab8a69b8de9440fcc263244002d9..3c32acd2c15f40dd7222603d52c33358445410be 100755 (executable)
@@ -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
                };
index 33645d0c833685e3acebc9031e67e2d788b6f70e..75267ab29e435e62506c8dbfb94b01db7b921226 100644 (file)
@@ -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
index ecddcb0c0140e4472d4f50a7f8288ae5e25b1c54..2346818b78a201cd48eb9a908a3bcacaf03ede7a 100644 (file)
@@ -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
index 8a46e0d7041b78a9863c5e2f03ccfe8ba90b586d..6bbaf36575b5d59e08e29d61a2fb4f3be588ecdd 100644 (file)
@@ -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
index d2a77f5a19447e83da943284308529b948b10e1a..8ef5aeaddd2d4c73152855668192c577254d46c5 100644 (file)
@@ -1,3 +1,2 @@
 PERF_COUNT_HW_CACHE_RESULT_ACCESS 0
 PERF_COUNT_HW_CACHE_RESULT_MISS   1
-#unterminated
index a642d0b496bf4f17d6dd12fc20aaaa7a9419b25a..44dd5ce574506cb6bc6d4dfe46d6e7d3c7ce0181 100644 (file)
@@ -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
index 95ca15c4b7883f8e4691d5edf018df525b98baa5..65b0061a7cb5c9ef97c53be296e37f735467f034 100644 (file)
@@ -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
index 9133e74defb5c57392ed28ab4b8a16b16c152901..3f3f87ea82c6e2f103b950924965f25f1f4150d4 100644 (file)
@@ -4,4 +4,3 @@ PERF_TYPE_TRACEPOINT  2
 PERF_TYPE_HW_CACHE    3
 PERF_TYPE_RAW         4
 PERF_TYPE_BREAKPOINT  5
-#unterminated