Dag-Erling Smørgrav schrieb am 2009-11-10: > Alexander Best <alexbes...@wwu.de> writes: > > good point. is this one better?
> Yes (modulo indentation - run your code through tabify) > DES oops. found another problem. if BURNCD_SPEED and -s aren't defined strcasecmp segfaults because env_speed is NULL. does this patch take care of the problem? alex ps: would be nice if strcasecmp could protect itself from segfault with one or both of the args being NULL.
Index: usr.sbin/burncd/burncd.8 =================================================================== --- usr.sbin/burncd/burncd.8 (revision 199125) +++ usr.sbin/burncd/burncd.8 (working copy) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 2, 2005 +.Dd Nov 9, 2009 .Os .Dt BURNCD 8 .Sh NAME @@ -158,7 +158,11 @@ .Sh ENVIRONMENT The following environment variables affect the execution of .Nm : -.Bl -tag -width ".Ev CDROM" +.Bl -tag -width ".Ev BURNCD_SPEED" +.It Ev BURNCD_SPEED +The write speed to use if one is not specified with the +.Fl s +flag. .It Ev CDROM The CD device to use if one is not specified with the .Fl f Index: usr.sbin/burncd/burncd.c =================================================================== --- usr.sbin/burncd/burncd.c (revision 199125) +++ usr.sbin/burncd/burncd.c (working copy) @@ -80,11 +80,13 @@ int dao = 0, eject = 0, fixate = 0, list = 0, multi = 0, preemp = 0; int nogap = 0, speed = 4 * 177, test_write = 0, force = 0; int block_size = 0, block_type = 0, cdopen = 0, dvdrw = 0; - const char *dev; + const char *dev, *env_speed; if ((dev = getenv("CDROM")) == NULL) dev = "/dev/acd0"; + env_speed = getenv("BURNCD_SPEED"); + while ((ch = getopt(argc, argv, "def:Flmnpqs:tv")) != -1) { switch (ch) { case 'd': @@ -124,12 +126,7 @@ break; case 's': - if (strcasecmp("max", optarg) == 0) - speed = CDR_MAX_SPEED; - else - speed = atoi(optarg) * 177; - if (speed <= 0) - errx(EX_USAGE, "Invalid speed: %s", optarg); + env_speed = optarg; break; case 't': @@ -147,6 +144,15 @@ argc -= optind; argv += optind; + if (env_speed == NULL) + ; + else 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", optarg); + if (argc == 0) usage();
_______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"