Re: [PATCH 1/6] parse-options: sanity check PARSE_OPT_NOARG flag

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

 



Stephen Boyd <bebarino@xxxxxxxxx> writes:

> On 11/29/10 18:55, Jonathan Nieder wrote:
>> +static void check_flags(const struct option *opt)
>> +{
>> +	switch (opt->type) {
>> +	case OPTION_BOOLEAN:
>> +	case OPTION_BIT:
>> +	case OPTION_NEGBIT:
>> +	case OPTION_SET_INT:
>> +	case OPTION_SET_PTR:
>> +	case OPTION_NUMBER:
>> +		break;
>> +	default:	/* (usually accepts an argument) */
>> +		return;
>> +	}
>> +	if ((opt->flags & (PARSE_OPT_OPTARG | PARSE_OPT_NOARG)) == PARSE_OPT_NOARG)
>> +		return;
>> +	die("BUG: option '-%c%s' should not accept an argument",
>> +				!opt->short_name ? '-' : opt->short_name,
>> +				!opt->short_name ? opt->long_name : "");
>> +}
>> +
>
> This check should probably go into parse_options_check()...

Very good suggestion---that way we can check and get diagnosis for all the
errors, not just dying on the first one.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]