Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F2822884
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/devel/coccinelle/string-empty.cocci b/devel/coccinelle/string-empty.cocci
index d51f69ca8a..16e6b1756a 100644
--- a/devel/coccinelle/string-empty.cocci
+++ b/devel/coccinelle/string-empty.cocci
@@ -1,30 +1,45 @@
/*
* Copyright 2020 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU General Public License version 2
* or later (GPLv2+) WITHOUT ANY WARRANTY.
*
* Catch string comparisons where the pcmk__str_empty function could be used
* instead. Note that we are only catching uses involving identifiers (not
* expressions), but I think this is probably fine - we are likely not using
* the same expression multiple times in a single line of code. If some are
* found, it's easy enough to add another block here.
*/
virtual internal
@ string_empty depends on internal @
-identifier I;
+type t;
+identifier func !~ "pcmk__str_empty";
+char* I;
@@
+t func(...) {
+...
(
- (I == NULL) || (strlen(I) == 0)
+ pcmk__str_empty(I)
|
- (I == NULL) || !strlen(I)
+ pcmk__str_empty(I)
|
- (I == NULL) || (I[0] == 0)
+ pcmk__str_empty(I)
+|
+- (I == NULL) || (*I == 0)
++ pcmk__str_empty(I)
+|
+- (I == NULL) || (I[0] == '\0')
++ pcmk__str_empty(I)
+|
+- (I == NULL) || (*I == '\0')
++ pcmk__str_empty(I)
)
+...
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Jan 25, 6:49 AM (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1321562
Default Alt Text
(1 KB)
Attached To
Mode
rP Pacemaker
Attached
Detach File
Event Timeline
Log In to Comment