[patch] sndio.7

2012-12-21 Thread Martin Toft
One typo and two style issues:

--- sndio.7.orig2012-12-21 17:55:39.415008759 +0100
+++ sndio.7 2012-12-21 18:01:20.607018154 +0100
@@ -44,7 +44,7 @@
 while doing all necessary conversions on the fly.
 It can mix multiple streams or split the hardware into
 multiple subdevices, to allow programs to use the hardware
-concurently.
+concurrently.
 .Pp
 Hardware MIDI ports correspond to serial connectors provided by the
 .Xr midi 4
@@ -56,7 +56,7 @@
 Software MIDI thru boxes allow one application to send MIDI data to other
 applications connected to the thru box (for instance a software sequencer
 can send events to multiple software synthesizers).
-There's no hardware involved: thru boxes are created by
+There is no hardware involved: thru boxes are created by
 .Xr sndiod 1 .
 .Pp
 Additionally,
@@ -123,7 +123,7 @@
 .Fl fM
 option on the command line.
 .It Pa option
-Corresponds to the sub-device string registered using the
+Corresponds to the subdevice string registered using the
 .Fl s
 option of
 .Xr sndiod 1 .
@@ -140,7 +140,7 @@
 First audio device exposed by
 .Xr sndiod 1 .
 .It Pa snd/0.rear
-Sub-device registered with
+Subdevice registered with
 .Fl s Fa rear .
 .It Pa midithru/0
 First MIDI thru box created with



Re: [patch] sndio.7

2012-12-21 Thread Jason McIntyre
On Fri, Dec 21, 2012 at 06:04:47PM +0100, Martin Toft wrote:
 One typo and two style issues:
 
 --- sndio.7.orig2012-12-21 17:55:39.415008759 +0100
 +++ sndio.7 2012-12-21 18:01:20.607018154 +0100
 @@ -44,7 +44,7 @@
  while doing all necessary conversions on the fly.
  It can mix multiple streams or split the hardware into
  multiple subdevices, to allow programs to use the hardware
 -concurently.
 +concurrently.

right

  .Pp
  Hardware MIDI ports correspond to serial connectors provided by the
  .Xr midi 4
 @@ -56,7 +56,7 @@
  Software MIDI thru boxes allow one application to send MIDI data to other
  applications connected to the thru box (for instance a software sequencer
  can send events to multiple software synthesizers).
 -There's no hardware involved: thru boxes are created by
 +There is no hardware involved: thru boxes are created by

i don;t see why this is an improvement. what's wrong with it?

  .Xr sndiod 1 .
  .Pp
  Additionally,
 @@ -123,7 +123,7 @@
  .Fl fM
  option on the command line.
  .It Pa option
 -Corresponds to the sub-device string registered using the
 +Corresponds to the subdevice string registered using the

well, the aucat/sndiod docs all use sub-device (for better or worse).
so it makes more sense to change the two examples of subdevice.

  .Fl s
  option of
  .Xr sndiod 1 .
 @@ -140,7 +140,7 @@
  First audio device exposed by
  .Xr sndiod 1 .
  .It Pa snd/0.rear
 -Sub-device registered with
 +Subdevice registered with
  .Fl s Fa rear .
  .It Pa midithru/0
  First MIDI thru box created with


i'll make these changes in a bit...

jmc



Re: [patch] sndio.7

2012-12-21 Thread Stuart Henderson
On 2012/12/21 18:31, Jason McIntyre wrote:
  -There's no hardware involved: thru boxes are created by
  +There is no hardware involved: thru boxes are created by
 
 i don;t see why this is an improvement. what's wrong with it?

No hardware is involved might be a slight improvement,
There is no ... looks rather awkward to me.



Re: [patch] sndio.7

2012-12-21 Thread Martin Toft
  -There's no hardware involved: thru boxes are created by
  +There is no hardware involved: thru boxes are created by
 
 i don;t see why this is an improvement. what's wrong with it?

Well, I didn't mean it was wrong or a bug, but the relaxed style seemed
inconsistent with the rest of the page (in *my* eyes).

The mentioned typo was probably the only important part of my patch.

Martin



Re: [patch] sndio.7

2012-12-21 Thread Jason McIntyre
On Fri, Dec 21, 2012 at 06:47:49PM +, Stuart Henderson wrote:
 On 2012/12/21 18:31, Jason McIntyre wrote:
   -There's no hardware involved: thru boxes are created by
   +There is no hardware involved: thru boxes are created by
  
  i don;t see why this is an improvement. what's wrong with it?
 
 No hardware is involved might be a slight improvement,

i'm not sure why. if anything, passive voice is probably harder to
understand than active. it might read better to some people, but why
change it when it's currently correct and clear?

 There is no ... looks rather awkward to me.


i don;t have any problem with that either, i just don;t see any benefit
in making the change.

jmc



[PATCH] pfctl: leak stuff

2012-12-21 Thread Maxime Villard
Hi,
here are my small changes for pfctl.

1) There are cases where we could leak a file descriptor by
   returning.

2) We don't need to check memory before freeing it, as
   free() already does that.

3) Just replaced a snprintf() by strlcpy(), it's faster.

Ok/Comments ?



Index: pfctl.c
===
RCS file: /cvs/src/sbin/pfctl/pfctl.c,v
retrieving revision 1.314
diff -u -r1.314 pfctl.c
--- pfctl.c 19 Sep 2012 15:52:17 -  1.314
+++ pfctl.c 22 Dec 2012 07:08:28 -
@@ -1377,8 +1377,7 @@
err(1, DIOCXROLLBACK);
exit(1);
} else {/* sub ruleset */
-   if (path)
-   free(path);
+   free(path);
return (-1);
}
 
@@ -1867,10 +1866,6 @@
unsigned int len = 0;
size_t n;
 
-   f = fopen(file, w);
-   if (f == NULL)
-   err(1, open: %s, file);
-
memset(ps, 0, sizeof(ps));
for (;;) {
ps.ps_len = len;
@@ -1893,6 +1888,10 @@
return; /* no states */
len *= 2;
}
+
+   f = fopen(file, w);
+   if (f == NULL)
+   err(1, open: %s, file);
 
n = ps.ps_len / sizeof(struct pfsync_state);
if (fwrite(inbuf, sizeof(struct pfsync_state), n, f)  n)
Index: pfctl_osfp.c
===
RCS file: /cvs/src/sbin/pfctl/pfctl_osfp.c,v
retrieving revision 1.18
diff -u -r1.18 pfctl_osfp.c
--- pfctl_osfp.c18 Oct 2010 15:55:28 -  1.18
+++ pfctl_osfp.c22 Dec 2012 07:08:28 -
@@ -112,16 +112,11 @@
 
while ((line = fgetln(in, len)) != NULL) {
lineno++;
-   if (class)
-   free(class);
-   if (version)
-   free(version);
-   if (subtype)
-   free(subtype);
-   if (desc)
-   free(desc);
-   if (tcpopts)
-   free(tcpopts);
+   free(class);
+   free(version);
+   free(subtype);
+   free(desc);
+   free(tcpopts);
class = version = subtype = desc = tcpopts = NULL;
memset(fp, 0, sizeof(fp));
 
@@ -250,16 +245,11 @@
add_fingerprint(dev, opts, fp);
}
 
-   if (class)
-   free(class);
-   if (version)
-   free(version);
-   if (subtype)
-   free(subtype);
-   if (desc)
-   free(desc);
-   if (tcpopts)
-   free(tcpopts);
+   free(class);
+   free(version);
+   free(subtype);
+   free(desc);
+   free(tcpopts);
 
fclose(in);
 
@@ -513,7 +503,7 @@
return (buf);
 
 found:
-   snprintf(buf, len, %s, class_name);
+   strlcpy(buf, class_name, len);
if (version_name) {
strlcat(buf,  , len);
strlcat(buf, version_name, len);
Index: pfctl_radix.c
===
RCS file: /cvs/src/sbin/pfctl/pfctl_radix.c,v
retrieving revision 1.29
diff -u -r1.29 pfctl_radix.c
--- pfctl_radix.c   27 Jul 2011 00:26:10 -  1.29
+++ pfctl_radix.c   22 Dec 2012 07:08:28 -
@@ -499,8 +499,7 @@
 {
if (b == NULL)
return;
-   if (b-pfrb_caddr != NULL)
-   free(b-pfrb_caddr);
+   free(b-pfrb_caddr);
b-pfrb_caddr = NULL;
b-pfrb_size = b-pfrb_msize = 0;
 }