[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250715150156.QXAD4dZl@linutronix.de>
Date: Tue, 15 Jul 2025 17:01:56 +0200
From: Nam Cao <namcao@...utronix.de>
To: Gabriele Monaco <gmonaco@...hat.com>
Cc: linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
linux-trace-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Tomas Glozar <tglozar@...hat.com>, Juri Lelli <jlelli@...hat.com>,
Clark Williams <williams@...hat.com>,
John Kacur <jkacur@...hat.com>
Subject: Re: [PATCH v3 09/17] tools/dot2c: Fix generated files going over 100
column limit
On Tue, Jul 15, 2025 at 09:14:26AM +0200, Gabriele Monaco wrote:
> From: Nam Cao <namcao@...utronix.de>
You seem to take a slightly different solution. Feel free to take my name
off the author field, Co-developed-by: or Suggested-by: would be fine. It's
up to you, doesn't really matter to me.
> The dot2c.py script generates all states in a single line. This breaks the
> 100 column limit when the state machines are non-trivial.
>
> Change dot2c.py to generate the states in separate lines in case the
> generated line is going to be too long.
>
> Co-authored-by: Gabriele Monaco <gmonaco@...hat.com>
> Signed-off-by: Nam Cao <namcao@...utronix.de>
> Signed-off-by: Gabriele Monaco <gmonaco@...hat.com>
> ---
> tools/verification/rvgen/rvgen/dot2c.py | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/tools/verification/rvgen/rvgen/dot2c.py b/tools/verification/rvgen/rvgen/dot2c.py
> index 6009caf568d92..5216d98ae21c8 100644
> --- a/tools/verification/rvgen/rvgen/dot2c.py
> +++ b/tools/verification/rvgen/rvgen/dot2c.py
> @@ -152,28 +152,29 @@ class Dot2c(Automata):
> max_state_name = max(self.states, key = len).__len__()
> return max(max_state_name, self.invalid_state_str.__len__())
>
> - def __get_state_string_length(self):
> - maxlen = self.__get_max_strlen_of_states() + self.enum_suffix.__len__()
> - return "%" + str(maxlen) + "s"
> -
> def get_aut_init_function(self):
> nr_states = self.states.__len__()
> nr_events = self.events.__len__()
> buff = []
>
> - strformat = self.__get_state_string_length()
> -
> + maxlen = self.__get_max_strlen_of_states() + len(self.enum_suffix)
> + # account for tabs and spaces/punctuation for each event
> + linetoolong = 16 + (maxlen + 3) * nr_events >= self.line_length
I managed to figure out 16 is the indentation. But I failed to understand
where is this '3' from.
Can you please add some comments for these magic numbers? Or better, assign
them to variables with self-explanatory names.
Best regards,
Nam
Powered by blists - more mailing lists