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

Kinsbursky Stanislav skinsbursky at openvz.org
Mon Jan 30 08:36:15 EST 2012


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.


>> +			{
>> +				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:


-- 
Best regards,
Stanislav Kinsbursky




More information about the CRIU mailing list