[PATCH 2/2] telemetry: use portable syntax to initialize array
Tyler Retzlaff
roretzla at linux.microsoft.com
Mon Apr 3 18:30:24 CEST 2023
Use of ranges in designated initialization are a non-standard gcc
extension. Manually expand the ranges used in designated initialization
to eliminate the use of non-standard features.
Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
---
lib/telemetry/telemetry_data.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/lib/telemetry/telemetry_data.c b/lib/telemetry/telemetry_data.c
index 2bac2de..87e5f18 100644
--- a/lib/telemetry/telemetry_data.c
+++ b/lib/telemetry/telemetry_data.c
@@ -152,12 +152,20 @@
static bool
valid_name(const char *name)
{
- char allowed[128] = {
- ['0' ... '9'] = 1,
- ['A' ... 'Z'] = 1,
- ['a' ... 'z'] = 1,
- ['_'] = 1,
- ['/'] = 1,
+ static const char allowed[128] = {
+ ['0'] = 1, ['1'] = 1, ['2'] = 1, ['3'] = 1, ['4'] = 1,
+ ['5'] = 1, ['6'] = 1, ['7'] = 1, ['8'] = 1, ['9'] = 1,
+ ['A'] = 1, ['B'] = 1, ['C'] = 1, ['D'] = 1, ['E'] = 1,
+ ['F'] = 1, ['G'] = 1, ['H'] = 1, ['I'] = 1, ['J'] = 1,
+ ['K'] = 1, ['L'] = 1, ['M'] = 1, ['N'] = 1, ['O'] = 1,
+ ['P'] = 1, ['Q'] = 1, ['R'] = 1, ['S'] = 1, ['T'] = 1,
+ ['U'] = 1, ['V'] = 1, ['W'] = 1, ['X'] = 1, ['Y'] = 1,
+ ['Z'] = 1, ['a'] = 1, ['b'] = 1, ['c'] = 1, ['d'] = 1,
+ ['e'] = 1, ['f'] = 1, ['g'] = 1, ['h'] = 1, ['i'] = 1,
+ ['j'] = 1, ['k'] = 1, ['l'] = 1, ['m'] = 1, ['n'] = 1,
+ ['o'] = 1, ['p'] = 1, ['q'] = 1, ['r'] = 1, ['s'] = 1,
+ ['t'] = 1, ['u'] = 1, ['v'] = 1, ['w'] = 1, ['x'] = 1,
+ ['y'] = 1, ['z'] = 1, ['_'] = 1, ['/'] = 1,
};
while (*name != '\0') {
if ((size_t)*name >= RTE_DIM(allowed) || allowed[(int)*name] == 0)
--
1.8.3.1
More information about the dev
mailing list