Date: Mon, 09 Nov 2009 22:11:25 +0100 (CET) From: Alexander Best <alexbestms@wwu.de> To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= <des@des.no> Cc: freebsd-hackers@FreeBSD.org, Giorgos Keramidas <keramida@freebsd.org> Subject: Re: [patch] burncd: honour for envar SPEED Message-ID: <permail-200911092111251e86ffa80000575d-a_best01@message-id.uni-muenster.de> In-Reply-To: <86aayvfmaa.fsf@ds4.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a MIME encoded multipart message. --+permail-200911092111251e86ffa80000575d-a_best01+ Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Dag-Erling Sm=F8rgrav schrieb am 2009-11-09: > Alexander Best <alexbestms@wwu.de> writes: > > + if ((env_speed =3D getenv("BURNCD_SPEED")) !=3D NULL) { > > + if (strcasecmp("max", env_speed) =3D=3D 0) > > + speed =3D CDR_MAX_SPEED; > > + else > > + speed =3D atoi(env_speed) * 177; > > + if (speed <=3D 0) > > + errx(EX_USAGE, "Invalid speed: %s", > > env_speed); > > + } > > + > > while ((ch =3D getopt(argc, argv, "def:Flmnpqs:tv")) !=3D -1) { > > switch (ch) { > > case 'd': > You realize you're duplicating 6 lines of non-trivial code for no > good > reason? > env_speed =3D getenv("BURNCD_SPEED"); > while ((ch =3D getopt(...)) !=3D -1) { > switch (ch) { > case 's': > env_speed =3D optarg; > break; > ... > } > } > if (env_speed !=3D NULL) { > if (strcasecmp...) { > ... > } > } > DES good point. is this one better? alex --+permail-200911092111251e86ffa80000575d-a_best01+ Content-Type: text/plain Content-Transfer-Encoding: Base64 Content-Disposition: attachment; filename="burncdspeedpatch.txt" SW5kZXg6IHVzci5zYmluL2J1cm5jZC9idXJuY2QuOAo9PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSB1c3Iuc2Jpbi9i dXJuY2QvYnVybmNkLjgJKHJldmlzaW9uIDE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CisJCWVycngoRVhfVVNBR0Us ICJJbnZhbGlkIHNwZWVkOiAlcyIsIG9wdGFyZyk7CisJCQogCWlmIChhcmdjID09IDApCiAJCXVz YWdlKCk7CiAK --+permail-200911092111251e86ffa80000575d-a_best01+--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?permail-200911092111251e86ffa80000575d-a_best01>