[systemd-devel] [PATCH 1/5] Factorize some machine-id-setup functions to be reused

Lennart Poettering lennart at poettering.net
Mon Dec 1 09:38:46 PST 2014


On Mon, 24.11.14 12:35, Didier Roche (didrocks at ubuntu.com) wrote:

>  
> +static int get_valid_machine_id(int fd, char id[34]) {
> +        assert(fd >= 0);
> +        assert(id);
> +
> +        if (loop_read(fd, id, 33, false) == 33 && id[32] == '\n') {
> +                id[32] = 0;
> +
> +                if (id128_is_valid(id)) {
> +                        id[32] = '\n';
> +                        id[33] = 0;
> +                        return 0;
> +                }
> +        }
> +
> +        return -EINVAL;
> +}

As a matter of coding style we try hard to avoid functions that clobber
their parameters if they fail. Please follow the same scheme here.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list