On 03/09/13 06:30, Sami Kerola wrote:
> An 'if' clause with empty statement is allowed, but unusual construct.
> When 'if' is used this way the statement should at least have orphan
> semicolon ';'.  For empty statements 'switch' feels like a native way
> express what is meant.
> 
> Signed-off-by: Sami Kerola <[email protected]>
> ---
>  src/pacman/util.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/src/pacman/util.c b/src/pacman/util.c
> index 9eb0042..6035963 100644
> --- a/src/pacman/util.c
> +++ b/src/pacman/util.c
> @@ -190,16 +190,13 @@ int rmrf(const char *path)
>       if(!unlink(path)) {
>               return 0;
>       } else {
> -             if(errno == ENOENT) {
> +             switch(errno) {
> +             case ENOENT:
>                       return 0;
> -             } else if(errno == EPERM) {
> -                     /* fallthrough */
> -             } else if(errno == EISDIR) {
> -                     /* fallthrough */
> -             } else if(errno == ENOTDIR) {
> -                     return 1;
> -             } else {
> -                     /* not a directory */
> +             case EPERM:
> +             case EISDIR:
> +                     break;
> +             default:

I'd like to keep the "not a directory" comment here.

>                       return 1;
>               }
>  
> 


Reply via email to