[ovs-dev] checkpatch: Fix handling of line endings.

Message ID 20190415133654.5744-1-i.maximets@samsung.com
State New
Headers show
Series
  • [ovs-dev] checkpatch: Fix handling of line endings.
Related show

Commit Message

Ilya Maximets April 15, 2019, 1:36 p.m.
Unlike manual splitting, 'splitlines' correctly handles different
line endings. Without this change script fails to check files with
'\r\n' endings treating the whole patch as a header.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 utilities/checkpatch.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff April 15, 2019, 7:35 p.m. | #1
On Mon, Apr 15, 2019 at 04:36:54PM +0300, Ilya Maximets wrote:
> Unlike manual splitting, 'splitlines' correctly handles different
> line endings. Without this change script fails to check files with
> '\r\n' endings treating the whole patch as a header.
> 
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>

Thanks, I applied this to master.

I don't think OVS legitimately has any text files that contain carriage
returns, so it might be worth warning about them.
Ilya Maximets April 16, 2019, 7:31 a.m. | #2
On 15.04.2019 22:35, Ben Pfaff wrote:
> On Mon, Apr 15, 2019 at 04:36:54PM +0300, Ilya Maximets wrote:
>> Unlike manual splitting, 'splitlines' correctly handles different
>> line endings. Without this change script fails to check files with
>> '\r\n' endings treating the whole patch as a header.
>>
>> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> 
> Thanks, I applied this to master.
> 
> I don't think OVS legitimately has any text files that contain carriage
> returns, so it might be worth warning about them.

'git am' by default strips '\r' symbols. OTOH, some mail clients adds them.
There might be a lot of false positives if we'll add this kind of check
to checkpatch.
Ben Pfaff April 16, 2019, 5:17 p.m. | #3
On Tue, Apr 16, 2019 at 10:31:20AM +0300, Ilya Maximets wrote:
> On 15.04.2019 22:35, Ben Pfaff wrote:
> > On Mon, Apr 15, 2019 at 04:36:54PM +0300, Ilya Maximets wrote:
> >> Unlike manual splitting, 'splitlines' correctly handles different
> >> line endings. Without this change script fails to check files with
> >> '\r\n' endings treating the whole patch as a header.
> >>
> >> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> > 
> > Thanks, I applied this to master.
> > 
> > I don't think OVS legitimately has any text files that contain carriage
> > returns, so it might be worth warning about them.
> 
> 'git am' by default strips '\r' symbols. OTOH, some mail clients adds them.
> There might be a lot of false positives if we'll add this kind of check
> to checkpatch.

OK, never mind then.

Patch

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 369911960..441eaa807 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -725,7 +725,7 @@  def ovs_checkpatch_parse(text, filename, author=None, committer=None):
 
     reset_counters()
 
-    for line in text.split('\n'):
+    for line in text.splitlines():
         if current_file != previous_file:
             previous_file = current_file