summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@users.noreply.github.com>2019-06-13 21:06:24 +0200
committerGitHub <noreply@github.com>2019-06-13 21:06:24 +0200
commit42aac9b2abe62b3eae952ba690bdec855edc1ba7 (patch)
tree9b63a18ee4b099a6c5229f807e934d0b9c78fdb3 /lib
parentMerge pull request #4509 from opensourcerouting/spanish-intquisition (diff)
parentlib/clippy: expand some macros (diff)
downloadfrr-42aac9b2abe62b3eae952ba690bdec855edc1ba7.tar.xz
frr-42aac9b2abe62b3eae952ba690bdec855edc1ba7.zip
Merge pull request #4500 from opensourcerouting/clippy-improve
clippy: batch of improvements
Diffstat (limited to 'lib')
-rw-r--r--lib/clippy.c2
-rw-r--r--lib/defun_lex.l17
-rw-r--r--lib/subdir.am14
3 files changed, 22 insertions, 11 deletions
diff --git a/lib/clippy.c b/lib/clippy.c
index 44dcc02eb..cd8067f5e 100644
--- a/lib/clippy.c
+++ b/lib/clippy.c
@@ -85,8 +85,6 @@ int main(int argc, char **argv)
if (PyRun_AnyFile(fp, pyfile)) {
if (PyErr_Occurred())
PyErr_Print();
- else
- printf("unknown python failure (?)\n");
return 1;
}
Py_Finalize();
diff --git a/lib/defun_lex.l b/lib/defun_lex.l
index 6c0805a4f..19b06f51b 100644
--- a/lib/defun_lex.l
+++ b/lib/defun_lex.l
@@ -163,7 +163,7 @@ static int yylex_clr(char **retbuf)
return rv;
}
-static PyObject *get_args(void)
+static PyObject *get_args(const char *filename, int lineno)
{
PyObject *pyObj = PyList_New(0);
PyObject *pyArg = NULL;
@@ -190,6 +190,13 @@ static PyObject *get_args(void)
free(tval);
continue;
}
+ if (token == PREPROC) {
+ free(tval);
+ Py_DECREF(pyObj);
+ return PyErr_Format(PyExc_ValueError,
+ "%s:%d: cannot process CPP directive within argument list",
+ filename, lineno);
+ }
if (token == SPECIAL) {
if (depth == 1 && (tval[0] == ',' || tval[0] == ')')) {
if (pyArg)
@@ -244,7 +251,12 @@ PyObject *clippy_parse(PyObject *self, PyObject *args)
case DEFUNNY:
case INSTALL:
case AUXILIARY:
- pyArgs = get_args();
+ pyArgs = get_args(filename, lineno);
+ if (!pyArgs) {
+ free(tval);
+ Py_DECREF(pyCont);
+ return NULL;
+ }
pyItem = PyDict_New();
PyDict_SetItemString(pyItem, "type", PyUnicode_FromString(tval));
PyDict_SetItemString(pyItem, "args", pyArgs);
@@ -260,6 +272,7 @@ PyObject *clippy_parse(PyObject *self, PyObject *args)
pyItem = PyDict_New();
PyDict_SetItemString(pyItem, "type", PyUnicode_FromString("PREPROC"));
PyDict_SetItemString(pyItem, "line", PyUnicode_FromString(tval));
+ lineno--;
break;
}
if (pyItem) {
diff --git a/lib/subdir.am b/lib/subdir.am
index 4e6adced7..0b859f793 100644
--- a/lib/subdir.am
+++ b/lib/subdir.am
@@ -3,7 +3,7 @@
#
lib_LTLIBRARIES += lib/libfrr.la
lib_libfrr_la_LDFLAGS = -version-info 0:0:0 -Xlinker -e_libfrr_version
-lib_libfrr_la_LIBADD = $(LIBCAP) $(UNWIND_LIBS) $(LIBYANG_LIBS) $(LUA_LIB)
+lib_libfrr_la_LIBADD = $(LIBCAP) $(UNWIND_LIBS) $(LIBYANG_LIBS) $(LUA_LIB) $(LIBM)
lib_libfrr_la_SOURCES = \
lib/agg_table.c \
@@ -340,8 +340,10 @@ noinst_PROGRAMS += \
if BUILD_CLIPPY
noinst_PROGRAMS += lib/clippy
else
-$(HOSTTOOLS)lib/clippy:
- @$(MAKE) -C $(top_builddir)/$(HOSTTOOLS) lib/route_types.h lib/clippy
+if HOSTTOOLS_CLIPPY
+$(CLIPPY):
+ @$(MAKE) -C $(top_builddir)/hosttools lib/route_types.h lib/clippy
+endif
endif
lib_grammar_sandbox_SOURCES = \
@@ -372,13 +374,11 @@ am__v_CLIPPY_ = $(am__v_CLIPPY_$(AM_DEFAULT_VERBOSITY))
am__v_CLIPPY_0 = @echo " CLIPPY " $@;
am__v_CLIPPY_1 =
-CLIPPY_DEPS = $(HOSTTOOLS)lib/clippy $(top_srcdir)/python/clidef.py
+CLIPPY_DEPS = $(CLIPPY) $(top_srcdir)/python/clidef.py
SUFFIXES = _clippy.c .proto .pb-c.c .pb-c.h .pb.h .pb.cc .grpc.pb.cc
.c_clippy.c:
- @{ test -x $(top_builddir)/$(HOSTTOOLS)lib/clippy || \
- $(MAKE) -C $(top_builddir)/$(HOSTTOOLS) lib/clippy; }
- $(AM_V_CLIPPY) $(top_builddir)/$(HOSTTOOLS)lib/clippy $(top_srcdir)/python/clidef.py -o $@ $<
+ $(AM_V_CLIPPY) $(CLIPPY) $(top_srcdir)/python/clidef.py -o $@ $<
## automake's "ylwrap" is a great piece of GNU software... not.
.l.c: