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

Function process_file_args

dpdk/drivers/net/ark/ark_ethdev.c:888–925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

886}
887
888static inline int
889process_file_args(const char *key, const char *value, void *extra_args)
890{
891 ARK_PMD_LOG(DEBUG, "key = %s, value = %s\n",
892 key, value);
893 char *args = (char *)extra_args;
894
895 /* Open the configuration file */
896 FILE *file = fopen(value, "r");
897 char line[ARK_MAX_ARG_LEN];
898 int size = 0;
899 int first = 1;
900
901 if (file == NULL) {
902 ARK_PMD_LOG(ERR, "Unable to open "
903 "config file %s\n", value);
904 return -1;
905 }
906
907 while (fgets(line, sizeof(line), file)) {
908 size += strlen(line);
909 if (size >= ARK_MAX_ARG_LEN) {
910 ARK_PMD_LOG(ERR, "Unable to parse file %s args, "
911 "parameter list is too long\n", value);
912 fclose(file);
913 return -1;
914 }
915 if (first) {
916 strncpy(args, line, ARK_MAX_ARG_LEN);
917 first = 0;
918 } else {
919 strncat(args, line, ARK_MAX_ARG_LEN);
920 }
921 }
922 ARK_PMD_LOG(DEBUG, "file = %s\n", args);
923 fclose(file);
924 return 0;
925}
926
927static int
928eth_ark_check_args(struct ark_adapter *ark, const char *params)

Callers

nothing calls this directly

Calls 2

strncpyFunction · 0.85
strncatFunction · 0.85

Tested by

no test coverage detected