[CRIU] Re: [PATCH 2/2] namespaces: parametrized namespace option introduced

Pavel Emelyanov xemul at parallels.com
Mon Jan 30 08:37:47 EST 2012


On 01/30/2012 05:36 PM, Kinsbursky Stanislav wrote:
> 30.01.2012 17:14, Pavel Emelyanov пишет:
>>> @@ -288,7 +292,24 @@ int main(int argc, char *argv[])
>>>   			log_inited = 1;
>>>   			break;
>>>   		case 'n':
>>> -			opts.with_namespaces = true;
>>> +			ptr = optarg;
>>> +			while ( sscanf(ptr, "%31[a-z]%n", ns,&n) == 1 )
>> This sscanf is actually excessive, taking into account the fact you do strcmp() below.
>> Remove it and you'll have -2 variables and lighter code.
> 
> Not, this is not. This function was designed exactly for such situations.

Зачем он тут? Почему нельзя сходу делать strcmp(optarg, "uts")?

> 
>>> +			{
>>> +				if (!strcmp(ns, "uts"))
>>> +					opts.namespaces_flags |= CLONE_NEWUTS;
>>> +				else {
>>> +					pr_err("Unknown namespace '%s'\n", ns);
>>> +					return -1;
>>> +				}
>>> +				if (ptr[n] != ',') {
>>> +					if (ptr[n] == '\0')
>>> +						break;
>>> +					pr_err("Unknown symbol '%c' (%d)\n",
>>> +							ptr[n], ptr[n]);
>>> +					return -1;
>>> +				}
>>> +				ptr += n + 1;
>>> +			}
>> Move this to separate function.
>>
> 
> Ok.
> 
>>>   			break;
>>>   		case 'h':
>>>   		default:
> 
> 




More information about the CRIU mailing list