[patch] burncd: honour for envar SPEED

Dag-Erling Smørgrav des at des.no
Mon Nov 9 20:58:23 UTC 2009


Alexander Best <alexbestms at wwu.de> writes:
>  
> +	if ((env_speed = getenv("BURNCD_SPEED")) != NULL) {
> +		if (strcasecmp("max", env_speed) == 0)
> +			speed = CDR_MAX_SPEED;
> +		else
> +			speed = atoi(env_speed) * 177;
> +		if (speed <= 0)
> +			errx(EX_USAGE, "Invalid speed: %s", env_speed);
> +	}
> +
>  	while ((ch = getopt(argc, argv, "def:Flmnpqs:tv")) != -1) {
>  		switch (ch) {
>  		case 'd':

You realize you're duplicating 6 lines of non-trivial code for no good
reason?

env_speed = getenv("BURNCD_SPEED");

while ((ch = getopt(...)) != -1) {
    switch (ch) {
    case 's':
        env_speed = optarg;
        break;
    ...
    }
}

if (env_speed != NULL) {
    if (strcasecmp...) {
        ...
    }
}

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-hackers mailing list