* [Linux-kernel-mentees] [PATCH 1/2] parsing_cocci: parse_cocci: Fix struct pointer funcall regression
2020-05-13 7:29 [Linux-kernel-mentees] [PATCH 0/2] parsing_cocci: Fix struct pointer funcall regression Jaskaran Singh
@ 2020-05-13 7:29 ` Jaskaran Singh
2020-05-13 7:29 ` [Linux-kernel-mentees] [PATCH 2/2] tests: Add test case for struct pointer function call Jaskaran Singh
1 sibling, 0 replies; 3+ messages in thread
From: Jaskaran Singh @ 2020-05-13 7:29 UTC (permalink / raw)
To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees
This is a fix in response to the following bug report:
https://www.mail-archive.com/cocci@systeme.lip6.fr/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.
Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
parsing_cocci/parse_cocci.ml | 1 +
1 file changed, 1 insertion(+)
diff --git a/parsing_cocci/parse_cocci.ml b/parsing_cocci/parse_cocci.ml
index 292ee5c0..798abc27 100644
--- a/parsing_cocci/parse_cocci.ml
+++ b/parsing_cocci/parse_cocci.ml
@@ -1076,6 +1076,7 @@ let find_function_names l =
| (PC.TMetaId(_),_)::_
| (PC.TMetaLocalIdExp(_),_)::_
| (PC.TEq(_),_)::_
+ | (PC.TPtrOp(_),_)::_
| (PC.TEllipsis(_),_)::_
| (PC.TOEllipsis(_),_)::_
| (PC.TCEllipsis(_),_)::_
--
2.21.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Linux-kernel-mentees] [PATCH 2/2] tests: Add test case for struct pointer function call
2020-05-13 7:29 [Linux-kernel-mentees] [PATCH 0/2] parsing_cocci: Fix struct pointer funcall regression Jaskaran Singh
2020-05-13 7:29 ` [Linux-kernel-mentees] [PATCH 1/2] parsing_cocci: parse_cocci: " Jaskaran Singh
@ 2020-05-13 7:29 ` Jaskaran Singh
1 sibling, 0 replies; 3+ messages in thread
From: Jaskaran Singh @ 2020-05-13 7:29 UTC (permalink / raw)
To: cocci; +Cc: julia.lawall, jaskaransingh7654321, linux-kernel-mentees
This test case is in response to the following bug report:
https://www.mail-archive.com/cocci@systeme.lip6.fr/msg07332.html
Add a corresponding test case for a struct pointer function call.
Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
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
diff --git a/tests/structptr_func.c b/tests/structptr_func.c
new file mode 100644
index 00000000..e65dc4ce
--- /dev/null
+++ b/tests/structptr_func.c
@@ -0,0 +1,5 @@
+void func(struct socket *sock, struct sockaddr *uaddr, int peer)
+{
+ sock->ops->getname(sock, uaddr, peer);
+ return;
+}
diff --git a/tests/structptr_func.cocci b/tests/structptr_func.cocci
new file mode 100644
index 00000000..cf725d96
--- /dev/null
+++ b/tests/structptr_func.cocci
@@ -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);
+...
+}
diff --git a/tests/structptr_func.res b/tests/structptr_func.res
new file mode 100644
index 00000000..1b2d437c
--- /dev/null
+++ b/tests/structptr_func.res
@@ -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;
+}
--
2.21.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 3+ messages in thread