Commit 989e5b8
rtla/actions: Simplify argument parsing
The actions_parse() function uses open-coded logic to extract arguments
from a string. This includes manual length checks and strncmp() calls,
which can be verbose and error-prone.
To simplify and improve the robustness of argument parsing, introduce a
new extract_arg() helper macro. This macro extracts the value from a
"key=value" pair, making the code more concise and readable.
Also, introduce STRING_LENGTH() and strncmp_static() macros to
perform compile-time calculations of string lengths and safer string
comparisons.
Refactor actions_parse() to use these new helpers, resulting in
cleaner and more maintainable code.
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Link: https://lore.kernel.org/r/20260309195040.1019085-4-wander@redhat.com
Signed-off-by: Tomas Glozar <tglozar@redhat.com>1 parent b8f7f49 commit 989e5b8
2 files changed
Lines changed: 52 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
114 | 137 | | |
115 | 138 | | |
116 | 139 | | |
| |||
120 | 143 | | |
121 | 144 | | |
122 | 145 | | |
| 146 | + | |
123 | 147 | | |
124 | 148 | | |
125 | 149 | | |
| |||
152 | 176 | | |
153 | 177 | | |
154 | 178 | | |
155 | | - | |
156 | | - | |
157 | | - | |
| 179 | + | |
| 180 | + | |
158 | 181 | | |
159 | 182 | | |
160 | | - | |
161 | 183 | | |
162 | 184 | | |
163 | 185 | | |
| |||
169 | 191 | | |
170 | 192 | | |
171 | 193 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
179 | 197 | | |
180 | 198 | | |
181 | | - | |
182 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
183 | 209 | | |
184 | 210 | | |
185 | 211 | | |
| |||
194 | 220 | | |
195 | 221 | | |
196 | 222 | | |
197 | | - | |
| 223 | + | |
| 224 | + | |
198 | 225 | | |
199 | | - | |
| 226 | + | |
200 | 227 | | |
201 | 228 | | |
202 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
17 | 27 | | |
18 | 28 | | |
19 | 29 | | |
| |||
0 commit comments