[Devel] [PATCH 04/10] Dont-Repeat-Yourself: refer variable only once

Kir Kolyshkin kir at openvz.org
Tue May 7 05:03:11 PDT 2013


On 05/06/2013 11:42 PM, Igor Podlesny wrote:
> ---
>   src/vzctl-actions.c |   15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/src/vzctl-actions.c b/src/vzctl-actions.c
> index e0cd261..2f7e162 100644
> --- a/src/vzctl-actions.c
> +++ b/src/vzctl-actions.c
> @@ -1490,13 +1490,14 @@ int run_action(envid_t veid, act_t action, vps_param *g_p, vps_param *vps_p,
>   		g_p->res.dq.enable = NO;
>   	}
>   
> -	if (action != ACTION_EXEC &&
> -		action != ACTION_EXEC2 &&
> -		action != ACTION_EXEC3 &&
> -		action != ACTION_ENTER &&
> -		action != ACTION_CONSOLE &&
> -		action != ACTION_STATUS)
> -	{
> +	switch (action) {
> +	case ACTION_EXEC:	break;
> +	case ACTION_EXEC2:	break;
> +	case ACTION_EXEC3:	break;
> +	case ACTION_ENTER:	break;
> +	case ACTION_CONSOLE:	break;
> +	case ACTION_STATUS:	break;
> +	default:

You don't need multiple breaks here. Please do this:

case ACTION_EXEC:
case ACTION_EXEC2:
....
             break;

>   		if (skiplock != YES) {
>   			lock_id = vps_lock(veid, g_p->opt.lockdir, "");
>   			if (lock_id > 0) {




More information about the Devel mailing list