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

Pavel Emelyanov xemul at openvz.org
Mon Jan 30 08:14:11 EST 2012


> @@ -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.

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

>  			break;
>  		case 'h':
>  		default:


More information about the CRIU mailing list