[ofa-general] Re: [PATCH] osm: handle first syntax error in policy file

Sasha Khapyorsky sashak at voltaire.com
Thu Nov 15 05:44:58 PST 2007


Hi Yevgeny,

On 14:03 Thu 15 Nov     , Yevgeny Kliteynik wrote:
> When parsing QoS policy file for the first time, print
> first syntax error to stdout and to the osm log.
> 
> Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
> ---
>  opensm/opensm/osm_qos_parser.y |   11 ++++++++++-
>  1 files changed, 10 insertions(+), 1 deletions(-)
> 
> diff --git a/opensm/opensm/osm_qos_parser.y b/opensm/opensm/osm_qos_parser.y
> index 4738831..71f41fe 100644
> --- a/opensm/opensm/osm_qos_parser.y
> +++ b/opensm/opensm/osm_qos_parser.y
> @@ -1873,12 +1873,21 @@ int __qos_parser_wrap()
> 
>  void __qos_parser_error (char *s)
>  {
> +    static boolean_t first_time = TRUE;

Could we avoid using static variables? (But seems __qos_parser_error()
function itself should be declared as static).

Sasha


> +    char * last_text_read = __parser_strip_white(__qos_parser_text);
>      OSM_LOG_ENTER(p_qos_parser_osm_log, __qos_parser_error);
>      osm_log(p_qos_parser_osm_log, OSM_LOG_ERROR,
>              "__qos_parser_error: ERR AC05: "
>              "Syntax error (line %d:%d): %s. "
>              "Last text read: \"%s\"\n",
> -            line_num, column_num, s, __parser_strip_white(__qos_parser_text));
> +            line_num, column_num, s, last_text_read);
> +    if (first_time)
> +    {
> +        first_time = FALSE;
> +        printf("Error parsing QoS Policy File (line %d:%d): \"%s\". "
> +               "Last text read: \"%s\".\n",
> +               line_num, column_num, s, last_text_read);
> +    }
>      OSM_LOG_EXIT(p_qos_parser_osm_log);
>  }
> 
> -- 
> 1.5.1.4
> 
> 



More information about the general mailing list