Message ID | 20211130160207.7527-1-mkp@redhat.com |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,v2] checkpatch: Correct line count in error messages | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | fail | github build: failed |
Hello Mike, Mike Pattrick <mkp@redhat.com> writes: > As part of some previous checkpatch work, we discovered that checkpatch > isn't always reporting correct line numbers. As it turns out, Python's > splitlines function considers several characters to be new lines which > common text editors do not typically consider to be new lines. For > example, form feed characters, which this code base uses to cluster > functionality. > > Signed-off-by: Mike Pattrick <mkp@redhat.com> > --- > utilities/checkpatch.py | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > tested it against multiple files, all reporting the correct line number. The patch LGTM, Acked-by: Paolo Valerio <pvalerio@redhat.com> > diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py > index bf95358d5..caf10537b 100755 > --- a/utilities/checkpatch.py > +++ b/utilities/checkpatch.py > @@ -765,12 +765,16 @@ def ovs_checkpatch_parse(text, filename, author=None, committer=None): > > reset_counters() > > - for line in text.splitlines(): > + for line in text.split("\n"): > if current_file != previous_file: > previous_file = current_file > > lineno = lineno + 1 > total_line = total_line + 1 > + > + if line == "\f": > + # Form feed > + continue > if len(line) <= 0: > continue > > -- > 2.27.0 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
On 12/15/21 13:54, Paolo Valerio wrote: > Hello Mike, > > Mike Pattrick <mkp@redhat.com> writes: > >> As part of some previous checkpatch work, we discovered that checkpatch >> isn't always reporting correct line numbers. As it turns out, Python's >> splitlines function considers several characters to be new lines which >> common text editors do not typically consider to be new lines. For >> example, form feed characters, which this code base uses to cluster >> functionality. >> >> Signed-off-by: Mike Pattrick <mkp@redhat.com> >> --- >> utilities/checkpatch.py | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> > > tested it against multiple files, all reporting the correct line number. > The patch LGTM, > > Acked-by: Paolo Valerio <pvalerio@redhat.com> Thanks! Applied. Best regards, Ilya Maximets.
diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py index bf95358d5..caf10537b 100755 --- a/utilities/checkpatch.py +++ b/utilities/checkpatch.py @@ -765,12 +765,16 @@ def ovs_checkpatch_parse(text, filename, author=None, committer=None): reset_counters() - for line in text.splitlines(): + for line in text.split("\n"): if current_file != previous_file: previous_file = current_file lineno = lineno + 1 total_line = total_line + 1 + + if line == "\f": + # Form feed + continue if len(line) <= 0: continue
As part of some previous checkpatch work, we discovered that checkpatch isn't always reporting correct line numbers. As it turns out, Python's splitlines function considers several characters to be new lines which common text editors do not typically consider to be new lines. For example, form feed characters, which this code base uses to cluster functionality. Signed-off-by: Mike Pattrick <mkp@redhat.com> --- utilities/checkpatch.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)