Print warning message on deprecated ptp4l options.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2014-03-18 18:25:14 +01:00 committed by Richard Cochran
parent 2b099cfa06
commit 683218aee6
2 changed files with 32 additions and 11 deletions

View File

@ -383,22 +383,19 @@ static enum parser_result parse_global_setting(const char *option,
return r;
*cfg->pi_integral_norm_max = df;
} else if (!strcmp(option, "step_threshold") ||
!strcmp(option, "pi_offset_const")) {
} else if (!strcmp(option, "step_threshold")) {
r = get_ranged_double(value, &df, 0.0, DBL_MAX);
if (r != PARSED_OK)
return r;
*cfg->step_threshold = df;
} else if (!strcmp(option, "first_step_threshold") ||
!strcmp(option, "pi_f_offset_const")) {
} else if (!strcmp(option, "first_step_threshold")) {
r = get_ranged_double(value, &df, 0.0, DBL_MAX);
if (r != PARSED_OK)
return r;
*cfg->first_step_threshold = df;
} else if (!strcmp(option, "max_frequency") ||
!strcmp(option, "pi_max_frequency")) {
} else if (!strcmp(option, "max_frequency")) {
r = get_ranged_int(value, &val, 0, INT_MAX);
if (r != PARSED_OK)
return r;
@ -563,7 +560,9 @@ static enum parser_result parse_global_setting(const char *option,
return PARSED_OK;
}
static enum parser_result parse_setting_line(char *line, char **option, char **value)
static enum parser_result parse_setting_line(char *line,
const char **option,
const char **value)
{
*option = line;
@ -583,12 +582,32 @@ static enum parser_result parse_setting_line(char *line, char **option, char **v
return PARSED_OK;
}
static void check_deprecated_options(const char **option)
{
const char *new_option = NULL;
if (!strcmp(*option, "pi_offset_const")) {
new_option = "step_threshold";
} else if (!strcmp(*option, "pi_f_offset_const")) {
new_option = "first_step_threshold";
} else if (!strcmp(*option, "pi_max_frequency")) {
new_option = "max_frequency";
}
if (new_option) {
fprintf(stderr, "option %s is deprecated, please use %s instead\n",
*option, new_option);
*option = new_option;
}
}
int config_read(char *name, struct config *cfg)
{
enum config_section current_section = UNKNOWN_SECTION;
enum parser_result parser_res;
FILE *fp;
char buf[1024], *line, *c, *option, *value;
char buf[1024], *line, *c;
const char *option, *value;
int current_port = 0, line_num;
fp = 0 == strncmp(name, "-", 2) ? stdin : fopen(name, "r");
@ -642,6 +661,8 @@ int config_read(char *name, struct config *cfg)
goto parse_error;
}
check_deprecated_options(&option);
if (current_section == GLOBAL_SECTION)
parser_res = parse_global_setting(option, value, cfg);
else

View File

@ -347,7 +347,7 @@ The maximum offset the servo will correct by changing the clock
frequency instead of stepping the clock. When set to 0.0, the servo will
never step the clock except on start. It's specified in seconds.
The default is 0.0.
This option used to be called (and can still be set by)
This option used to be called
.BR pi_offset_const .
.TP
.B first_step_threshold
@ -356,7 +356,7 @@ frequency instead of stepping the clock. This is only applied on the first
update. It's specified in seconds. When set to 0.0, the servo won't step
the clock on start.
The default is 0.00002 (20 microseconds).
This option used to be called (and can still be set by)
This option used to be called
.BR pi_f_offset_const .
.TP
.B max_frequency
@ -364,7 +364,7 @@ The maximum allowed frequency adjustment of the clock in parts per billion
(ppb). This is an additional limit to the maximum allowed by the hardware. When
set to 0, the hardware limit will be used.
The default is 900000000 (90%).
This option used to be called (and can still be set by)
This option used to be called
.BR pi_max_frequency .
.TP
.B sanity_freq_limit