Skip to contentSkip to conversation

checkpatch: change status of warning from "BRACES" to "BRACES_SINGLE_STMT"

PATCH Christian Babeux 2 participants 3 messages Nov 13, 2013 – Nov 23, 2013 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Raphaël,

Do you have a specific example that is failing for this case of braces detection? I patched checkpatch a while ago in a similar way for braces around single statement blocks, I don't remember the intention behind the particular check you are patching.

Thanks,

Christian

Quoted 25 lines · Raphaël Beamonte

The warning about braces that are not necessary for any arm of a statement should be interpreted as a warning about braces around single statements.

---
 extras/checkpatch.pl |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
extras/checkpatch.pl +1 -2
index fdd8484..5a67704 100755
@@ -3138,7 +3138,7 @@ sub process {
                                                $sum_allowed += $_;
                                        }
                                        if ($sum_allowed == 0) {
-                                               WARN("BRACES",
+                                               WARN("BRACES_SINGLE_STMT",
                                                     "braces {} are not necessary for any arm of this statement\n" . $herectx);
                                        } elsif ($sum_allowed != $allow &&
                                                 $seen != $allow) {
--

1.7.10.4

Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): CAGDH53=vS-+mfjsJo8HFNGYsi+UbYgJDNZqd7bxQAYMpJhPf-w@mail.gmail.com

#3 lore raw

Hello Christian,

You can try to use checkpatch on the patch I sent yesterday about the expand_path unit test. You'll see that it shows a warning for the following lines :

+ if (strcmp(valid_tests_inputs[i].
relative_part, ".") == 0) {
+ relative = cur_path;
+ } else if (strcmp(valid_tests_inputs[i].relative_part,
"..") == 0) {
+ relative = prev_path;
+ } else if (strcmp(valid_tests_inputs[i].relative_part,
"../..") == 0) {
+ relative = pprev_path;
+ } else {
+ relative = empty;
+ }

As I understood from a discussion with Julien, singles braces are recommended for LTTng source code to limit the number of modified lines in case of change. In this very case, the warning that is shown is not the one about "single statement", but the one about "braces [that] are not necessary for any arm of this statement". It seems that the single statement check you patched is only about single ifs. If we use else or else-if, that's not the same check that is used.

Thanks,
Raphaël

2013/11/13 Christian Babeux <[email protected]>:

Quoted 42 lines

Hi Raphaël,

Do you have a specific example that is failing for this case of braces detection? I patched checkpatch a while ago in a similar way for braces around single statement blocks, I don't remember the intention behind the particular check you are patching.

Thanks,

Christian

Quoted 29 lines · Raphaël Beamonte

The warning about braces that are not necessary for any arm of a statement should be interpreted as a warning about braces around single statements.

---
 extras/checkpatch.pl |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
extras/checkpatch.pl +1 -2
index fdd8484..5a67704 100755
@@ -3138,7 +3138,7 @@ sub process {
                                                $sum_allowed += $_;
                                        }
                                        if ($sum_allowed == 0) {
-                                               WARN("BRACES",
+                                               WARN("BRACES_SINGLE_STMT",
                                                     "braces {} are not necessary for any arm of this statement\n" . $herectx);
                                        } elsif ($sum_allowed != $allow &&
                                                 $seen != $allow) {
--

1.7.10.4

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): CAE_Gge0wR7L6_SqP6YkWGiHK-Q3o-w=CR9oN9u86+wrgUxmxwQ@mail.gmail.com

#5 lore raw

Hello,

Do you have some follow-up on this patch ?

Thanks,
Raphaël

2013/11/13 Raphaël Beamonte <[email protected]>:

Quoted 76 lines

Hello Christian,

You can try to use checkpatch on the patch I sent yesterday about the expand_path unit test. You'll see that it shows a warning for the following lines :

+ if (strcmp(valid_tests_inputs[i].
relative_part, ".") == 0) {

(quoted diff) +2 -0
+                       relative = cur_path;
+               } else if (strcmp(valid_tests_inputs[i].relative_part,

"..") == 0) {

(quoted diff) +2 -0
+                       relative = prev_path;
+               } else if (strcmp(valid_tests_inputs[i].relative_part,

"../..") == 0) {

(quoted diff) +4 -0
+                       relative = pprev_path;
+               } else {
+                       relative = empty;
+               }

As I understood from a discussion with Julien, singles braces are recommended for LTTng source code to limit the number of modified lines in case of change. In this very case, the warning that is shown is not the one about "single statement", but the one about "braces [that] are not necessary for any arm of this statement". It seems that the single statement check you patched is only about single ifs. If we use else or else-if, that's not the same check that is used.

Thanks,
Raphaël

2013/11/13 Christian Babeux <[email protected]>:

Quoted 42 lines

Hi Raphaël,

Do you have a specific example that is failing for this case of braces detection? I patched checkpatch a while ago in a similar way for braces around single statement blocks, I don't remember the intention behind the particular check you are patching.

Thanks,

Christian

Quoted 29 lines · Raphaël Beamonte

The warning about braces that are not necessary for any arm of a statement should be interpreted as a warning about braces around single statements.

---
 extras/checkpatch.pl |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
extras/checkpatch.pl +1 -2
index fdd8484..5a67704 100755
@@ -3138,7 +3138,7 @@ sub process {
                                                $sum_allowed += $_;
                                        }
                                        if ($sum_allowed == 0) {
-                                               WARN("BRACES",
+                                               WARN("BRACES_SINGLE_STMT",
                                                     "braces {} are not necessary for any arm of this statement\n" . $herectx);
                                        } elsif ($sum_allowed != $allow &&
                                                 $seen != $allow) {
--

1.7.10.4

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev