parsing_cocci: Fix struct pointer funcall regression
cover parsing_cocci: Fix struct pointer funcall regression
This series is a fix in response to the following bug report:
https://www.mail-archive.com/[email protected]/msg07332.html
The following commit:
c280375635f62dfbe052709e4e47a82140d32ce5
Introduces a regression in the following SmPL use case:
@@ struct s *x; @@ x->func();
Where x is a pointer to a struct and func is a function belonging to said struct. The faulty commit mislabels func as a function prototype due to a missing case in the function-prototype-detection match ladder.
Enclosed in this patch series is a fix for this and a corresponding test case.
Jaskaran Singh (2):
parsing_cocci: parse_cocci: Fix struct pointer funcall regression
tests: Add test case for struct pointer function call
parsing_cocci/parse_cocci.ml | 1 + tests/structptr_func.c | 5 +++++ tests/structptr_func.cocci | 12 ++++++++++++ tests/structptr_func.res | 6 ++++++ 4 files changed, 24 insertions(+)
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH 1/2 parsing_cocci: parse_cocci: Fix struct pointer funcall regression
This is a fix in response to the following bug report:
https://www.mail-archive.com/[email protected]/msg07332.html
The following commit:
c280375635f62dfbe052709e4e47a82140d32ce5
Introduces a regression in the following SmPL use case:
@@ struct s *x; @@ x->func();
Where x is a pointer to a struct and func is a function belonging to said struct. The faulty commit mislabels func as a function prototype due to a missing case in the function-prototype-detection match ladder.
Add a case in the match ladder for a struct pointer function call.
--- parsing_cocci/parse_cocci.ml | 1 + 1 file changed, 1 insertion(+)
parsing_cocci/parse_cocci.ml +1 -0
@@ -1076,6 +1076,7 @@ let find_function_names l = | (PC.TMetaId(_),_)::_ | (PC.TMetaLocalIdExp(_),_)::_ | (PC.TEq(_),_)::_ + | (PC.TPtrOp(_),_)::_ | (PC.TEllipsis(_),_)::_ | (PC.TOEllipsis(_),_)::_ | (PC.TCEllipsis(_),_)::_
Signature · 6 lines
2.21.1 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
PATCH 2/2 tests: Add test case for struct pointer function call
In reply to Jaskaran SinghThis test case is in response to the following bug report:
https://www.mail-archive.com/[email protected]/msg07332.html
Add a corresponding test case for a struct pointer function call.
--- tests/structptr_func.c | 5 +++++ tests/structptr_func.cocci | 12 ++++++++++++ tests/structptr_func.res | 6 ++++++ 3 files changed, 23 insertions(+) create mode 100644 tests/structptr_func.c create mode 100644 tests/structptr_func.cocci create mode 100644 tests/structptr_func.res
tests/structptr_func.c new file +5 -0
@@ -0,0 +1,5 @@ +void func (struct socket *sock,struct sockaddr *uaddr,int peer) +{ + sock->ops->getname (sock, uaddr, peer); +return ; +}
tests/structptr_func.cocci new file +12 -0
@@ -0,0 +1,12 @@ +@@ +struct socket *sock; +struct sockaddr *uaddr; +int peer; +@@ +{ ++int ___addr_len; +... +- sock->ops->getname(sock, uaddr, peer); ++ sock->ops->getname(sock, uaddr, &___addr_len, peer); +... +}
tests/structptr_func.res new file +6 -0
@@ -0,0 +1,6 @@ +void func(struct socket *sock, struct sockaddr *uaddr, int peer) +{ + int ___addr_len; + sock->ops->getname(sock, uaddr, &___addr_len, peer); + return; +}
Signature · 6 lines
2.21.1 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees