tools: ynl: move the new line in NlMsg __repr__

We add the new line even if message has no error or extack,
which leads to print(nl_msg) ending with two new lines.

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jakub Kicinski 2024-03-04 21:33:07 -08:00 committed by David S. Miller
parent b206acf1ff
commit 7df7231d6a

View file

@ -213,11 +213,11 @@ class NlMsg:
return self.nl_type
def __repr__(self):
msg = f"nl_len = {self.nl_len} ({len(self.raw)}) nl_flags = 0x{self.nl_flags:x} nl_type = {self.nl_type}\n"
msg = f"nl_len = {self.nl_len} ({len(self.raw)}) nl_flags = 0x{self.nl_flags:x} nl_type = {self.nl_type}"
if self.error:
msg += '\terror: ' + str(self.error)
msg += '\n\terror: ' + str(self.error)
if self.extack:
msg += '\textack: ' + repr(self.extack)
msg += '\n\textack: ' + repr(self.extack)
return msg