Hello,
On Mon, 17 Jun 2013, Alexander Frolkin wrote:
> /* check the options based on the commands_v_options table */
> static void generic_opt_check(int command, int options);
> @@ -363,7 +366,7 @@ parse_options(int argc, char **argv, struct
> ipvs_command_entry *ce,
> {
> int c, parse;
> poptContext context;
> - char *optarg=NULL;
> + char *optarg=NULL, sched_flags_arg[128];
> struct poptOption options_table[] = {
> { "add-service", 'A', POPT_ARG_NONE, NULL, 'A', NULL, NULL },
> { "edit-service", 'E', POPT_ARG_NONE, NULL, 'E', NULL, NULL },
> @@ -426,9 +429,12 @@ parse_options(int argc, char **argv, struct
> ipvs_command_entry *ce,
> { "ops", 'o', POPT_ARG_NONE, NULL, 'o', NULL, NULL },
> { "pe", '\0', POPT_ARG_STRING, &optarg, TAG_PERSISTENCE_ENGINE,
> NULL, NULL },
> + { "sched-flags", 'b', POPT_ARG_STRING, &optarg, 'b', NULL, NULL
> },
> { NULL, 0, 0, NULL, 0, NULL, NULL }
> };
>
> + sched_flags_arg[0] = '\0';
> +
> context = poptGetContext("ipvsadm", argc, (const char **)argv,
> options_table, 0);
>
> @@ -656,6 +662,10 @@ parse_options(int argc, char **argv, struct
> ipvs_command_entry *ce,
> set_option(options, OPT_PERSISTENCE_ENGINE);
> strncpy(ce->svc.pe_name, optarg, IP_VS_PENAME_MAXLEN);
> break;
> + case 'b':
> + set_option(options, OPT_SCHED_FLAGS);
> + strncpy(sched_flags_arg, optarg,
> sizeof(sched_flags_arg));
Such strncpy calls are not very safe, they should be
strncpy(dest, src, space - 1); dest[space - 1] = 0;
Better to use
snprintf(sched_flags_arg, sizeof(sched_flags_arg), "%s", optarg);
> + break;
> +static unsigned int parse_sched_flags(const char *sched, char *optarg)
> +{
> + unsigned int flags = 0;
> + char *flag;
> + const char *scheduler = (sched && *sched) ? sched : DEF_SCHED;
We can reuse 'sched' here, no need for 'scheduler':
sched = (sched && *sched) ? sched : DEF_SCHED;
Regards
--
Julian Anastasov <ja@xxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
|