Aq macro

2015-02-15 Thread Ted Unangst
The .Aq macro quotes a word with surrounding angle brackets. This is used a
few places. Lots of man pages quote email addresses. spamd(8) quotes the
spamd pf table name. compress(3) quotes the zconf.h path.

The mandoc chars.in though says that for unicode, it should output these fancy
mathematical left angle bracket and mathematical right angle bracket
characters. Two problems. First, they look like kind of silly because most
fonts use a different glyph. Two, a decent number of fonts don't include them,
and then things look really silly.

mandoc already special cases Aq in Mt macros to output plain brackets.
Existing usage suggests that's what people want elsewhere as well. pf tables
and include.h headers are not math equations either. (.In is available in
some cases, but it's not a general solution.)


Index: chars.in
===
RCS file: /cvs/src/usr.bin/mandoc/chars.in,v
retrieving revision 1.27
diff -u -p -r1.27 chars.in
--- chars.in16 Dec 2014 19:48:49 -  1.27
+++ chars.in15 Feb 2015 08:49:17 -
@@ -86,8 +86,8 @@ CHAR(lB,[,91)
 CHAR(rB, ],93)
 CHAR(lC, {,123)
 CHAR(rC, },125)
-CHAR(la, ,10216)
-CHAR(ra, ,10217)
+CHAR(la, ,60)
+CHAR(ra, ,62)
 CHAR(bv, |,9130)
 CHAR(braceex,|,9130)
 CHAR(bracketlefttp,  |,9121)



mandoc width clamping

2015-02-15 Thread Ted Unangst
In trying to set man up to use my current terminal width $(($COLUMNS-2)) I
discovered that COLUMNS isn't exported to subshells. mandoc itself seems to go
crazy when run with -O width=-2.

Clamp width and indent settings to sensible values. I wasn't sure how to
handle errors, so they're just ignored for now.


Index: term_ascii.c
===
RCS file: /cvs/src/usr.bin/mandoc/term_ascii.c,v
retrieving revision 1.29
diff -u -p -r1.29 term_ascii.c
--- term_ascii.c31 Dec 2014 16:50:54 -  1.29
+++ term_ascii.c15 Feb 2015 11:48:23 -
@@ -55,6 +55,8 @@ ascii_init(enum termenc enc, const struc
const char  *toks[5];
char*v;
struct termp*p;
+   const char  *errstr;
+   int num;
 
p = mandoc_calloc(1, sizeof(struct termp));
 
@@ -99,10 +101,14 @@ ascii_init(enum termenc enc, const struc
while (outopts  *outopts)
switch (getsubopt(outopts, UNCONST(toks), v)) {
case 0:
-   p-defindent = (size_t)atoi(v);
+   num = strtonum(v, 0, 1000, errstr);
+   if (!errstr)
+   p-defindent = num;
break;
case 1:
-   p-defrmargin = (size_t)atoi(v);
+   num = strtonum(v, 0, 1000, errstr);
+   if (!errstr)
+   p-defrmargin = num;
break;
case 2:
/*



Re: Aq macro

2015-02-15 Thread Ted Unangst
Anthony J. Bentley wrote:
 Ted Unangst writes:
  The mandoc chars.in though says that for unicode, it should output these 
  fanc
  y
  mathematical left angle bracket and mathematical right angle bracket
  characters. Two problems. First, they look like kind of silly because most
  fonts use a different glyph.
 
 Well, if it's a matter of aesthetics, I happen to like it. So we're at
 an impasse!
 
 More importantly, though, it matches groff. I don't think it can (or
 should) change. When this behavior was added to mandoc, several pages
 using Aq to represent HTML tags were fixed. These pages were just
 overlooked.

 Here is a patch that corrects spamd(8). I can look at pages that use it
 for headers later... a quick grep reveals less than 20.

Ah, well, fixed is fixed. :) pf.conf also appears to be a big offender.




Re: Aq macro

2015-02-15 Thread Anthony J. Bentley
Anthony J. Bentley writes:
 Ted Unangst writes:
  spamd(8) quotes the
  spamd pf table name. compress(3) quotes the zconf.h path.
 
 IMO, these are bugs in the manuals. spamd(8) should be using  directly.
 compress(3) should drop the angle quotes and just use Pa. Or wrap Pa in
  if people really think it's needed.

Replying to myself, there's already a simpler and more semantic macro
for include files: In. mdoc(7) only seems to document its usage in
SYNOPSIS, but that could just be unclear wording. It is already widely
used in non-SYNOPSIS situations.

ok?


Index: lib/libarch/i386/i386_get_ldt.2
===
RCS file: /cvs/src/lib/libarch/i386/i386_get_ldt.2,v
retrieving revision 1.16
diff -u -p -u -p -r1.16 i386_get_ldt.2
--- lib/libarch/i386/i386_get_ldt.2 31 May 2007 19:19:27 -  1.16
+++ lib/libarch/i386/i386_get_ldt.2 15 Feb 2015 12:52:50 -
@@ -64,7 +64,7 @@ Each entry in the
 .Fa descs
 array can be either a segment_descriptor or a gate_descriptor,
 as defined in
-.Aq Pa i386/segments.h .
+.In i386/segments.h .
 These structures are defined by the architecture
 as disjoint bit-fields, so care must be taken in constructing them.
 .Pp
Index: lib/libz/compress.3
===
RCS file: /cvs/src/lib/libz/compress.3,v
retrieving revision 1.14
diff -u -p -u -p -r1.14 compress.3
--- lib/libz/compress.3 16 Jul 2013 15:21:11 -  1.14
+++ lib/libz/compress.3 15 Feb 2015 12:52:50 -
@@ -229,7 +229,7 @@ and
 for consistency.
 If the first character differs, the library code actually used is
 not compatible with the
-.Aq Pa zlib.h
+.In zlib.h
 header file used by the application.
 This check is automatically made by
 .Fn deflateInit
@@ -889,7 +889,7 @@ memLevel=1 uses minimum memory but is sl
 memLevel=9 uses maximum memory for optimal speed.
 The default value is 8.
 See
-.Aq Pa zconf.h
+.In zconf.h
 for total memory usage as a function of
 .Fa windowBits
 and
@@ -2588,7 +2588,7 @@ and
 must be able to allocate exactly 65536 bytes,
 but will not be required to allocate more than this if the symbol MAXSEG_64K
 is defined (see
-.Aq Pa zconf.h ) .
+.In zconf.h ) .
 .Pp
 WARNING: On MSDOS, pointers returned by
 .Fa zalloc
@@ -2598,7 +2598,7 @@ The default allocation function provided
 To reduce memory requirements and avoid any allocation of 64K objects,
 at the expense of compression ratio,
 compile the library with -DMAX_WBITS=14 (see
-.Aq Pa zconf.h ) .
+.In zconf.h ) .
 .Pp
 The fields
 .Fa total_in
@@ -2739,7 +2739,7 @@ version and the compiler's view of
 .Re
 .Sh HISTORY
 This manual page is based on an HTML version of
-.Aq Pa zlib.h
+.In zlib.h
 converted by
 .An piaip Aq Mt pi...@csie.ntu.edu.tw
 and was converted to mdoc format by the
Index: sbin/pflogd/pflogd.8
===
RCS file: /cvs/src/sbin/pflogd/pflogd.8,v
retrieving revision 1.46
diff -u -p -u -p -r1.46 pflogd.8
--- sbin/pflogd/pflogd.821 Jan 2014 03:15:45 -  1.46
+++ sbin/pflogd/pflogd.815 Feb 2015 12:52:50 -
@@ -137,7 +137,7 @@ Selects which packets will be dumped, us
 .Xr tcpdump 8 .
 Tcpdump has been extended to be able to filter on the pfloghdr
 structure defined in
-.Aq Ar net/if_pflog.h .
+.In net/if_pflog.h .
 It can restrict the output
 to packets logged on a specified interface, a rule number, a reason,
 a direction, an IP family or an action.
Index: share/man/man4/speaker.4
===
RCS file: /cvs/src/share/man/man4/speaker.4,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 speaker.4
--- share/man/man4/speaker.416 Jul 2013 16:05:49 -  1.7
+++ share/man/man4/speaker.415 Feb 2015 12:52:50 -
@@ -72,7 +72,7 @@ on a speaker file descriptor to control 
 definitions for the
 .Fn ioctl
 interface are in
-.Aq Pa dev/isa/spkrio.h .
+.In dev/isa/spkrio.h .
 The
 .Li tone_t
 structure used in these calls has two fields,
Index: share/man/man4/usb.4
===
RCS file: /cvs/src/share/man/man4/usb.4,v
retrieving revision 1.162
diff -u -p -u -p -r1.162 usb.4
--- share/man/man4/usb.46 Feb 2015 23:46:30 -   1.162
+++ share/man/man4/usb.415 Feb 2015 12:52:50 -
@@ -651,7 +651,7 @@ field contains the actual length transfe
 .El
 .Pp
 The include file
-.Aq Pa dev/usb/usb.h
+.In dev/usb/usb.h
 contains definitions for the types used by the various
 .Xr ioctl 2
 calls.
@@ -672,7 +672,7 @@ and
 macros to handle byte order and alignment properly.
 .Pp
 The include file
-.Aq Pa dev/usb/usbhid.h
+.In dev/usb/usbhid.h
 similarly contains the definitions for
 Human Interface Devices
 .Pq Tn HID .
Index: share/man/man4/wsdisplay.4
===
RCS file: /cvs/src/share/man/man4/wsdisplay.4,v
retrieving revision 1.46
diff -u -p -u -p 

Re: PATCH: ntpctl.8, ntpd.c

2015-02-15 Thread Mike.


On 2/15/2015 at 2:51 AM j...@wxcvbn.org wrote:

|Jason McIntyre j...@kerhand.co.uk writes:
|
| On Fri, Feb 13, 2015 at 09:49:58PM -0600, Adam Thompson wrote:
| Fix a minor typo in the ntpctl help output, and same semantic
mistake
|in the
| manpage.  Currently says (to be pedantic) that '-s' only works
with
|'all',
| which is not the case: '-s' is required with all options.
| Apologies if I've got the patch format wrong, I don't do this
often...
| -Adam
| 
| 
| --- ntpd.c_r1.92Fri Feb 13 21:43:39 2015
| +++ ntpd.c  Fri Feb 13 21:43:49 2015
| @@ -90,7 +90,7 @@
| 
| if (strcmp(__progname, ntpctl) == 0)
| fprintf(stderr,
| -   usage: ntpctl [-s all | peers | Sensors |
|status]\n);
| +   usage: ntpctl -s [all | peers | Sensors |
|status]\n);
| else
| fprintf(stderr, usage: %s [-dnSsv] [-f file]\n,
| __progname);
| 
| 
| --- ntpctl.8_r1.7   Fri Feb 13 21:39:53 2015
| +++ ntpctl.8Fri Feb 13 21:40:32 2015
| @@ -22,7 +22,8 @@
|  .Nd control the Network Time Protocol daemon
|  .Sh SYNOPSIS
|  .Nm ntpctl
| -.Op Fl s Cm all | peers | Sensors | status
| +.Fl s
| +.Op Cm all | peers | Sensors | status
|  .Sh DESCRIPTION
|  The
|  .Nm
| 
|
| i didn;t realise that -s was mandatory. pretty yucky that we have
a
| utility with only one option, and it's not optional ;(
|
|Maybe ntpctl will provide more options/features one day, who knows?
:)
 =

That was my thought




Re: Aq macro

2015-02-15 Thread Ingo Schwarze
Hi Christian,

Christian Weisgerber wrote on Sun, Feb 15, 2015 at 04:04:57PM +:
 On 2015-02-15, Ted Unangst t...@tedunangst.com wrote:

 mandoc already special cases Aq in Mt macros to output plain brackets.
 Existing usage suggests that's what people want elsewhere as well.

I'm not sure i can absolutely exclude that, but i don't remember
having seen convincing use of .Aq without .Mt that needs ASCII 
either.  So for now, let's just fix the bad .Aq usage that was found.
If good usage needing ASCII  is found, we can reconsider.

 pf tables and include.h headers are not math equations either.

 I think these manuals should use actual   instead of the Aq macro.

pf.conf(5) should use plain  for tables.  include.h should
always use .In.

 There are related problems in some man pages like pf.conf(5) where
 = is turned into a fancy mathematical sign etc.  I wanted to clean
 up some of those, but wasn't sure what the correct fix was, failed
 to get a straight answer out of schwarze@ and jmc@, and then sort
 of forgot...

Oops, sorry, that mail fell through the cracks, you just got a
late answer.  It boils down to never use \*(Lt \*(Le \*(Gt \*(Ge.
Usually, you don't need any \* whatsoever.

Yours,
  Ingo



Re: Aq macro

2015-02-15 Thread Ingo Schwarze
Hi Anthony,

Anthony J. Bentley wrote on Sun, Feb 15, 2015 at 03:19:48AM -0700:

 More importantly, though, it matches groff.

Yes.  We shouldn't change mandoc(1) without changing groff(1)
in parallel.

 Here is a patch that corrects spamd(8). I can look at pages that
 use it for headers later... a quick grep reveals less than 20.

OK schwarze@ for the patch below.
  Ingo


 Index: libexec/spamd/spamd.8
 ===
 RCS file: /cvs/src/libexec/spamd/spamd.8,v
 retrieving revision 1.125
 diff -u -p -u -p -r1.125 spamd.8
 --- libexec/spamd/spamd.8 7 Feb 2015 18:05:57 -   1.125
 +++ libexec/spamd/spamd.8 15 Feb 2015 10:17:38 -
 @@ -268,11 +268,11 @@ regularly scans the
  .Pa /var/db/spamd
  database and configures all whitelist addresses as the
  .Xr pf 4
 -.Aq spamd-white
 +spamd-white
  table,
  allowing connections to pass to the real MTA.
  Any addresses not found in
 -.Aq spamd-white
 +spamd-white
  are redirected to
  .Nm .
  .Pp
 @@ -385,7 +385,7 @@ spamtrap address,
  it is blacklisted for 24 hours by adding the host to the
  .Nm
  blacklist
 -.Aq spamd-greytrap .
 +spamd-greytrap.
  Spamtrap addresses are added to the
  .Pa /var/db/spamd
  database with the following
 @@ -468,7 +468,7 @@ a slightly modified
  .Xr pf.conf 5
  ruleset is required,
  redirecting any addresses found in the
 -.Aq spamd
 +spamd
  table to
  .Nm .
  Any other addresses
 @@ -488,7 +488,7 @@ like:
  .Pp
  .Xr spamd-setup 8
  can also be used to load addresses into the
 -.Aq spamd
 +spamd
  table.
  It has the added benefit of being able to remove addresses from
  blacklists, and will connect to



Re: Aq macro

2015-02-15 Thread Christian Weisgerber
On 2015-02-15, Ted Unangst t...@tedunangst.com wrote:

 mandoc already special cases Aq in Mt macros to output plain brackets.
 Existing usage suggests that's what people want elsewhere as well. pf tables
 and include.h headers are not math equations either.

I think these manuals should use actual   instead of the Aq macro.

There are related problems in some man pages like pf.conf(5) where
= is turned into a fancy mathematical sign etc.  I wanted to clean
up some of those, but wasn't sure what the correct fix was, failed
to get a straight answer out of schwarze@ and jmc@, and then sort
of forgot...

-- 
Christian naddy Weisgerber  na...@mips.inka.de



Re: Aq macro

2015-02-15 Thread Ingo Schwarze
Hi Anthony,

Anthony J. Bentley wrote on Sun, Feb 15, 2015 at 06:16:11AM -0700:
 Anthony J. Bentley writes:
 Ted Unangst writes:

 spamd(8) quotes the spamd pf table name.

That's in normal text, so it doesn't really matter, nobody is going
to copy and paste a single word out of the middle of the text.
But i don't to just writing the spamd-white table either.

 compress(3) quotes the zconf.h path.

 IMO, these are bugs in the manuals. spamd(8) should be using  directly.
 compress(3) should drop the angle quotes and just use Pa. Or wrap Pa in
  if people really think it's needed.

 Replying to myself, there's already a simpler and more semantic macro
 for include files: In. mdoc(7) only seems to document its usage in
 SYNOPSIS, but that could just be unclear wording.

I just committed a patch to mdoc.7 to avoid that misconception.

 It is already widely used in non-SYNOPSIS situations.

Indeed, .In is fine everywhere.

 ok?

OK schwarze@ on the patch below.

Yours,
  Ingo


 Index: lib/libarch/i386/i386_get_ldt.2
 ===
 RCS file: /cvs/src/lib/libarch/i386/i386_get_ldt.2,v
 retrieving revision 1.16
 diff -u -p -u -p -r1.16 i386_get_ldt.2
 --- lib/libarch/i386/i386_get_ldt.2   31 May 2007 19:19:27 -  1.16
 +++ lib/libarch/i386/i386_get_ldt.2   15 Feb 2015 12:52:50 -
 @@ -64,7 +64,7 @@ Each entry in the
  .Fa descs
  array can be either a segment_descriptor or a gate_descriptor,
  as defined in
 -.Aq Pa i386/segments.h .
 +.In i386/segments.h .
  These structures are defined by the architecture
  as disjoint bit-fields, so care must be taken in constructing them.
  .Pp
 Index: lib/libz/compress.3
 ===
 RCS file: /cvs/src/lib/libz/compress.3,v
 retrieving revision 1.14
 diff -u -p -u -p -r1.14 compress.3
 --- lib/libz/compress.3   16 Jul 2013 15:21:11 -  1.14
 +++ lib/libz/compress.3   15 Feb 2015 12:52:50 -
 @@ -229,7 +229,7 @@ and
  for consistency.
  If the first character differs, the library code actually used is
  not compatible with the
 -.Aq Pa zlib.h
 +.In zlib.h
  header file used by the application.
  This check is automatically made by
  .Fn deflateInit
 @@ -889,7 +889,7 @@ memLevel=1 uses minimum memory but is sl
  memLevel=9 uses maximum memory for optimal speed.
  The default value is 8.
  See
 -.Aq Pa zconf.h
 +.In zconf.h
  for total memory usage as a function of
  .Fa windowBits
  and
 @@ -2588,7 +2588,7 @@ and
  must be able to allocate exactly 65536 bytes,
  but will not be required to allocate more than this if the symbol MAXSEG_64K
  is defined (see
 -.Aq Pa zconf.h ) .
 +.In zconf.h ) .
  .Pp
  WARNING: On MSDOS, pointers returned by
  .Fa zalloc
 @@ -2598,7 +2598,7 @@ The default allocation function provided
  To reduce memory requirements and avoid any allocation of 64K objects,
  at the expense of compression ratio,
  compile the library with -DMAX_WBITS=14 (see
 -.Aq Pa zconf.h ) .
 +.In zconf.h ) .
  .Pp
  The fields
  .Fa total_in
 @@ -2739,7 +2739,7 @@ version and the compiler's view of
  .Re
  .Sh HISTORY
  This manual page is based on an HTML version of
 -.Aq Pa zlib.h
 +.In zlib.h
  converted by
  .An piaip Aq Mt pi...@csie.ntu.edu.tw
  and was converted to mdoc format by the
 Index: sbin/pflogd/pflogd.8
 ===
 RCS file: /cvs/src/sbin/pflogd/pflogd.8,v
 retrieving revision 1.46
 diff -u -p -u -p -r1.46 pflogd.8
 --- sbin/pflogd/pflogd.8  21 Jan 2014 03:15:45 -  1.46
 +++ sbin/pflogd/pflogd.8  15 Feb 2015 12:52:50 -
 @@ -137,7 +137,7 @@ Selects which packets will be dumped, us
  .Xr tcpdump 8 .
  Tcpdump has been extended to be able to filter on the pfloghdr
  structure defined in
 -.Aq Ar net/if_pflog.h .
 +.In net/if_pflog.h .
  It can restrict the output
  to packets logged on a specified interface, a rule number, a reason,
  a direction, an IP family or an action.
 Index: share/man/man4/speaker.4
 ===
 RCS file: /cvs/src/share/man/man4/speaker.4,v
 retrieving revision 1.7
 diff -u -p -u -p -r1.7 speaker.4
 --- share/man/man4/speaker.4  16 Jul 2013 16:05:49 -  1.7
 +++ share/man/man4/speaker.4  15 Feb 2015 12:52:50 -
 @@ -72,7 +72,7 @@ on a speaker file descriptor to control 
  definitions for the
  .Fn ioctl
  interface are in
 -.Aq Pa dev/isa/spkrio.h .
 +.In dev/isa/spkrio.h .
  The
  .Li tone_t
  structure used in these calls has two fields,
 Index: share/man/man4/usb.4
 ===
 RCS file: /cvs/src/share/man/man4/usb.4,v
 retrieving revision 1.162
 diff -u -p -u -p -r1.162 usb.4
 --- share/man/man4/usb.4  6 Feb 2015 23:46:30 -   1.162
 +++ share/man/man4/usb.4  15 Feb 2015 12:52:50 -
 @@ -651,7 +651,7 @@ field contains the actual length transfe
  .El
  .Pp
  The include file
 -.Aq 

opencvs: add commitid to status

2015-02-15 Thread Joris Vink
Hi.

Diff below adds support to opencvs to display commitid for status
commands.

.joris

Index: status.c
===
RCS file: /cvs/src/usr.bin/cvs/status.c,v
retrieving revision 1.94
diff -u -p -r1.94 status.c
--- status.c16 Jan 2015 06:40:07 -  1.94
+++ status.c15 Feb 2015 19:14:28 -
@@ -121,6 +121,7 @@ cvs_status_local(struct cvs_file *cf)
size_t len;
RCSNUM *head;
const char *status;
+   struct rcs_delta *rdp;
char buf[PATH_MAX + CVS_REV_BUFSZ + 128];
char timebuf[CVS_TIME_BUFSZ], revbuf[CVS_REV_BUFSZ];
struct rcs_sym *sym;
@@ -211,6 +211,16 @@ cvs_status_local(struct cvs_file *cf)
}
 
cvs_printf(   Repository revision:\t%s\n, buf);
+
+   if (cf-file_rcs != NULL  head != NULL) {
+   rdp = rcs_findrev(cf-file_rcs, head);
+   if (rdp == NULL) {
+   fatal(cvs_status_local: No head revision delta);
+   }
+
+   cvs_printf(   Commit Identifier:\t%s\n,
+   (rdp-rd_commitid != NULL) ? rdp-rd_commitid : (none));
+   }
 
if (cf-file_ent != NULL) {
if (cf-file_ent-ce_tag != NULL)



Re: opencvs: show correct time in status

2015-02-15 Thread Joris Vink
Hi.

Updated diff below.

.joris

Index: entries.c
===
RCS file: /cvs/src/usr.bin/cvs/entries.c,v
retrieving revision 1.103
diff -u -p -r1.103 entries.c
--- entries.c   16 Jan 2015 06:40:07 -  1.103
+++ entries.c   15 Feb 2015 19:03:11 -
@@ -151,6 +151,7 @@ cvs_ent_parse(const char *entry)
ent-ce_rev = NULL;
ent-ce_date = -1;
ent-ce_tag = NULL;
+   ent-ce_time = NULL;
 
if (ent-ce_type == CVS_ENT_FILE) {
if (*fields[2] == '-') {
@@ -187,6 +188,8 @@ cvs_ent_parse(const char *entry)
if (strncmp(fields[3], Result of merge+, 16) == 0)
p += 16;
 
+   ent-ce_time = xstrdup(p);
+
/* Date field can be a '+=' with remote to indicate
 * conflict.  In this case do nothing. */
if (strptime(p, %a %b %d %T %Y, t) != NULL) {
@@ -383,6 +386,9 @@ cvs_ent_free(struct cvs_ent *ent)
 {
if (ent-ce_rev != NULL)
rcsnum_free(ent-ce_rev);
+   if (ent-ce_time != NULL)
+   xfree(ent-ce_time);
+
xfree(ent-ce_buf);
xfree(ent);
 }
Index: status.c
===
RCS file: /cvs/src/usr.bin/cvs/status.c,v
retrieving revision 1.94
diff -u -p -r1.94 status.c
--- status.c16 Jan 2015 06:40:07 -  1.94
+++ status.c15 Feb 2015 19:03:11 -
@@ -176,9 +177,8 @@ cvs_status_local(struct cvs_file *cf)
rcsnum_tostr(cf-file_ent-ce_rev, revbuf, sizeof(revbuf));
 
if (cf-file_ent-ce_conflict == NULL) {
-   ctime_r((cf-file_ent-ce_mtime), timebuf);
-   if (timebuf[strlen(timebuf) - 1] == '\n')
-   timebuf[strlen(timebuf) - 1] = '\0';
+   (void)strlcpy(timebuf, cf-file_ent-ce_time,
+   sizeof(timebuf));
} else {
len = strlcpy(timebuf, cf-file_ent-ce_conflict,
sizeof(timebuf));
Index: cvs.h
===
RCS file: /cvs/src/usr.bin/cvs/cvs.h,v
retrieving revision 1.181
diff -u -p -r1.181 cvs.h
--- cvs.h   20 Sep 2011 12:43:45 -  1.181
+++ cvs.h   15 Feb 2015 19:03:11 -
@@ -249,6 +249,7 @@ struct cvs_ent {
char*ce_name;
char*ce_opts;
char*ce_tag;
+   char*ce_time;
time_t   ce_date;
time_t   ce_mtime;
u_int16_tce_type;



Re: Aq macro

2015-02-15 Thread Anthony J. Bentley
Ted Unangst writes:
 spamd(8) quotes the
 spamd pf table name. compress(3) quotes the zconf.h path.

IMO, these are bugs in the manuals. spamd(8) should be using  directly.
compress(3) should drop the angle quotes and just use Pa. Or wrap Pa in
 if people really think it's needed.

 The mandoc chars.in though says that for unicode, it should output these fanc
 y
 mathematical left angle bracket and mathematical right angle bracket
 characters. Two problems. First, they look like kind of silly because most
 fonts use a different glyph.

Well, if it's a matter of aesthetics, I happen to like it. So we're at
an impasse!

More importantly, though, it matches groff. I don't think it can (or
should) change. When this behavior was added to mandoc, several pages
using Aq to represent HTML tags were fixed. These pages were just
overlooked.

 Two, a decent number of fonts don't include them,
 and then things look really silly.

But to get to that point you have to:

- use a UTF-8 locale (not the default);
- change the xterm fonts (all the default fonts display these characters)
- ...to something that doesn't support that character (lots of fonts do,
  what makes yours so special?)

 mandoc already special cases Aq in Mt macros to output plain brackets.

This also matches groff.

Here is a patch that corrects spamd(8). I can look at pages that use it
for headers later... a quick grep reveals less than 20.

Index: libexec/spamd/spamd.8
===
RCS file: /cvs/src/libexec/spamd/spamd.8,v
retrieving revision 1.125
diff -u -p -u -p -r1.125 spamd.8
--- libexec/spamd/spamd.8   7 Feb 2015 18:05:57 -   1.125
+++ libexec/spamd/spamd.8   15 Feb 2015 10:17:38 -
@@ -268,11 +268,11 @@ regularly scans the
 .Pa /var/db/spamd
 database and configures all whitelist addresses as the
 .Xr pf 4
-.Aq spamd-white
+spamd-white
 table,
 allowing connections to pass to the real MTA.
 Any addresses not found in
-.Aq spamd-white
+spamd-white
 are redirected to
 .Nm .
 .Pp
@@ -385,7 +385,7 @@ spamtrap address,
 it is blacklisted for 24 hours by adding the host to the
 .Nm
 blacklist
-.Aq spamd-greytrap .
+spamd-greytrap.
 Spamtrap addresses are added to the
 .Pa /var/db/spamd
 database with the following
@@ -468,7 +468,7 @@ a slightly modified
 .Xr pf.conf 5
 ruleset is required,
 redirecting any addresses found in the
-.Aq spamd
+spamd
 table to
 .Nm .
 Any other addresses
@@ -488,7 +488,7 @@ like:
 .Pp
 .Xr spamd-setup 8
 can also be used to load addresses into the
-.Aq spamd
+spamd
 table.
 It has the added benefit of being able to remove addresses from
 blacklists, and will connect to



Re: Brainy: Kernel Memory Leak in sdmmc

2015-02-15 Thread Doug Hogan
On Sun, Feb 15, 2015 at 08:53:08PM +, Miod Vallat wrote:
 This ought to fix this problem:

This looks reasonable but needs a tweak if you want to keep the existing
behavior.  In the existing code, it has this section above the copyout():

rw_enter_write(sc-sc_lock);
if (request == SDIOCEXECMMC)
error = sdmmc_mmc_command(sc, cmd);
else
error = sdmmc_app_command(sc, cmd);
rw_exit(sc-sc_lock);
if (error  !cmd.c_error)
cmd.c_error = error;

and returns 0 even if error is non-zero.  With this diff, it will either
return the result of those functions or the result of copyout depending
on whether ucmd-c_data is non-zero.  Using the result of copyout is
intentional, but not the result from sdmmc_{mmc,app}_command().

Could you set error=0 after the above chunk or use a new variable?
Also, one of the new lines has space indents rather than a tab.

 Index: sdmmc.c
 ===
 RCS file: /cvs/src/sys/dev/sdmmc/sdmmc.c,v
 retrieving revision 1.36
 diff -u -p -r1.36 sdmmc.c
 --- sdmmc.c   1 Nov 2014 16:32:06 -   1.36
 +++ sdmmc.c   15 Feb 2015 20:52:08 -
 @@ -749,7 +749,7 @@ sdmmc_ioctl(struct device *self, u_long 
   struct sdmmc_command *ucmd;
   struct sdmmc_command cmd;
   void *data;
 - int error;
 + int error = 0;
  
   switch (request) {
  #ifdef SDMMC_DEBUG
 @@ -784,8 +784,9 @@ sdmmc_ioctl(struct device *self, u_long 
   M_WAITOK | M_CANFAIL);
   if (data == NULL)
   return ENOMEM;
 - if (copyin(ucmd-c_data, data, ucmd-c_datalen))
 - return EFAULT;
 + error = copyin(ucmd-c_data, data, ucmd-c_datalen);
 + if (error != 0)
 + goto exec_done;
  
   cmd.c_data = data;
   cmd.c_datalen = ucmd-c_datalen;
 @@ -804,10 +805,10 @@ sdmmc_ioctl(struct device *self, u_long 
   ucmd-c_flags = cmd.c_flags;
   ucmd-c_error = cmd.c_error;
  
 - if (ucmd-c_data  copyout(data, ucmd-c_data,
 - ucmd-c_datalen))
 - return EFAULT;
 + if (ucmd-c_data)
 +error = copyout(data, ucmd-c_data, ucmd-c_datalen);
  
 +exec_done:
   if (ucmd-c_data)
   free(data, M_TEMP, 0);
   break;
 @@ -815,7 +816,7 @@ sdmmc_ioctl(struct device *self, u_long 
   default:
   return ENOTTY;
   }
 - return 0;
 + return error;
  }
  #endif
  
 



Brainy: Kernel Memory Leak in sdmmc

2015-02-15 Thread Maxime Villard
Hi,
I put here a bug among others:

-- dev/sdmmc/sdmmc.c --

783 data = malloc(ucmd-c_datalen, M_TEMP,
M_WAITOK | M_CANFAIL);
if (data == NULL)
return ENOMEM;
if (copyin(ucmd-c_data, data, ucmd-c_datalen))
return EFAULT;

---

'data' is leaked.

Found by The Brainy Code Scanner.

Maxime



Re: syslogd SSL3_WRITE_PENDING:bad write retry

2015-02-15 Thread Alexander Bluhm
On Fri, Feb 13, 2015 at 02:44:18PM -0500, Ted Unangst wrote:
 I think this is ok, but it needs some basic load testing with httpd (and ftp)
 as well.

I have tested ftp https by downloading ports distfiles.
I have done basic testing with httpd.

Could someone test this diff who has a busy httpd server using
https?

bluhm

  Index: lib/libtls/tls.c
  ===
  RCS file: /data/mirror/openbsd/cvs/src/lib/libtls/tls.c,v
  retrieving revision 1.7
  diff -u -p -r1.7 tls.c
  --- lib/libtls/tls.c7 Feb 2015 09:50:09 -   1.7
  +++ lib/libtls/tls.c13 Feb 2015 18:33:31 -
  @@ -183,6 +183,9 @@ err:
   int
   tls_configure_ssl(struct tls *ctx)
   {
  +   SSL_CTX_set_mode(ctx-ssl_ctx, SSL_MODE_ENABLE_PARTIAL_WRITE);
  +   SSL_CTX_set_mode(ctx-ssl_ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
  +
  SSL_CTX_set_options(ctx-ssl_ctx, SSL_OP_NO_SSLv2);
  SSL_CTX_set_options(ctx-ssl_ctx, SSL_OP_NO_SSLv3);
   



Re: Brainy: Kernel Memory Leak in sdmmc

2015-02-15 Thread Miod Vallat
 Hi,
 I put here a bug among others:
 
 -- dev/sdmmc/sdmmc.c --
 
 783   data = malloc(ucmd-c_datalen, M_TEMP,
   M_WAITOK | M_CANFAIL);
   if (data == NULL)
   return ENOMEM;
   if (copyin(ucmd-c_data, data, ucmd-c_datalen))
   return EFAULT;
 
 ---
 
 'data' is leaked.

This ought to fix this problem:

Index: sdmmc.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc.c,v
retrieving revision 1.36
diff -u -p -r1.36 sdmmc.c
--- sdmmc.c 1 Nov 2014 16:32:06 -   1.36
+++ sdmmc.c 15 Feb 2015 20:52:08 -
@@ -749,7 +749,7 @@ sdmmc_ioctl(struct device *self, u_long 
struct sdmmc_command *ucmd;
struct sdmmc_command cmd;
void *data;
-   int error;
+   int error = 0;
 
switch (request) {
 #ifdef SDMMC_DEBUG
@@ -784,8 +784,9 @@ sdmmc_ioctl(struct device *self, u_long 
M_WAITOK | M_CANFAIL);
if (data == NULL)
return ENOMEM;
-   if (copyin(ucmd-c_data, data, ucmd-c_datalen))
-   return EFAULT;
+   error = copyin(ucmd-c_data, data, ucmd-c_datalen);
+   if (error != 0)
+   goto exec_done;
 
cmd.c_data = data;
cmd.c_datalen = ucmd-c_datalen;
@@ -804,10 +805,10 @@ sdmmc_ioctl(struct device *self, u_long 
ucmd-c_flags = cmd.c_flags;
ucmd-c_error = cmd.c_error;
 
-   if (ucmd-c_data  copyout(data, ucmd-c_data,
-   ucmd-c_datalen))
-   return EFAULT;
+   if (ucmd-c_data)
+  error = copyout(data, ucmd-c_data, ucmd-c_datalen);
 
+exec_done:
if (ucmd-c_data)
free(data, M_TEMP, 0);
break;
@@ -815,7 +816,7 @@ sdmmc_ioctl(struct device *self, u_long 
default:
return ENOTTY;
}
-   return 0;
+   return error;
 }
 #endif
 



Add support for Arduino Leonardo to umodem(4)

2015-02-15 Thread Gregor Best
Hi,

Arduino Leonardos emulate a CDC ACM modem for their serial port. The
following patch adds explicit matching for those in umodem_match,
because apparently the emulation done by the Leonardo is not complete
enough to make umodem attach automatically.

I've tested a kernel with this patch for a few days now, but only with a
baudrate of 115200, which seems to work fine.

-- 
Gregor Best

Index: dev/usb/umodem.c
===
RCS file: /mnt/media/cvs/src/sys/dev/usb/umodem.c,v
retrieving revision 1.57
diff -u -p -u -r1.57 umodem.c
--- dev/usb/umodem.c12 Jul 2014 20:26:33 -  1.57
+++ dev/usb/umodem.c13 Feb 2015 19:36:39 -
@@ -250,6 +250,10 @@ umodem_match(struct device *parent, void
id-bInterfaceNumber == 0)
ret = UMATCH_VENDOR_PRODUCT;
 
+   if (UGETW(dd-idVendor) == USB_VENDOR_ARDUINO 
+   UGETW(dd-idProduct) == USB_PRODUCT_ARDUINO_LEONARDO)
+   ret = UMATCH_VENDOR_PRODUCT;
+
if (ret == UMATCH_NONE 
id-bInterfaceClass == UICLASS_CDC 
id-bInterfaceSubClass == UISUBCLASS_ABSTRACT_CONTROL_MODEL 
Index: dev/usb/usbdevs
===
RCS file: /mnt/media/cvs/src/sys/dev/usb/usbdevs,v
retrieving revision 1.644
diff -u -p -u -r1.644 usbdevs
--- dev/usb/usbdevs 9 Jan 2015 20:41:48 -   1.644
+++ dev/usb/usbdevs 13 Feb 2015 19:36:40 -
@@ -54,6 +54,7 @@ vendor PLANEX40x0053  Planex Communicat
 vendor UNKNOWN20x0105  Unknown vendor
 vendor EGALAX2 0x0123  eGalax
 vendor UNKNOWN60x01e1  Unknown vendor
+vendor ARDUINO 0x2341  Arduino LLC
 vendor HUMAX   0x02ad  HUMAX
 vendor BWCT0x03da  Bernd Walter Computer Technology
 vendor AOX 0x03e8  AOX
@@ -977,6 +978,9 @@ product APPLE ISIGHT0x8502  iSight
 
 /* Araneus Information Systems products */
 product ARANEUS ALEA   0x0001  True Random Number Generator
+
+/* Arduino LLC products */
+product ARDUINO LEONARDO   0x8036  Arduino Lenoardo
 
 /* Arkmicro products */
 product ARKMICRO ARK3116   0x0232  ARK3116 Serial
Index: dev/usb/usbdevs.h
===
RCS file: /mnt/media/cvs/src/sys/dev/usb/usbdevs.h,v
retrieving revision 1.656
diff -u -p -u -r1.656 usbdevs.h
--- dev/usb/usbdevs.h   9 Jan 2015 20:42:40 -   1.656
+++ dev/usb/usbdevs.h   13 Feb 2015 19:36:44 -
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs.h,v 1.656 2015/01/09 20:42:40 kettenis Exp $  */
+/* $OpenBSD$   */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -61,6 +61,7 @@
 #defineUSB_VENDOR_UNKNOWN2 0x0105  /* Unknown vendor */
 #defineUSB_VENDOR_EGALAX2  0x0123  /* eGalax */
 #defineUSB_VENDOR_UNKNOWN6 0x01e1  /* Unknown vendor */
+#defineUSB_VENDOR_ARDUINO  0x2341  /* Arduino LLC */
 #defineUSB_VENDOR_HUMAX0x02ad  /* HUMAX */
 #defineUSB_VENDOR_BWCT 0x03da  /* Bernd Walter Computer 
Technology */
 #defineUSB_VENDOR_AOX  0x03e8  /* AOX */
@@ -984,6 +985,9 @@
 
 /* Araneus Information Systems products */
 #defineUSB_PRODUCT_ARANEUS_ALEA0x0001  /* True Random 
Number Generator */
+
+/* Arduino LLC products */
+#defineUSB_PRODUCT_ARDUINO_LEONARDO0x8036  /* Arduino 
Lenoardo */
 
 /* Arkmicro products */
 #defineUSB_PRODUCT_ARKMICRO_ARK31160x0232  /* ARK3116 
Serial */
Index: dev/usb/usbdevs_data.h
===
RCS file: /mnt/media/cvs/src/sys/dev/usb/usbdevs_data.h,v
retrieving revision 1.650
diff -u -p -u -r1.650 usbdevs_data.h
--- dev/usb/usbdevs_data.h  9 Jan 2015 20:42:40 -   1.650
+++ dev/usb/usbdevs_data.h  13 Feb 2015 19:36:44 -
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs_data.h,v 1.650 2015/01/09 20:42:40 kettenis Exp $ 
*/
+/* $OpenBSD$   */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -962,6 +962,10 @@ const struct usb_known_product usb_known
True Random Number Generator,
},
{
+   USB_VENDOR_ARDUINO, USB_PRODUCT_ARDUINO_LEONARDO,
+   Arduino Lenoardo,
+   },
+   {
USB_VENDOR_ARKMICRO, USB_PRODUCT_ARKMICRO_ARK3116,
ARK3116 Serial,
},
@@ -11248,6 +11252,10 @@ const struct usb_known_vendor usb_known_
{
USB_VENDOR_UNKNOWN6,
Unknown vendor,
+   },
+   {
+   USB_VENDOR_ARDUINO,
+   Arduino LLC,
},
{
USB_VENDOR_HUMAX,



ksh version lies

2015-02-15 Thread Ted Unangst
ksh (and sh) have a version string embedded in them:
@(#)PD KSH v5.2.14 99/07/13.2

This is clearly a lie. We've added, removed, and fixed bugs and features since
then. I first noticed the lie in the man page, then saw that it's also
exported via the environment and other places.

Instead of trying to fix something that can't be fixed, it's simpler to delete
it entirely. Somehow I think people will learn to live without PS1=\\V $
prompts. Just in case the version changes between commands I guess.

This may have obscure runtime fallout, so I'm happy to wait until after 5.7
release to commit the code changes, but I think we can delete the man page
references now as a first step towards deprecating this functionality.


Index: Makefile
===
RCS file: /cvs/src/bin/ksh/Makefile,v
retrieving revision 1.29
diff -u -p -r1.29 Makefile
--- Makefile2 Dec 2013 20:41:01 -   1.29
+++ Makefile16 Feb 2015 01:50:15 -
@@ -4,7 +4,7 @@ PROG=   ksh
 SRCS=  alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \
exec.c expr.c history.c io.c jobs.c lex.c mail.c main.c mknod.c \
misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c var.c \
-   version.c vi.c
+   vi.c
 
 DEFS=  -Wall
 CFLAGS+=${DEFS} -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/gen
Index: emacs.c
===
RCS file: /cvs/src/bin/ksh/emacs.c,v
retrieving revision 1.49
diff -u -p -r1.49 emacs.c
--- emacs.c 16 Feb 2015 01:44:41 -  1.49
+++ emacs.c 16 Feb 2015 01:50:15 -
@@ -185,7 +185,6 @@ static int  x_set_mark(int);
 static int x_stuff(int);
 static int x_stuffreset(int);
 static int x_transpose(int);
-static int x_version(int);
 static int x_xchg_point_mark(int);
 static int x_yank(int);
 static int x_comp_list(int);
@@ -244,7 +243,6 @@ static const struct x_ftab x_ftab[] = {
{ x_stuff,  stuff,0 },
{ x_stuffreset, stuff-reset,  0 },
{ x_transpose,  transpose-chars,  0 },
-   { x_version,version,  0 },
{ x_xchg_point_mark,exchange-point-and-mark,  0 },
{ x_yank,   yank, 0 },
{ x_comp_list,  complete-list,0 },
@@ -1654,35 +1652,6 @@ x_xchg_point_mark(int c)
tmp = xmp;
xmp = xcp;
x_goto( tmp );
-   return KSTD;
-}
-
-static int
-x_version(int c)
-{
-   char *o_xbuf = xbuf, *o_xend = xend;
-   char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp;
-   int lim = x_lastcp() - xbp;
-
-   xbuf = xbp = xcp = (char *) ksh_version + 4;
-   xend = xep = (char *) ksh_version + 4 + strlen(ksh_version + 4);
-   x_redraw(lim);
-   x_flush();
-
-   c = x_e_getc();
-   xbuf = o_xbuf;
-   xend = o_xend;
-   xbp = o_xbp;
-   xep = o_xep;
-   xcp = o_xcp;
-   x_redraw(strlen(ksh_version));
-
-   if (c  0)
-   return KSTD;
-   /* This is what att ksh seems to do...  Very bizarre */
-   if (c != ' ')
-   x_e_ungetc(c);
-
return KSTD;
 }
 
Index: ksh.1
===
RCS file: /cvs/src/bin/ksh/ksh.1,v
retrieving revision 1.156
diff -u -p -r1.156 ksh.1
--- ksh.1   16 Jan 2015 15:32:32 -  1.156
+++ ksh.1   16 Feb 2015 01:50:15 -
@@ -1465,8 +1465,6 @@ above for details.
 .Sy Note :
 This parameter is not imported from the environment when the shell is
 started.
-.It Ev KSH_VERSION
-The version of the shell and the date the version was created (read-only).
 .It Ev LINENO
 The line number of the function or shell script that is currently being
 executed.
@@ -1612,13 +1610,6 @@ The current time, in 12-hour HH:MM:SS AM
 The current time, in 24-hour HH:MM format.
 .It Li \eu
 The current user's username.
-.It Li \ev
-The current version of
-.Nm .
-.It Li \eV
-Like
-.Sq \ev ,
-but more verbose.
 .It Li \ew
 The current working directory.
 .Dv $HOME
@@ -5610,9 +5601,6 @@ Privileged shell profile.
 .%T IEEE Standard for Information Technology \- Portable Operating \
 System Interface (POSIX) \- Part 2: Shell and Utilities
 .Re
-.Sh VERSION
-This page documents version @(#)PD KSH v5.2.14 99/07/13.2 of the public
-domain Korn shell.
 .Sh AUTHORS
 .An -nosplit
 This shell is based on the public domain 7th edition Bourne shell clone by
Index: lex.c
===
RCS file: /cvs/src/bin/ksh/lex.c,v
retrieving revision 1.49
diff -u -p -r1.49 lex.c
--- lex.c   17 Dec 2013 16:37:06 -  1.49
+++ lex.c   16 Feb 2015 01:50:15 -
@@ -1310,21 +1310,6 @@ dopprompt(const char *sp, int ntruncate,
case 'u':   /* '\' 'u' username */

Re: ksh version lies

2015-02-15 Thread Kamil Rytarowski
Ted Unangst wrote:
 ksh (and sh) have a version string embedded in them:
 @(#)PD KSH v5.2.14 99/07/13.2
 
 This is clearly a lie. We've added, removed, and fixed bugs and features since
 then. I first noticed the lie in the man page, then saw that it's also
 exported via the environment and other places.
 
 Instead of trying to fix something that can't be fixed, it's simpler to delete
 it entirely. [...]
 

1. MacOSX
Please see:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ksh.1.html

2. ksh93
Please see original source code of ksh93 (links from http://kornshell.com ).
Extracted from their sh.1 embedded in the source package:
.sh.version
  Set to a value that identifies the version of this shell.
KSH_VERSION
  A name reference to .sh.version.

3. MirBSD Korn Shell (pdksh fork) ( http://linux.die.net/man/1/mksh )
KSH_VERSIONThe name and version of the shell (read-only).

What's broken?



Re: ksh version lies

2015-02-15 Thread Damien Miller
On Sun, 15 Feb 2015, Ted Unangst wrote:

 ksh (and sh) have a version string embedded in them:
 @(#)PD KSH v5.2.14 99/07/13.2
 
 This is clearly a lie. We've added, removed, and fixed bugs and features since
 then. I first noticed the lie in the man page, then saw that it's also
 exported via the environment and other places.
 
 Instead of trying to fix something that can't be fixed,

That's a bit of a non sequitur; there are lots of ways to fix it.
E.g. OpenBSD 5.7 ksh; based on PD KSH v5.2.14

-d




Re: Brainy: Kernel Memory Leak in sdmmc

2015-02-15 Thread Miod Vallat
 On Sun, Feb 15, 2015 at 08:53:08PM +, Miod Vallat wrote:
  This ought to fix this problem:
 
 This looks reasonable but needs a tweak if you want to keep the existing
 behavior.  In the existing code, it has this section above the copyout():
 
   rw_enter_write(sc-sc_lock);
   if (request == SDIOCEXECMMC)
   error = sdmmc_mmc_command(sc, cmd);
   else
   error = sdmmc_app_command(sc, cmd);
   rw_exit(sc-sc_lock);
   if (error  !cmd.c_error)
   cmd.c_error = error;
 
 and returns 0 even if error is non-zero.  With this diff, it will either
 return the result of those functions or the result of copyout depending
 on whether ucmd-c_data is non-zero.  Using the result of copyout is
 intentional, but not the result from sdmmc_{mmc,app}_command().
 
 Could you set error=0 after the above chunk or use a new variable?
 Also, one of the new lines has space indents rather than a tab.

Indeed.

Index: sdmmc.c
===
RCS file: /cvs/src/sys/dev/sdmmc/sdmmc.c,v
retrieving revision 1.36
diff -u -p -r1.36 sdmmc.c
--- sdmmc.c 1 Nov 2014 16:32:06 -   1.36
+++ sdmmc.c 16 Feb 2015 05:14:27 -
@@ -749,7 +749,7 @@ sdmmc_ioctl(struct device *self, u_long 
struct sdmmc_command *ucmd;
struct sdmmc_command cmd;
void *data;
-   int error;
+   int error = 0;
 
switch (request) {
 #ifdef SDMMC_DEBUG
@@ -784,8 +784,9 @@ sdmmc_ioctl(struct device *self, u_long 
M_WAITOK | M_CANFAIL);
if (data == NULL)
return ENOMEM;
-   if (copyin(ucmd-c_data, data, ucmd-c_datalen))
-   return EFAULT;
+   error = copyin(ucmd-c_data, data, ucmd-c_datalen);
+   if (error != 0)
+   goto exec_done;
 
cmd.c_data = data;
cmd.c_datalen = ucmd-c_datalen;
@@ -804,10 +805,12 @@ sdmmc_ioctl(struct device *self, u_long 
ucmd-c_flags = cmd.c_flags;
ucmd-c_error = cmd.c_error;
 
-   if (ucmd-c_data  copyout(data, ucmd-c_data,
-   ucmd-c_datalen))
-   return EFAULT;
+   if (ucmd-c_data)
+   error = copyout(data, ucmd-c_data, ucmd-c_datalen);
+   else
+   error = 0;
 
+exec_done:
if (ucmd-c_data)
free(data, M_TEMP, 0);
break;
@@ -815,7 +818,7 @@ sdmmc_ioctl(struct device *self, u_long 
default:
return ENOTTY;
}
-   return 0;
+   return error;
 }
 #endif