[PATCH] find: implement -empty

David Demelier markand at malikania.fr
Wed Sep 11 13:22:33 UTC 2019


Le 10/09/2019 à 22:06, Aaro Koskinen a écrit :
> +#if ENABLE_FEATURE_FIND_EMPTY
> +ACTF(empty)
> +{
> +	if (S_ISDIR(statbuf->st_mode)) {
> +		DIR *dir;
> +
> +		dir = opendir(fileName);
> +		if (!dir) {
> +			bb_simple_perror_msg(fileName);
> +			return FALSE;
> +		} else {

You can save an indent level here by removing this else block. Since 
there is a return before, no need for this else.

> +			struct dirent *dent;
> +			char n = 0;
> +
> +			while ((dent = readdir(dir)) != NULL &&
> +			       DOT_OR_DOTDOT(dent->d_name) &&
> +			       n++ < 2)
> +				;
> +			closedir(dir);
> +			return !dent;
> +		}
> +	}
> +	return S_ISREG(statbuf->st_mode) && !statbuf->st_size;
> +}




More information about the busybox mailing list