Re: [PATCH 09/17] mountpoint: add struct mountpoint_control

Karel Zak
2014-09-12T09:14:23Z

On Sun, Sep 07, 2014 at 01:42:57PM +0100, Sami Kerola wrote:
> This unifies variable names in different functions, and removes redundant
> stat() calls.
>
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
> sys-utils/mountpoint.c | 86 ++++++++++++++++++++++++--------------------------
> 1 file changed, 41 insertions(+), 45 deletions(-)
>
> diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c
> index 3919ab7..3392cdd 100644
> --- a/sys-utils/mountpoint.c
> +++ b/sys-utils/mountpoint.c
> @@ -40,9 +40,17 @@
> #include "closestream.h"
> #include "pathnames.h"
>
> -static int quiet;
> +struct mountpoint_control {
> + char *devname;

This member name makes the code difficult to read, on many places it's
not device at all. Please, use "path" or "spec" rather then "devname".

> + dev_t dev;
> + struct stat st;
> + uint8_t
> + dev_devno:1,
> + fs_devno:1,
> + quiet:1;
> +};

Use "unsigned int" for bit fields, it's compiler business to optimize
how the bits are packed in the struct.

C99, 6.7.2.1 Structure and union specifiers

A bit-field shall have a type that is a qualified or unqualified
version of _Bool, signed int, unsigned int, or some other
implementation-defined type.

Karel

--
Karel Zak <kzak@redhat.com>