From a6751fd0f8ebb2b88e089b0b58a64b2d77be9adf Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 3 Jun 2021 11:59:37 -0700 Subject: [PATCH 1/3] Removes clang-format comments from H5O.c call --- src/H5O.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/H5O.c b/src/H5O.c index a1c9c2d6547..3ad14dd341a 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1230,14 +1230,13 @@ H5Oget_info_by_name_async(const char *app_file, const char *app_func, unsigned a hid_t es_id) { H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ - void * token = NULL; /* Request token for async operation */ - void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ + void * token = NULL; /* Request token for async operation */ + void ** token_ptr = H5_REQUEST_NULL; /* Pointer to request token for async operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - /* clang-format off */ - H5TRACE9("e", "*s*sIui*sxIuii", app_file, app_func, app_line, loc_id, name, oinfo, fields, lapl_id, es_id); - /* clang-format on */ + H5TRACE9("e", "*s*sIui*sxIuii", app_file, app_func, app_line, loc_id, name, oinfo, fields, lapl_id, + es_id); /* Set up request token pointer for asynchronous operation */ if (H5ES_NONE != es_id) From a9f947083a47f7add2ffdb0f4834123666c395a0 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 3 Jun 2021 13:07:31 -0700 Subject: [PATCH 2/3] Fixes bin/trace to correctly wrap lines near the clang-format limit --- bin/trace | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/bin/trace b/bin/trace index 162343844f6..60d9ce86f94 100755 --- a/bin/trace +++ b/bin/trace @@ -354,10 +354,33 @@ sub rewrite_func ($$$$$) { $argtrace = "H5ARG_TRACE" . scalar(@arg_str) . "(FUNC, \""; $trace .= join("", @arg_str) . "\""; $argtrace .= join("", @arg_str) . "\""; - my $len = 4 + length $trace; # Add 4, for indenting the line - for (@arg_name) { - # Wrap lines that will be longer than the limit, after ');' is added - if ($len + length >= ($max_trace_macro_line_len - 2)) { + + # Add 4 for indenting the line + my $len = 4 + length($trace); + my $trace_len = length($trace); + + for my $i (0 .. $#arg_name) { + # Handle wrapping + + # Be VERY careful here! clang-format and this script MUST agree + # on which lines get wrapped or there will be churn as each tries + # to undo the other's output. + # + # TWO cases must be handled: + # 1) The argument is that last one and ');' will be appended + # 2) The argument is NOT the last one and ',' will be appended + # + # NB: clang-format does NOT consider terminal newlines when + # counting columns for the ColumnLimit + # + # The extra '2' added after $len includes the ', ' that would be + # added BEFORE the argument. + # + my $adjust = ($i + 1 == scalar(@arg_str)) ? 2 : 1; + my $len_if_added = $len + 2 + length($arg_name[$i]) + $adjust; + + # Wrap lines that will be longer than the limit + if ($len_if_added > $max_trace_macro_line_len) { # Wrap line, with indention $trace .= ",\n "; $len = 13; # Set to 13, for indention @@ -373,9 +396,11 @@ sub rewrite_func ($$$$$) { } # Append argument - $trace .= "$_"; - $argtrace .= ", $_"; - $len += length; # Add length of appended argument name + $trace .= "$arg_name[$i]"; + $argtrace .= ", $arg_name[$i]"; + + # Add length of appended argument name + $len += length($arg_name[$i]); } # Append final ');' for macro From 603befaa5aea853620f0edcc88c275dacc83bbf5 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 3 Jun 2021 13:12:14 -0700 Subject: [PATCH 3/3] Removed unused variable from bin/trace --- bin/trace | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/trace b/bin/trace index 60d9ce86f94..d51b8cb349f 100755 --- a/bin/trace +++ b/bin/trace @@ -357,7 +357,6 @@ sub rewrite_func ($$$$$) { # Add 4 for indenting the line my $len = 4 + length($trace); - my $trace_len = length($trace); for my $i (0 .. $#arg_name) { # Handle wrapping