* [Cocci] [PATCH 0/2] parsing_cocci: Fix struct pointer funcall regression
@ 2020-05-13 7:29 Jaskaran Singh
2020-05-13 7:29 ` [Cocci] [PATCH 1/2] parsing_cocci: parse_cocci: " Jaskaran Singh
2020-05-13 7:29 ` [Cocci] [PATCH 2/2] tests: Add test case for struct pointer function call Jaskaran Singh
0 siblings, 2 replies; 3+ messages in thread
From: Jaskaran Singh @ 2020-05-13 7:29 UTC (permalink / raw)
To: cocci; +Cc: linux-kernel-mentees
This series 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.
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(+)
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cocci] [PATCH 1/2] parsing_cocci: parse_cocci: Fix struct pointer funcall regression
2020-05-13 7:29 [Cocci] [PATCH 0/2] parsing_cocci: Fix struct pointer funcall regression Jaskaran Singh
@ 2020-05-13 7:29 ` Jaskaran Singh
2020-05-13 7:29 ` [Cocci] [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: 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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Cocci] [PATCH 2/2] tests: Add test case for struct pointer function call
2020-05-13 7:29 [Cocci] [PATCH 0/2] parsing_cocci: Fix struct pointer funcall regression Jaskaran Singh
2020-05-13 7:29 ` [Cocci] [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: 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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-13 7:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13 7:29 [Cocci] [PATCH 0/2] parsing_cocci: Fix struct pointer funcall regression Jaskaran Singh
2020-05-13 7:29 ` [Cocci] [PATCH 1/2] parsing_cocci: parse_cocci: " Jaskaran Singh
2020-05-13 7:29 ` [Cocci] [PATCH 2/2] tests: Add test case for struct pointer function call Jaskaran Singh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).