[systemd-devel] [PATCH] service: add support for Arch daemons

Lennart Poettering lennart at poettering.net
Mon Sep 20 14:19:06 PDT 2010


On Sun, 19.09.10 21:25, Tom Gundersen (teg at jklm.no) wrote:

>  
> +#ifdef TARGET_ARCH
> +	if ((r = parse_env_file("/etc/rc.conf", NEWLINE,
> +				"DAEMONS", &arch_daemons,
> +				NULL)) < 0) {
> +		if (r != -ENOENT)
> +			log_warning("Failed to read /etc/rc.conf: %s", strerror(-r));
> +	}
> +	else if (arch_daemons) {
> +		for (i=0; i < strlen(arch_daemons); i++) { /* strip of end paren */
> +			if (arch_daemons[i] == ')') {
> +				arch_daemons[i] = 0;
> +				break;
> +			}
> +		}

Looks like this could be simplified as:

arch_daemons[strcspn(arch_daemons, ")"] = 0;

> +		for (i=0; i < strlen(arch_daemons); i++) { /* find position of start paren */
> +			if (arch_daemons[i] == '(') {
> +				i++;
> +				break;
> +			}
> +		}

Similarly here:

if (!(p = strchr(arch_deamons, '('))))
        p = arch_daemons;

And then just use p from then on.

Otherwise looks fine!

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list