#include "rte_swx_pipeline.h"
#include "rte_swx_ctl.h"
-#define MAX_LINE_LENGTH 256
-#define MAX_TOKENS 16
-#define MAX_INSTRUCTION_LENGTH 256
+#define MAX_LINE_LENGTH RTE_SWX_INSTRUCTION_SIZE
+#define MAX_TOKENS RTE_SWX_INSTRUCTION_TOKENS_MAX
#define STRUCT_BLOCK 0
#define ACTION_BLOCK 1
static void
extobj_spec_free(struct extobj_spec *s)
{
+ if (!s)
+ return;
+
free(s->name);
+ s->name = NULL;
+
free(s->extern_type_name);
+ s->extern_type_name = NULL;
+
free(s->pragma);
+ s->pragma = NULL;
}
static int
static void
header_spec_free(struct header_spec *s)
{
+ if (!s)
+ return;
+
free(s->name);
+ s->name = NULL;
+
free(s->struct_type_name);
+ s->struct_type_name = NULL;
}
static int
static void
metadata_spec_free(struct metadata_spec *s)
{
+ if (!s)
+ return;
+
free(s->struct_type_name);
+ s->struct_type_name = NULL;
}
static int
uint32_t *err_line,
const char **err_msg)
{
- char buffer[MAX_INSTRUCTION_LENGTH], *instr;
+ char buffer[RTE_SWX_INSTRUCTION_SIZE], *instr;
const char **new_instructions;
uint32_t i;
uint32_t *err_line,
const char **err_msg)
{
- char buffer[MAX_INSTRUCTION_LENGTH], *instr;
+ char buffer[RTE_SWX_INSTRUCTION_SIZE], *instr;
const char **new_instructions;
uint32_t i;
goto error;
}
+ /* Handle excessively long tokens. */
+ if (strnlen(token, RTE_SWX_NAME_SIZE) >=
+ RTE_SWX_NAME_SIZE) {
+ if (err_line)
+ *err_line = n_lines;
+ if (err_msg)
+ *err_msg = "Token too big.";
+ status = -EINVAL;
+ goto error;
+ }
+
/* Save token. */
tokens[n_tokens] = token;
n_tokens++;