[ofa-general] Re: [PATCH] osm: handle first syntax error in policy file
Yevgeny Kliteynik
kliteyn at dev.mellanox.co.il
Thu Nov 15 06:46:28 PST 2007
Yevgeny Kliteynik wrote:
> Sasha Khapyorsky wrote:
>> 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?
>
> Would you prefer global flags instead?
> Is there any other way? Nothing comes to mind right now...
I can also remove the flag and have the error message printed
to stderr with every sweep, until the syntax error is fixed.
Sounds better?
-- Yevgeny
>> (But seems __qos_parser_error() function itself should be declared as
>> static).
>
> Sorry, can't do - it's defined by yacc, and
> it's even declared as extern in this file.
>
> -- Yevgeny
>
>> 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
>>>
>>>
>>
>
> _______________________________________________
> general mailing list
> general at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
>
> To unsubscribe, please visit
> http://openib.org/mailman/listinfo/openib-general
>
More information about the general
mailing list