Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Nov 2009 02:19:05 +0100 (CET)
From:      Alexander Best <alexbestms@math.uni-muenster.de>
To:        Gabor Kovesdan <gabor@FreeBSD.org>
Cc:        freebsd-hackers@FreeBSD.org
Subject:   Re: [patch] burncd: honour for envar SPEED
Message-ID:  <permail-2009110901190580e26a0b0000354f-a_best01@message-id.uni-muenster.de>
In-Reply-To: <4AF76A2C.400@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Gabor Kovesdan schrieb am 2009-11-09:
> Gabor Kovesdan escribió:
> >Alexander Best escribió:
> >>any thoughts on these small changes to burncd?
> >> -    int nogap = 0, speed = 4 * 177, test_write = 0, force = 0;
> >>+    int nogap = 0, speed = 0, test_write = 0, force = 0;
> >>    int block_size = 0, block_type = 0, cdopen = 0, dvdrw = 0;
> >>    const char *dev;
> >>     if ((dev = getenv("CDROM")) == NULL)
> >>        dev = "/dev/acd0";
> >>+    if ((speed = getenv("SPEED")) == NULL)
> >>+        speed = 4 * 177;
> >>+
> >It seems incorrect. The speed variable is of type int, while getenv
> >returns char *. You should first assign getenv("SPEED") to a char *
> >variable and if it isn't NULL then you should convert it to int or
> >fall back to the default value otherwise.
> And one more thing. Personally, I think that a more
> specific/descriptive name would be better, e.g. BURNCD_SPEED. SPEED
> is just too general.

> --
> Gabor Kovesdan
> FreeBSD Volunteer

> EMAIL: gabor@FreeBSD.org .:|:. gabor@kovesdan.org
> WEB:   http://people.FreeBSD.org/~gabor .:|:. http://kovesdan.org

thanks for the help. how about this revised patch?

cheers.
alex

[-- Attachment #2 --]
Index: usr.sbin/burncd/burncd.8
===================================================================
--- usr.sbin/burncd/burncd.8	(revision 199064)
+++ usr.sbin/burncd/burncd.8	(working copy)
@@ -164,6 +164,12 @@
 .Fl f
 flag.
 .El
+.Bl -tag -width ".Ev WRITE_SPEED"
+.It Ev WRITE_SPEED
+The write speed to use if one is not specified with the
+.Fl s
+flag.
+.El
 .Sh FILES
 .Bl -tag -width ".Pa /dev/acd0"
 .It Pa /dev/acd0
Index: usr.sbin/burncd/burncd.c
===================================================================
--- usr.sbin/burncd/burncd.c	(revision 199064)
+++ usr.sbin/burncd/burncd.c	(working copy)
@@ -80,11 +80,20 @@
 	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";
 
+	if ((env_speed = getenv("WRITE_SPEED")) != NULL)
+		if (strcasecmp("max", getenv) == 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':

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?permail-2009110901190580e26a0b0000354f-a_best01>