Re: [PATCH v2 2/5] Add uclampset schedutil

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 30, 2021 at 08:50:36PM +0000, Qais Yousef wrote:

Now I see that you have reused chrt concept of --pid. We keep it for
chrt due to backward compatibility, but for new util it would be
better to use standard 'required_argument' for --pid.

> +	static const struct option longopts[] = {
> +		{ "all-tasks",		no_argument, NULL, 'a' },
> +		{ "pid",		no_argument, NULL, 'p' },

 { "pid", required_argument, NULL, 'p' },

> +		{ "system",		no_argument, NULL, 's' },
> +		{ "reset-on-fork",	no_argument, NULL, 'R' },
> +		{ "help",		no_argument, NULL, 'h' },
> +		{ "verbose",		no_argument, NULL, 'v' },
> +		{ "version",		no_argument, NULL, 'V' },
> +		{ NULL,			no_argument, NULL, 0 }
> +	};
> +
> +	setlocale(LC_ALL, "");
> +	bindtextdomain(PACKAGE, LOCALEDIR);
> +	textdomain(PACKAGE);
> +	close_stdout_atexit();
> +
> +	while((c = getopt_long(argc, argv, "+asRphmMvV", longopts, NULL)) != -1)

 The same we can do for -m and -M, just normal options where getopt_long() 
 use optarg:

   "+asRp:hm:M:vV"

> +	{
> +		switch (c) {
> +		case 'a':
> +			ctl->all_tasks = 1;
> +			break;
> +		case 'p':
> +			errno = 0;
> +			ctl->pid = strtos32_or_err(argv[optind], _("invalid PID argument"));


 ctl->pid = strtos32_or_err(optarg, _("invalid PID argument")); 

> +			optind++;
> +			break;
> +		case 's':
> +			ctl->system = 1;
> +			break;
> +		case 'R':
> +			ctl->reset_on_fork = 1;
> +			break;
> +		case 'v':
> +			ctl->verbose = 1;
> +			break;
> +		case 'm':
> +			ctl->util_min = strtos32_or_err(argv[optind], _("invalid util_min argument"));

 ctl->util_min = strtos32_or_err(optarg, _("invalid util_min argument"));
 

> +			ctl->util_min_set = 1;
> +			validate_util(ctl->util_min);
> +			optind++;
> +			break;
> +		case 'M':
> +			ctl->util_max = strtos32_or_err(argv[optind], _("invalid util_max argument"));

 ctl->util_max = strtos32_or_err(optarg, _("invalid util_max argument"));

> +			ctl->util_max_set = 1;
> +			validate_util(ctl->util_max);
> +			optind++;
> +			break;
> +		case 'V':
> +			print_version(EXIT_SUCCESS);
> +			/* fallthrough */
> +		case 'h':
> +			usage();
> +		default:
> +			errtryhelp(EXIT_FAILURE);
> +		}
> +	}


 Karel


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux