MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fs_parse_device_param

Function fs_parse_device_param

dpdk/drivers/net/failsafe/failsafe_args.c:199–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199static int
200fs_parse_device_param(struct rte_eth_dev *dev, const char *param,
201 uint8_t head)
202{
203 struct fs_priv *priv;
204 struct sub_device *sdev;
205 char *args = NULL;
206 size_t a, b;
207 int ret;
208
209 priv = PRIV(dev);
210 a = 0;
211 b = 0;
212 ret = 0;
213 while (param[b] != '(' &&
214 param[b] != '\0')
215 b++;
216 a = b;
217 b += closing_paren(&param[b]);
218 if (a == b) {
219 ERROR("Dangling parenthesis");
220 return -EINVAL;
221 }
222 a += 1;
223 args = strndup(&param[a], b - a);
224 if (args == NULL) {
225 ERROR("Not enough memory for parameter parsing");
226 return -ENOMEM;
227 }
228 sdev = &priv->subs[head];
229 if (strncmp(param, "dev", 3) == 0) {
230 ret = fs_parse_device(sdev, args);
231 if (ret)
232 goto free_args;
233 } else if (strncmp(param, "exec", 4) == 0) {
234 ret = fs_execute_cmd(sdev, args);
235 if (ret == -ENODEV) {
236 DEBUG("Reading device info from command line failed");
237 ret = 0;
238 }
239 if (ret)
240 goto free_args;
241 } else if (strncmp(param, "fd(", 3) == 0) {
242 ret = fs_read_fd(sdev, args);
243 if (ret == -ENODEV) {
244 DEBUG("Reading device info from FD failed");
245 ret = 0;
246 }
247 if (ret)
248 goto free_args;
249 } else {
250 ERROR("Unrecognized device type: %.*s", (int)b, param);
251 ret = -EINVAL;
252 }
253free_args:
254 free(args);
255 return ret;
256}

Callers

nothing calls this directly

Calls 7

closing_parenFunction · 0.85
strndupFunction · 0.85
strncmpFunction · 0.85
fs_parse_deviceFunction · 0.85
fs_execute_cmdFunction · 0.85
fs_read_fdFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected