tarantool / checkpatch

Checkpatch for Tarantool
GNU General Public License v2.0
2 stars 2 forks source link

False-positive or false-negative `'definition without comment'` #53

Closed Gerold103 closed 1 year ago

Gerold103 commented 1 year ago

I have the following 2 new functions in a patch:

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 0ae283ce6..2febb153c 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -3867,6 +3867,25 @@ on_replace_dd_priv(struct trigger * /* trigger */, void *event)

 /* {{{ cluster configuration */

+static int
+on_commit_replicaset_uuid(struct trigger *trigger, void * /* event */)
+{
+       struct tt_uuid *uuid = (struct tt_uuid *)trigger->data;
+       if (tt_uuid_is_equal(&REPLICASET_UUID, uuid))
+               return 0;
+       REPLICASET_UUID = *uuid;
+       box_broadcast_id();
+       say_info("cluster uuid %s", tt_uuid_str(uuid));
+       return 0;
+}
+
+static int
+on_commit_dd_version(struct trigger *trigger, void * /* event */)
+{
+       dd_version_id = (uint32_t)(uintptr_t)trigger->data;
+       return 0;
+}
+

Checkpatch complains only about the first one:

ERROR: 'on_commit_replicaset_uuid' definition without comment
#29: FILE: src/box/alter.cc:3871:
+on_commit_replicaset_uuid(struct trigger *trigger, void * /* event */)

total: 1 errors, 92 lines checked

If I add a comment to the first function, then all is fine. But the second function remains without a comment. So either the error was false-positive, or on_commit_dd_version() ignorance was false-negative. Or is there some hidden rule like how many lines can a function have without needing a comment?

locker commented 1 year ago

Checkpatch doesn't require comments to short functions. A function is considered short if its body is <= 3 lines, not counting lines like assert(foo); and (void)foo;.

Gerold103 commented 1 year ago

Ok, then the behaviour is understandable.