[PATCH] cocci: do not directly access the .d_type member in struct dirent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In "struct dirent", the presence of the .d_type member should not be
assumed and the code should instead use DTYPE() macro, with possibly
a fallback check to determine the type of the file.

Add a rule to catch direct access to the .d_type member and use
DTYPE() macro instead, except in the emulation code paths that work
on platforms that do have the member.  This is probably not sufficient
to notice the lack of necessary fallback code.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 contrib/coccinelle/dtype.cocci | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 contrib/coccinelle/dtype.cocci

diff --git a/contrib/coccinelle/dtype.cocci b/contrib/coccinelle/dtype.cocci
new file mode 100644
index 0000000000..8fe66fce95
--- /dev/null
+++ b/contrib/coccinelle/dtype.cocci
@@ -0,0 +1,8 @@
+@@
+identifier f != { finddata2dirent, precompose_utf8_readdir };
+struct dirent *E;
+@@
+  f(...) {<...
+- E->d_type
++ DTYPE(E)
+  ...>}
-- 
2.50.0-228-g6e205fdad9





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux