svn commit: r334071 - head/usr.bin/getconf

2018-05-22 Thread Garrett Wollman
Author: wollman
Date: Wed May 23 02:54:28 2018
New Revision: 334071
URL: https://svnweb.freebsd.org/changeset/base/334071

Log:
  Whoops, forgot to add this file in r334070.
  
  PR:   164049

Added:
  head/usr.bin/getconf/unsigned_limits.gperf   (contents, props changed)

Added: head/usr.bin/getconf/unsigned_limits.gperf
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/getconf/unsigned_limits.gperf  Wed May 23 02:54:28 2018
(r334071)
@@ -0,0 +1,43 @@
+%{
+/*
+ * Copyright is disclaimed as to the contents of this file.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+
+#include 
+#include 
+
+#include "getconf.h"
+
+/*
+ * Override gperf's built-in external scope.
+ */
+static const struct map *in_word_set(const char *str);
+
+%}
+struct map { const char *name; uintmax_t value; int valid; };
+%%
+UCHAR_MAX, UCHAR_MAX
+UINT_MAX, UINT_MAX
+ULLONG_MAX, ULLONG_MAX
+ULONG_MAX, ULONG_MAX
+USHRT_MAX, USHRT_MAX
+%%
+int
+find_unsigned_limit(const char *name, uintmax_t *value)
+{
+   const struct map *rv;
+
+   rv = in_word_set(name);
+   if (rv != NULL) {
+   if (rv->valid) {
+   *value = rv->value;
+   return 1;
+   }
+   return -1;
+   }
+   return 0;
+}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334070 - head/usr.bin/getconf

2018-05-22 Thread Garrett Wollman
Author: wollman
Date: Wed May 23 02:51:56 2018
New Revision: 334070
URL: https://svnweb.freebsd.org/changeset/base/334070

Log:
  Move unsigned limits to a separate table/recognizer and display them
  using the appropriate (unsigned) format specification.  This prevents
  integer overflow when ULLONG_MAX and (on some architectures) ULONG_MAX
  are used to initialize an intmax_t and then displayed as the signed
  value -1.  (A different approach was suggested in the bug report,
  which I did not use.)  If other limits are defined to be unsigned,
  they could be moved here.
  
  PR:   164049
  Reported by:  Marcus Reid

Modified:
  head/usr.bin/getconf/Makefile
  head/usr.bin/getconf/getconf.c
  head/usr.bin/getconf/getconf.h
  head/usr.bin/getconf/limits.gperf

Modified: head/usr.bin/getconf/Makefile
==
--- head/usr.bin/getconf/Makefile   Wed May 23 01:48:09 2018
(r334069)
+++ head/usr.bin/getconf/Makefile   Wed May 23 02:51:56 2018
(r334070)
@@ -4,11 +4,12 @@
 
 PROG=  getconf
 
-SRCS=  confstr.c getconf.c limits.c pathconf.c progenv.c sysconf.c
+SRCS=  confstr.c getconf.c limits.c pathconf.c progenv.c sysconf.c \
+   unsigned_limits.c
 CFLAGS+= -I${.CURDIR}
 CLEANFILES+=   confstr.c limits.c pathconf.c progenv.c sysconf.c \
confstr.names limits.names pathconf.names sysconf.names \
-   conflicting.names unique.names
+   conflicting.names unique.names unsigned_limits.names
 
 .SUFFIXES: .gperf .names
 .PHONY: conflicts

Modified: head/usr.bin/getconf/getconf.c
==
--- head/usr.bin/getconf/getconf.c  Wed May 23 01:48:09 2018
(r334069)
+++ head/usr.bin/getconf/getconf.c  Wed May 23 02:51:56 2018
(r334070)
@@ -65,6 +65,7 @@ main(int argc, char **argv)
int c, key, valid;
const char *name, *vflag, *alt_path;
intmax_t limitval;
+   uintmax_t ulimitval;
 
aflag = false;
vflag = NULL;
@@ -115,6 +116,13 @@ main(int argc, char **argv)
}
 
if (argv[optind + 1] == NULL) { /* confstr or sysconf */
+   if ((valid = find_unsigned_limit(name, )) != 0) {
+   if (valid > 0)
+   printf("%" PRIuMAX "\n", ulimitval);
+   else
+   printf("undefined\n");
+   return 0;
+   }
if ((valid = find_limit(name, )) != 0) {
if (valid > 0)
printf("%" PRIdMAX "\n", limitval);

Modified: head/usr.bin/getconf/getconf.h
==
--- head/usr.bin/getconf/getconf.h  Wed May 23 01:48:09 2018
(r334069)
+++ head/usr.bin/getconf/getconf.h  Wed May 23 02:51:56 2018
(r334070)
@@ -37,6 +37,7 @@ typedef long long intmax_t;
 #endif
 
 intfind_confstr(const char *name, int *key);
+intfind_unsigned_limit(const char *name, uintmax_t *value);
 intfind_limit(const char *name, intmax_t *value);
 intfind_pathconf(const char *name, int *key);
 intfind_progenv(const char *name, const char **alt_path);

Modified: head/usr.bin/getconf/limits.gperf
==
--- head/usr.bin/getconf/limits.gperf   Wed May 23 01:48:09 2018
(r334069)
+++ head/usr.bin/getconf/limits.gperf   Wed May 23 02:51:56 2018
(r334070)
@@ -86,11 +86,6 @@ SCHAR_MIN, SCHAR_MIN
 SHRT_MAX, SHRT_MAX
 SHRT_MIN, SHRT_MIN
 SSIZE_MAX, SSIZE_MAX
-UCHAR_MAX, UCHAR_MAX
-UINT_MAX, UINT_MAX
-ULLONG_MAX, ULLONG_MAX
-ULONG_MAX, ULONG_MAX
-USHRT_MAX, USHRT_MAX
 WORD_BIT, WORD_BIT
 CHARCLASS_NAME_MAX, CHARCLASS_NAME_MAX
 NL_ARGMAX, NL_ARGMAX
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r293358 - stable/10/sys/netinet6

2016-01-07 Thread Garrett Wollman
Author: wollman
Date: Thu Jan  7 20:43:45 2016
New Revision: 293358
URL: https://svnweb.freebsd.org/changeset/base/293358

Log:
  MFH r292836:
  
  in6_if2idlen: treat bridge(4) interfaces like other Ethernet interfaces
  
  bridge(4) interfaces have an if_type of IFT_BRIDGE, rather than
  IFT_ETHER, even though they only support Ethernet-style links.  This
  caused in6_if2idlen to emit an "unknown link type (209)" warning to
  the console every time it was called.  Add IFT_BRIDGE to the case
  statement in the appropriate place, indicating that it uses the same
  IPv6 address format as other Ethernet-like interfaces.

Modified:
  stable/10/sys/netinet6/in6.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet6/in6.c
==
--- stable/10/sys/netinet6/in6.cThu Jan  7 20:37:18 2016
(r293357)
+++ stable/10/sys/netinet6/in6.cThu Jan  7 20:43:45 2016
(r293358)
@@ -2449,6 +2449,7 @@ in6_if2idlen(struct ifnet *ifp)
 #ifdef IFT_MIP
case IFT_MIP:   /* ditto */
 #endif
+   case IFT_BRIDGE:/* bridge(4) only does Ethernet-like links */
case IFT_INFINIBAND:
return (64);
case IFT_FDDI:  /* RFC2467 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r292836 - head/sys/netinet6

2015-12-28 Thread Garrett Wollman
Author: wollman
Date: Mon Dec 28 18:29:47 2015
New Revision: 292836
URL: https://svnweb.freebsd.org/changeset/base/292836

Log:
  in6_if2idlen: treat bridge(4) interfaces like other Ethernet interfaces
  
  bridge(4) interfaces have an if_type of IFT_BRIDGE, rather than
  IFT_ETHER, even though they only support Ethernet-style links.  This
  caused in6_if2idlen to emit an "unknown link type (209)" warning to
  the console every time it was called.  Add IFT_BRIDGE to the case
  statement in the appropriate place, indicating that it uses the same
  IPv6 address format as other Ethernet-like interfaces.
  
  MFC after:1 week

Modified:
  head/sys/netinet6/in6.c

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Mon Dec 28 18:28:18 2015(r292835)
+++ head/sys/netinet6/in6.c Mon Dec 28 18:29:47 2015(r292836)
@@ -2008,6 +2008,7 @@ in6_if2idlen(struct ifnet *ifp)
case IFT_PROPVIRTUAL:   /* XXX: no RFC. treat it as ether */
case IFT_L2VLAN:/* ditto */
case IFT_IEEE80211: /* ditto */
+   case IFT_BRIDGE:/* bridge(4) only does Ethernet-like links */
case IFT_INFINIBAND:
return (64);
case IFT_FDDI:  /* RFC2467 */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r290203 - stable/10/sys/rpc

2015-10-30 Thread Garrett Wollman
Author: wollman
Date: Fri Oct 30 19:26:55 2015
New Revision: 290203
URL: https://svnweb.freebsd.org/changeset/base/290203

Log:
  Long-overdue MFC of r280930:
  
Fix overflow bugs in and remove obsolete limit from kernel RPC
implementation.
  
The kernel RPC code, which is responsible for the low-level scheduling
of incoming NFS requests, contains a throttling mechanism that
prevents too much kernel memory from being tied up by NFS requests
that are being serviced.  When the throttle is engaged, the RPC layer
stops servicing incoming NFS sockets, resulting ultimately in
backpressure on the clients (if they're using TCP).  However, this is
a very heavy-handed mechanism as it prevents all clients from making
any requests, regardless of how heavy or light they are.  (Thus, when
engaged, the throttle often prevents clients from even mounting the
filesystem.)  The throttle mechanism applies specifically to requests
that have been received by the RPC layer (from a TCP or UDP socket)
and are queued waiting to be serviced by one of the nfsd threads; it
does not limit the amount of backlog in the socket buffers.
  
The original implementation limited the total bytes of queued requests
to the minimum of a quarter of (nmbclusters * MCLBYTES) and 45 MiB.
The former limit seems reasonable, since requests queued in the socket
buffers and replies being constructed to the requests in progress will
all require some amount of network memory, but the 45 MiB limit is
plainly ridiculous for modern memory sizes: when running 256 service
threads on a busy server, 45 MiB would result in just a single
maximum-sized NFS3PROC_WRITE queued per thread before throttling.
  
Removing this limit exposed integer-overflow bugs in the original
computation, and related bugs in the routines that actually account
for the amount of traffic enqueued for service threads.  The old
implementation also attempted to reduce accounting overhead by
batching updates until each queue is fully drained, but this is prone
to livelock, resulting in repeated accumulate-throttle-drain cycles on
a busy server.  Various data types are changed to long or unsigned
long; explicit 64-bit types are not used due to the unavailability of
64-bit atomics on many 32-bit platforms, but those platforms also
cannot support nmbclusters large enough to cause overflow.
  
This code (in a 10.1 kernel) is presently running on production NFS
servers at CSAIL.
  
Summary of this revision:
* Removes 45 MiB limit on requests queued for nfsd service threads
* Fixes integer-overflow and signedness bugs
* Avoids unnecessary throttling by not deferring accounting for
  completed requests
  
  Differential Revision:https://reviews.freebsd.org/D2165
  Reviewed by:  rmacklem, mav
  Relnotes: yes
  Sponsored by: MIT Computer Science & Artificial Intelligence Laboratory

Modified:
  stable/10/sys/rpc/svc.c
  stable/10/sys/rpc/svc.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/rpc/svc.c
==
--- stable/10/sys/rpc/svc.c Fri Oct 30 19:20:40 2015(r290202)
+++ stable/10/sys/rpc/svc.c Fri Oct 30 19:26:55 2015(r290203)
@@ -73,7 +73,7 @@ static struct svc_callout *svc_find(SVCP
 char *);
 static void svc_new_thread(SVCGROUP *grp);
 static void xprt_unregister_locked(SVCXPRT *xprt);
-static void svc_change_space_used(SVCPOOL *pool, int delta);
+static void svc_change_space_used(SVCPOOL *pool, long delta);
 static bool_t svc_request_space_available(SVCPOOL *pool);
 
 /* ***  SVCXPRT related stuff  */
@@ -113,13 +113,14 @@ svcpool_create(const char *name, struct 
}
 
/*
-* Don't use more than a quarter of mbuf clusters or more than
-* 45Mb buffering requests.
+* Don't use more than a quarter of mbuf clusters.  Nota bene:
+* nmbclusters is an int, but nmbclusters*MCLBYTES may overflow
+* on LP64 architectures, so cast to u_long to avoid undefined
+* behavior.  (ILP32 architectures cannot have nmbclusters
+* large enough to overflow for other reasons.)
 */
-   pool->sp_space_high = nmbclusters * MCLBYTES / 4;
-   if (pool->sp_space_high > 45 << 20)
-   pool->sp_space_high = 45 << 20;
-   pool->sp_space_low = 2 * pool->sp_space_high / 3;
+   pool->sp_space_high = (u_long)nmbclusters * MCLBYTES / 4;
+   pool->sp_space_low = (pool->sp_space_high / 3) * 2;
 
sysctl_ctx_init(>sp_sysctl);
if (sysctl_base) {
@@ -139,24 +140,24 @@ svcpool_create(const char *name, struct 
"groups", CTLFLAG_RD, >sp_groupcount, 0,
"Number of thread groups");
 
-   SYSCTL_ADD_UINT(>sp_sysctl, sysctl_base, OID_AUTO,
+ 

svn commit: r280930 - head/sys/rpc

2015-03-31 Thread Garrett Wollman
Author: wollman
Date: Wed Apr  1 00:45:47 2015
New Revision: 280930
URL: https://svnweb.freebsd.org/changeset/base/280930

Log:
  Fix overflow bugs in and remove obsolete limit from kernel RPC
  implementation.
  
  The kernel RPC code, which is responsible for the low-level scheduling
  of incoming NFS requests, contains a throttling mechanism that
  prevents too much kernel memory from being tied up by NFS requests
  that are being serviced.  When the throttle is engaged, the RPC layer
  stops servicing incoming NFS sockets, resulting ultimately in
  backpressure on the clients (if they're using TCP).  However, this is
  a very heavy-handed mechanism as it prevents all clients from making
  any requests, regardless of how heavy or light they are.  (Thus, when
  engaged, the throttle often prevents clients from even mounting the
  filesystem.)  The throttle mechanism applies specifically to requests
  that have been received by the RPC layer (from a TCP or UDP socket)
  and are queued waiting to be serviced by one of the nfsd threads; it
  does not limit the amount of backlog in the socket buffers.
  
  The original implementation limited the total bytes of queued requests
  to the minimum of a quarter of (nmbclusters * MCLBYTES) and 45 MiB.
  The former limit seems reasonable, since requests queued in the socket
  buffers and replies being constructed to the requests in progress will
  all require some amount of network memory, but the 45 MiB limit is
  plainly ridiculous for modern memory sizes: when running 256 service
  threads on a busy server, 45 MiB would result in just a single
  maximum-sized NFS3PROC_WRITE queued per thread before throttling.
  
  Removing this limit exposed integer-overflow bugs in the original
  computation, and related bugs in the routines that actually account
  for the amount of traffic enqueued for service threads.  The old
  implementation also attempted to reduce accounting overhead by
  batching updates until each queue is fully drained, but this is prone
  to livelock, resulting in repeated accumulate-throttle-drain cycles on
  a busy server.  Various data types are changed to long or unsigned
  long; explicit 64-bit types are not used due to the unavailability of
  64-bit atomics on many 32-bit platforms, but those platforms also
  cannot support nmbclusters large enough to cause overflow.
  
  This code (in a 10.1 kernel) is presently running on production NFS
  servers at CSAIL.
  
  Summary of this revision:
  * Removes 45 MiB limit on requests queued for nfsd service threads
  * Fixes integer-overflow and signedness bugs
  * Avoids unnecessary throttling by not deferring accounting for
completed requests
  
  Differential Revision:https://reviews.freebsd.org/D2165
  Reviewed by:  rmacklem, mav
  MFC after:30 days
  Relnotes: yes
  Sponsored by: MIT Computer Science  Artificial Intelligence Laboratory

Modified:
  head/sys/rpc/svc.c
  head/sys/rpc/svc.h

Modified: head/sys/rpc/svc.c
==
--- head/sys/rpc/svc.c  Wed Apr  1 00:15:31 2015(r280929)
+++ head/sys/rpc/svc.c  Wed Apr  1 00:45:47 2015(r280930)
@@ -73,7 +73,7 @@ static struct svc_callout *svc_find(SVCP
 char *);
 static void svc_new_thread(SVCGROUP *grp);
 static void xprt_unregister_locked(SVCXPRT *xprt);
-static void svc_change_space_used(SVCPOOL *pool, int delta);
+static void svc_change_space_used(SVCPOOL *pool, long delta);
 static bool_t svc_request_space_available(SVCPOOL *pool);
 
 /* ***  SVCXPRT related stuff  */
@@ -113,13 +113,14 @@ svcpool_create(const char *name, struct 
}
 
/*
-* Don't use more than a quarter of mbuf clusters or more than
-* 45Mb buffering requests.
+* Don't use more than a quarter of mbuf clusters.  Nota bene:
+* nmbclusters is an int, but nmbclusters*MCLBYTES may overflow
+* on LP64 architectures, so cast to u_long to avoid undefined
+* behavior.  (ILP32 architectures cannot have nmbclusters
+* large enough to overflow for other reasons.)
 */
-   pool-sp_space_high = nmbclusters * MCLBYTES / 4;
-   if (pool-sp_space_high  45  20)
-   pool-sp_space_high = 45  20;
-   pool-sp_space_low = 2 * pool-sp_space_high / 3;
+   pool-sp_space_high = (u_long)nmbclusters * MCLBYTES / 4;
+   pool-sp_space_low = (pool-sp_space_high / 3) * 2;
 
sysctl_ctx_init(pool-sp_sysctl);
if (sysctl_base) {
@@ -139,24 +140,24 @@ svcpool_create(const char *name, struct 
groups, CTLFLAG_RD, pool-sp_groupcount, 0,
Number of thread groups);
 
-   SYSCTL_ADD_UINT(pool-sp_sysctl, sysctl_base, OID_AUTO,
+   SYSCTL_ADD_ULONG(pool-sp_sysctl, sysctl_base, OID_AUTO,
request_space_used, CTLFLAG_RD,
-   pool-sp_space_used, 0,
+   

svn commit: r267840 - head/lib/libc/sys

2014-06-24 Thread Garrett Wollman
Author: wollman
Date: Tue Jun 24 20:23:18 2014
New Revision: 267840
URL: http://svnweb.freebsd.org/changeset/base/267840

Log:
  Catch up with many years of changes:
  
  o Document PF_LOCAL as being an alias for PF_UNIX
  o Document POSIX standardization of this interface using AF_*
constants rather than PF_* constants, and note the three particular
families which POSIX standardizes.
  o Note anticipated POSIX standardization of SOCK_CLOEXEC.
  o Delete from listing protocol families that FreeBSD doesn't support
(in some cases, like PF_PUP, has never supported).
  o Add to listing some current protocol families that have been
introduced in the last decade or so.
  o Document the correspondence of PF_* and AF_* constants.
  
  We should probably change the documentation to make the AF_* constants
  primary, but this commit does not do so.
  
  Reviewed by:  kevlo@
  MFC after:1 month

Modified:
  head/lib/libc/sys/socket.2

Modified: head/lib/libc/sys/socket.2
==
--- head/lib/libc/sys/socket.2  Tue Jun 24 20:11:22 2014(r267839)
+++ head/lib/libc/sys/socket.2  Tue Jun 24 20:23:18 2014(r267840)
@@ -57,24 +57,30 @@ These families are defined in the includ
 The currently understood formats are:
 .Pp
 .Bd -literal -offset indent -compact
-PF_LOCAL   Host-internal protocols, formerly called PF_UNIX,
-PF_UNIXHost-internal protocols, deprecated, use PF_LOCAL,
+PF_LOCAL   Host-internal protocols (alias for PF_UNIX),
+PF_UNIXHost-internal protocols,
 PF_INETInternet version 4 protocols,
-PF_PUP PUP protocols, like BSP,
-PF_APPLETALK   AppleTalk protocols,
-PF_ROUTE   Internal Routing protocol,
+PF_INET6   Internet version 6 protocols,
+PF_ROUTE   Internal routing protocol,
 PF_LINKLink layer interface,
-PF_IPX Novell Internet Packet eXchange protocol,
-PF_RTIPHelp Identify RTIP packets,
-PF_PIP Help Identify PIP packets,
-PF_ISDNIntegrated Services Digital Network,
 PF_KEY Internal key-management function,
-PF_INET6   Internet version 6 protocols,
-PF_NATMNative ATM access,
-PF_ATM ATM,
-PF_NETGRAPHNetgraph sockets
+PF_NATMAsynchronous transfer mode protocols,
+PF_NETGRAPHNetgraph sockets,
+PF_IEEE80211   IEEE 802.11 wireless link-layer protocols (WiFi),
+PF_BLUETOOTH   Bluetooth protocols,
+PF_INET_SDPOFED socket direct protocol (IPv4),
+PF_INET6_SDP   OFED socket direct protocol (IPv6)
 .Ed
 .Pp
+Each protocol family is connected to an address family, which has the
+same name except that the prefix is
+.Dq Dv AF_
+in place of
+.Dq Dv PF_ .
+Other protocol families may be also defined, beginning with
+.Dq Dv PF_ ,
+with corresponding address families.
+.Pp
 The socket has the indicated
 .Fa type ,
 which specifies the semantics of communication.
@@ -307,6 +313,37 @@ The socket type is not supported by the 
 .%B PS1
 .%N 8
 .Re
+.Sh STANDARDS
+The
+.Fn socket
+function conforms to
+.St -p1003.1-2008 .
+The
+.Tn POSIX
+standard specifies only the
+.Dv AF_INET ,
+.Dv AF_INET6 ,
+and
+.Dv AF_UNIX
+constants for address families, and requires the use of
+.Dv AF_*
+constants for the
+.Fa domain
+argument of
+.Fn socket .
+The
+.Dv SOCK_CLOEXEC
+flag is expected to conform to the next revision of the
+.Tn POSIX
+standard.
+The
+.Dv SOCK_RDM
+.Fa type ,
+the
+.Dv PF_*
+constants, and other address families are
+.Fx
+extensions.
 .Sh HISTORY
 The
 .Fn socket
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r241140 - head/sys/kern

2012-10-02 Thread Garrett Wollman
Author: wollman
Date: Tue Oct  2 18:38:05 2012
New Revision: 241140
URL: http://svn.freebsd.org/changeset/base/241140

Log:
  Fix spelling of the function name in two assertion messages.

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==
--- head/sys/kern/uipc_socket.c Tue Oct  2 17:46:32 2012(r241139)
+++ head/sys/kern/uipc_socket.c Tue Oct  2 18:38:05 2012(r241140)
@@ -995,9 +995,9 @@ sosend_dgram(struct socket *so, struct s
int atomic = sosendallatonce(so) || top;
 #endif
 
-   KASSERT(so-so_type == SOCK_DGRAM, (sodgram_send: !SOCK_DGRAM));
+   KASSERT(so-so_type == SOCK_DGRAM, (sosend_dgram: !SOCK_DGRAM));
KASSERT(so-so_proto-pr_flags  PR_ATOMIC,
-   (sodgram_send: !PR_ATOMIC));
+   (sosend_dgram: !PR_ATOMIC));
 
if (uio != NULL)
resid = uio-uio_resid;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r231181 - head/usr.sbin/tzsetup

2012-02-07 Thread Garrett Wollman
Author: wollman
Date: Wed Feb  8 05:03:04 2012
New Revision: 231181
URL: http://svn.freebsd.org/changeset/base/231181

Log:
  It's not an error if unlink(2) fails because the pathname doesn't exist.
  
  Noticed by: kevlo
  Pointy hat to: wollman

Modified:
  head/usr.sbin/tzsetup/tzsetup.c

Modified: head/usr.sbin/tzsetup/tzsetup.c
==
--- head/usr.sbin/tzsetup/tzsetup.c Wed Feb  8 04:55:00 2012
(r231180)
+++ head/usr.sbin/tzsetup/tzsetup.c Wed Feb  8 05:03:04 2012
(r231181)
@@ -723,7 +723,7 @@ install_zoneinfo_file(const char *zonein
return (DITEM_FAILURE | DITEM_RECREATE);
}
 
-   if (unlink(path_localtime)  0) {
+   if (unlink(path_localtime)  0  errno != ENOENT) {
snprintf(prompt, sizeof(prompt),
Could not unlink %s: %s,
path_localtime, strerror(errno));
@@ -780,7 +780,7 @@ install_zoneinfo_file(const char *zonein
fprintf(stderr, %s\n, prompt);
return (DITEM_FAILURE | DITEM_RECREATE);
}
-   if (unlink(path_localtime)  0) {
+   if (unlink(path_localtime)  0  errno != ENOENT) {
snprintf(prompt, sizeof(prompt),
Could not unlink %s: %s,
path_localtime, strerror(errno));
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r230005 - head/usr.sbin/tzsetup

2012-01-11 Thread Garrett Wollman
Author: wollman
Date: Thu Jan 12 05:50:32 2012
New Revision: 230005
URL: http://svn.freebsd.org/changeset/base/230005

Log:
  Use a reasonable-sized buffer when formatting error messages about
  installing zoneinfo.  While we're in the vicinity, add some missing
  error checking to eliminate an unhelpful error message when unlink()
  fails.
  
  /me is embarrassed by the quality of his 16-year-old code.
  The whole thing is awful and could stand a complete rewrite.
  
  PR:   164038
  Submitted by: Devin Teske (but implemented differently)

Modified:
  head/usr.sbin/tzsetup/tzsetup.c

Modified: head/usr.sbin/tzsetup/tzsetup.c
==
--- head/usr.sbin/tzsetup/tzsetup.c Thu Jan 12 05:47:28 2012
(r230004)
+++ head/usr.sbin/tzsetup/tzsetup.c Thu Jan 12 05:50:32 2012
(r230005)
@@ -57,6 +57,13 @@ __FBSDID($FreeBSD$);
 #define_PATH_DB/var/db/zoneinfo
 #define_PATH_WALL_CMOS_CLOCK   /etc/wall_cmos_clock
 
+#ifdef PATH_MAX
+#defineSILLY_BUFFER_SIZE   2*PATH_MAX
+#else
+#warning Somebody needs to fix this to dynamically size this buffer.
+#defineSILLY_BUFFER_SIZE   2048
+#endif
+
 /* special return codes for `fire' actions */
 #define DITEM_FAILURE   1
 
@@ -638,7 +645,7 @@ static int
 install_zoneinfo_file(const char *zoneinfo_file)
 {
charbuf[1024];
-   chartitle[64], prompt[64];
+   chartitle[64], prompt[SILLY_BUFFER_SIZE];
struct stat sb;
ssize_t len;
int fd1, fd2, copymode;
@@ -709,7 +716,18 @@ install_zoneinfo_file(const char *zonein
return (DITEM_FAILURE | DITEM_RECREATE);
}
 
-   unlink(path_localtime);
+   if (unlink(path_localtime)  0) {
+   snprintf(prompt, sizeof(prompt),
+   Could not unlink %s: %s,
+   path_localtime, strerror(errno));
+   if (usedialog) {
+   snprintf(title, sizeof(title), Error);
+   dialog_msgbox(title, prompt, 8, 72, 1);
+   } else
+   fprintf(stderr, %s\n, prompt);
+   return (DITEM_FAILURE | DITEM_RECREATE);
+   }
+
fd2 = open(path_localtime, O_CREAT | O_EXCL | O_WRONLY,
S_IRUSR | S_IRGRP | S_IROTH);
if (fd2  0) {
@@ -755,7 +773,17 @@ install_zoneinfo_file(const char *zonein
fprintf(stderr, %s\n, prompt);
return (DITEM_FAILURE | DITEM_RECREATE);
}
-   unlink(path_localtime);
+   if (unlink(path_localtime)  0) {
+   snprintf(prompt, sizeof(prompt),
+   Could not unlink %s: %s,
+   path_localtime, strerror(errno));
+   if (usedialog) {
+   snprintf(title, sizeof(title), Error);
+   dialog_msgbox(title, prompt, 8, 72, 1);
+   } else
+   fprintf(stderr, %s\n, prompt);
+   return (DITEM_FAILURE | DITEM_RECREATE);
+   }
if (symlink(zoneinfo_file, path_localtime)  0) {
snprintf(title, sizeof(title), Error);
snprintf(prompt, sizeof(prompt),
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r216745 - stable/8/usr.bin/locate/locate

2010-12-27 Thread Garrett Wollman
Author: wollman
Date: Mon Dec 27 23:46:47 2010
New Revision: 216745
URL: http://svn.freebsd.org/changeset/base/216745

Log:
  Merge three revisions from head:
  
r214583 | wollman | 2010-10-30 22:36:05 -0400 (Sat, 30 Oct 2010) | 6 lines
Changed paths:
   M /head/usr.bin/locate/locate/locate.rc
   M /head/usr.bin/locate/locate/updatedb.sh
  
Make it possible to exclude directories by name no matter where they
are in the filesystem from the locate database.  By default, exclude
.zfs directories, as users who who have set snapdir=visible and are
taking frequent snapshots most likely do not want the snapshots
included in the locate database.
  

r214613 | wollman | 2010-10-31 21:51:47 -0400 (Sun, 31 Oct 2010) | 7 lines
Changed paths:
   M /head/usr.bin/locate/locate/updatedb.sh
  
jilles@ pointed out that using ${PRUNEDIRS:=.zfs} in updatedb.sh
made it impossible to override PRUNEDIRS to make it empty.  Use the
non-colon form to only set PRUNEDIRS if it is completely unset.  (For
parallelism, the other configuration defaults here could be done the
same way, but that could be more obviously accomplished by disabling
updatedb in periodic.conf, so leave them alone for now.)
  

r214615 | wollman | 2010-10-31 22:20:18 -0400 (Sun, 31 Oct 2010) | 6 lines
Changed paths:
   M /head/usr.bin/locate/locate/updatedb.sh
  
Style cleanup: make this look more like a 21st-century shell script
and not something out of the early 1980s.  Make sure all error
messages go to stderr, not stdout.  Since there's error-handling code
to handle empty SEARCHPATHS and FILESYSTEMS, use the initialization
form that allows this error to be diagnosed.  (hat tip: jilles@)

Modified:
  stable/8/usr.bin/locate/locate/locate.rc
  stable/8/usr.bin/locate/locate/updatedb.sh
Directory Properties:
  stable/8/usr.bin/locate/   (props changed)

Modified: stable/8/usr.bin/locate/locate/locate.rc
==
--- stable/8/usr.bin/locate/locate/locate.rcMon Dec 27 22:52:47 2010
(r216744)
+++ stable/8/usr.bin/locate/locate/locate.rcMon Dec 27 23:46:47 2010
(r216745)
@@ -15,9 +15,12 @@
 # directories to be put in the database
 #SEARCHPATHS=/
 
-# directories unwanted in output
+# paths unwanted in output
 #PRUNEPATHS=/tmp /usr/tmp /var/tmp /var/db/portsnap
 
+# directories unwanted in output
+#PRUNEDIRS=.zfs
+
 # filesystems allowed. Beware: a non-listed filesystem will be pruned
 # and if the SEARCHPATHS starts in such a filesystem locate will build
 # an empty database.

Modified: stable/8/usr.bin/locate/locate/updatedb.sh
==
--- stable/8/usr.bin/locate/locate/updatedb.sh  Mon Dec 27 22:52:47 2010
(r216744)
+++ stable/8/usr.bin/locate/locate/updatedb.sh  Mon Dec 27 23:46:47 2010
(r216745)
@@ -50,17 +50,20 @@ PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; ex
 
 : ${mklocatedb:=locate.mklocatedb}  # make locate database program
 : ${FCODES:=/var/db/locate.database}# the database
-: ${SEARCHPATHS:=/}  # directories to be put in the database
-: ${PRUNEPATHS:=/tmp /usr/tmp /var/tmp /var/db/portsnap} # unwanted 
directories
-: ${FILESYSTEMS:=$(lsvfs | tail -n +3 | \
+: ${SEARCHPATHS=/}   # directories to be put in the database
+: ${PRUNEPATHS=/tmp /usr/tmp /var/tmp /var/db/portsnap} # unwanted 
directories
+: ${PRUNEDIRS=.zfs}  # unwanted directories, in any parent
+: ${FILESYSTEMS=$(lsvfs | tail -n +3 | \
egrep -vw loopback|network|synthetic|read-only|0 | \
cut -d   -f1)}   # allowed filesystems
 : ${find:=find}
 
-case X$SEARCHPATHS in 
-   X) echo $0: empty variable SEARCHPATHS; exit 1;; esac
-case X$FILESYSTEMS in 
-   X) echo $0: empty variable FILESYSTEMS; exit 1;; esac
+if [ -z $SEARCHPATHS ]; then
+   echo $0: empty variable SEARCHPATHS 2; exit 1
+fi
+if [ -z $FILESYSTEMS ]; then
+   echo $0: empty variable FILESYSTEMS 2; exit 1
+fi
 
 # Make a list a paths to exclude in the locate run
 excludes=! ( or=
@@ -71,25 +74,29 @@ do
 done
 excludes=$excludes ) -prune
 
-case X$PRUNEPATHS in
-   X) ;;
-   *) for path in $PRUNEPATHS
-   do 
+if [ -n $PRUNEPATHS ]; then
+   for path in $PRUNEPATHS; do 
excludes=$excludes -or -path $path -prune
-  done;;
-esac
+   done
+fi
+
+if [ -n $PRUNEDIRS ]; then
+   for dir in $PRUNEDIRS; do
+   excludes=$excludes -or -name $dir -type d -prune
+   done
+fi
 
 tmp=$TMPDIR/_updatedb$$
 trap 'rm -f $tmp; rmdir $TMPDIR' 0 1 2 3 5 10 15

 # search locally
-# echo $find $SEARCHPATHS $excludes -or -print  exit
 if $find -s $SEARCHPATHS $excludes -or -print 

svn commit: r214613 - head/usr.bin/locate/locate

2010-10-31 Thread Garrett Wollman
Author: wollman
Date: Mon Nov  1 01:51:47 2010
New Revision: 214613
URL: http://svn.freebsd.org/changeset/base/214613

Log:
  jilles@ pointed out that using ${PRUNEDIRS:=.zfs} in updatedb.sh
  made it impossible to override PRUNEDIRS to make it empty.  Use the
  non-colon form to only set PRUNEDIRS if it is completely unset.  (For
  parallelism, the other configuration defaults here could be done the
  same way, but that could be more obviously accomplished by disabling
  updatedb in periodic.conf, so leave them alone for now.)

Modified:
  head/usr.bin/locate/locate/updatedb.sh

Modified: head/usr.bin/locate/locate/updatedb.sh
==
--- head/usr.bin/locate/locate/updatedb.sh  Mon Nov  1 01:03:05 2010
(r214612)
+++ head/usr.bin/locate/locate/updatedb.sh  Mon Nov  1 01:51:47 2010
(r214613)
@@ -52,7 +52,7 @@ PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; ex
 : ${FCODES:=/var/db/locate.database}# the database
 : ${SEARCHPATHS:=/}  # directories to be put in the database
 : ${PRUNEPATHS:=/tmp /usr/tmp /var/tmp /var/db/portsnap} # unwanted 
directories
-: ${PRUNEDIRS:=.zfs} # unwanted directories, in any parent
+: ${PRUNEDIRS=.zfs}  # unwanted directories, in any parent
 : ${FILESYSTEMS:=$(lsvfs | tail -n +3 | \
egrep -vw loopback|network|synthetic|read-only|0 | \
cut -d   -f1)}   # allowed filesystems
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r214613 - head/usr.bin/locate/locate

2010-10-31 Thread Garrett Wollman
On Mon, 1 Nov 2010 01:51:47 + (UTC), Garrett Wollman 
woll...@freebsd.org said:

   jilles@ pointed out that using ${PRUNEDIRS:=.zfs} in updatedb.sh
   made it impossible to override PRUNEDIRS to make it empty.  Use the
   non-colon form to only set PRUNEDIRS if it is completely unset.  (For
   parallelism, the other configuration defaults here could be done the
   same way, but that could be more obviously accomplished by disabling
   updatedb in periodic.conf, so leave them alone for now.)

With this change, you can now make the locate database once again
include all of your mounted ZFS snapshots by setting PRUNEDIRS= in
your /etc/locate.rc.

-GAWollman
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r214615 - head/usr.bin/locate/locate

2010-10-31 Thread Garrett Wollman
Author: wollman
Date: Mon Nov  1 02:20:18 2010
New Revision: 214615
URL: http://svn.freebsd.org/changeset/base/214615

Log:
  Style cleanup: make this look more like a 21st-century shell script
  and not something out of the early 1980s.  Make sure all error
  messages go to stderr, not stdout.  Since there's error-handling code
  to handle empty SEARCHPATHS and FILESYSTEMS, use the initialization
  form that allows this error to be diagnosed.  (hat tip: jilles@)

Modified:
  head/usr.bin/locate/locate/updatedb.sh

Modified: head/usr.bin/locate/locate/updatedb.sh
==
--- head/usr.bin/locate/locate/updatedb.sh  Mon Nov  1 01:55:15 2010
(r214614)
+++ head/usr.bin/locate/locate/updatedb.sh  Mon Nov  1 02:20:18 2010
(r214615)
@@ -50,18 +50,20 @@ PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; ex
 
 : ${mklocatedb:=locate.mklocatedb}  # make locate database program
 : ${FCODES:=/var/db/locate.database}# the database
-: ${SEARCHPATHS:=/}  # directories to be put in the database
-: ${PRUNEPATHS:=/tmp /usr/tmp /var/tmp /var/db/portsnap} # unwanted 
directories
+: ${SEARCHPATHS=/}   # directories to be put in the database
+: ${PRUNEPATHS=/tmp /usr/tmp /var/tmp /var/db/portsnap} # unwanted 
directories
 : ${PRUNEDIRS=.zfs}  # unwanted directories, in any parent
-: ${FILESYSTEMS:=$(lsvfs | tail -n +3 | \
+: ${FILESYSTEMS=$(lsvfs | tail -n +3 | \
egrep -vw loopback|network|synthetic|read-only|0 | \
cut -d   -f1)}   # allowed filesystems
 : ${find:=find}
 
-case X$SEARCHPATHS in 
-   X) echo $0: empty variable SEARCHPATHS; exit 1;; esac
-case X$FILESYSTEMS in 
-   X) echo $0: empty variable FILESYSTEMS; exit 1;; esac
+if [ -z $SEARCHPATHS ]; then
+   echo $0: empty variable SEARCHPATHS 2; exit 1
+fi
+if [ -z $FILESYSTEMS ]; then
+   echo $0: empty variable FILESYSTEMS 2; exit 1
+fi
 
 # Make a list a paths to exclude in the locate run
 excludes=! ( or=
@@ -72,33 +74,29 @@ do
 done
 excludes=$excludes ) -prune
 
-case X$PRUNEPATHS in
-   X) ;;
-   *) for path in $PRUNEPATHS
-   do 
+if [ -n $PRUNEPATHS ]; then
+   for path in $PRUNEPATHS; do 
excludes=$excludes -or -path $path -prune
-  done;;
-esac
+   done
+fi
 
-case X$PRUNEDIRS in
-   X) ;;
-   *) for dir in $PRUNEDIRS
-  do
+if [ -n $PRUNEDIRS ]; then
+   for dir in $PRUNEDIRS; do
excludes=$excludes -or -name $dir -type d -prune
-  done;;
-esac
+   done
+fi
 
 tmp=$TMPDIR/_updatedb$$
 trap 'rm -f $tmp; rmdir $TMPDIR' 0 1 2 3 5 10 15

 # search locally
-# echo $find $SEARCHPATHS $excludes -or -print  exit
 if $find -s $SEARCHPATHS $excludes -or -print 2/dev/null |
 $mklocatedb -presort  $tmp
 then
-   case X`$find $tmp -size -257c -print` in
-   X) cat $tmp  $FCODES;;
-   *) echo updatedb: locate database $tmp is empty
-  exit 1
-   esac
+   if [ -n $($find $tmp -size -257c -print) ]; then
+   echo updatedb: locate database $tmp is empty 2
+   exit 1
+   else
+   cat $tmp  $FCODES  # should be cp?
+   fi
 fi
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r200369 - in head: etc share/termcap

2009-12-13 Thread Garrett Wollman
On Sun, 13 Dec 2009 13:03:42 +0100, Dag-Erling Smørgrav d...@des.no said:

 It's not what Linux does, it's what xterm does.

It's also, not to put too fine a point on it, obnoxious and stupid.

Let's please have the useful behavior.  There's a good reason why
our xterm termcap entry has never had this bogus behavior enabled
(except for brief periods after someone updates termcap).

-GAWollman

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r200369 - in head: etc share/termcap

2009-12-11 Thread Garrett Wollman
On Sat, 12 Dec 2009 03:20:07 +0900, Hajimu UMEMOTO u...@freebsd.org said:

 It's great, thank!!
 I believe that our xterm entry was modified not to clear screen when
 applications such as less(1) are terminated.  Are there any chance to
 back to the behavior?

aol/

I don't understand why people put up with the unspeakably obnoxious
alternate screen behavior.  Please don't tell me someone actually
thinks it's *useful*.

-GAWollman

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r200274 - head/lib/libc/gen

2009-12-11 Thread Garrett Wollman
On Thu, 10 Dec 2009 00:24:28 + (GMT), Robert Watson rwat...@freebsd.org 
said:

 It's beginning to sound like our POSIX semaphores should be behaving more 
 like 
 umtx, which requires only a shared page, and less like file descriptors.  Of 
 course, that would make the global namespace more tricky...

Ultimately, the problem is that POSIX semaphores are actually three
different kinds of object, which just happen to ostensibly use the
same programming interface.

-GAWollman

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r200016 - in stable/8/lib/libc: gen rpc stdio yp

2009-12-01 Thread Garrett Wollman
Author: wollman
Date: Wed Dec  2 02:47:29 2009
New Revision: 200016
URL: http://svn.freebsd.org/changeset/base/200016

Log:
  MFC revs 199781,199782,199784,199785,199786:
  
Eliminate dead stores.
  
In __mbsconv(), if prec was zero, nconv could have been used
uninitialized.  Initialize it to a safe value so that there's no
chance of returning an error if stack garbage happens to be equal to
(size_t)-1 or (size_t)-2.
  
In svc_raw_reply(), don't leave stat uninitialized if the MSG_ACCEPTED
 SUCCESS case succeeds.  The stack garbage might be zero.
  
In clnt_raw_create(), avoid minor race condition initializing the
file-scope variable clntraw_private.
  
  Found by: Clang static analyzer

Modified:
  stable/8/lib/libc/gen/getcap.c
  stable/8/lib/libc/gen/getusershell.c
  stable/8/lib/libc/gen/wordexp.c
  stable/8/lib/libc/rpc/clnt_raw.c
  stable/8/lib/libc/rpc/getnetconfig.c
  stable/8/lib/libc/rpc/key_call.c
  stable/8/lib/libc/rpc/svc_raw.c
  stable/8/lib/libc/stdio/fgetws.c
  stable/8/lib/libc/stdio/fvwrite.c
  stable/8/lib/libc/stdio/vfwprintf.c
  stable/8/lib/libc/yp/yplib.c
Directory Properties:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)

Modified: stable/8/lib/libc/gen/getcap.c
==
--- stable/8/lib/libc/gen/getcap.c  Wed Dec  2 00:38:11 2009
(r200015)
+++ stable/8/lib/libc/gen/getcap.c  Wed Dec  2 02:47:29 2009
(r200016)
@@ -647,7 +647,7 @@ int
 cgetnext(char **bp, char **db_array)
 {
size_t len;
-   int done, hadreaderr, i, savederrno, status;
+   int done, hadreaderr, savederrno, status;
char *cp, *line, *rp, *np, buf[BSIZE], nbuf[BSIZE];
u_int dummy;
 
@@ -658,7 +658,7 @@ cgetnext(char **bp, char **db_array)
(void)cgetclose();
return (-1);
}
-   for(;;) {
+   for (;;) {
if (toprec  !gottoprec) {
gottoprec = 1;
line = toprec;
@@ -709,7 +709,6 @@ cgetnext(char **bp, char **db_array)
/*
 * Line points to a name line.
 */
-   i = 0;
done = 0;
np = nbuf;
for (;;) {

Modified: stable/8/lib/libc/gen/getusershell.c
==
--- stable/8/lib/libc/gen/getusershell.cWed Dec  2 00:38:11 2009
(r200015)
+++ stable/8/lib/libc/gen/getusershell.cWed Dec  2 02:47:29 2009
(r200016)
@@ -124,7 +124,7 @@ _local_initshells(rv, cb_data, ap)
if ((fp = fopen(_PATH_SHELLS, r)) == NULL)
return NS_UNAVAIL;
 
-   sp = cp = line;
+   cp = line;
while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
while (*cp != '#'  *cp != '/'  *cp != '\0')
cp++;

Modified: stable/8/lib/libc/gen/wordexp.c
==
--- stable/8/lib/libc/gen/wordexp.c Wed Dec  2 00:38:11 2009
(r200015)
+++ stable/8/lib/libc/gen/wordexp.c Wed Dec  2 02:47:29 2009
(r200016)
@@ -282,7 +282,7 @@ we_check(const char *words, int flags)
if (c == '\0' || level != 0)
return (WRDE_SYNTAX);
} else
-   c = *--words;
+   --words;
break;
default:
break;

Modified: stable/8/lib/libc/rpc/clnt_raw.c
==
--- stable/8/lib/libc/rpc/clnt_raw.cWed Dec  2 00:38:11 2009
(r200015)
+++ stable/8/lib/libc/rpc/clnt_raw.cWed Dec  2 02:47:29 2009
(r200016)
@@ -92,13 +92,13 @@ clnt_raw_create(prog, vers)
rpcprog_t prog;
rpcvers_t vers;
 {
-   struct clntraw_private *clp = clntraw_private;
+   struct clntraw_private *clp;
struct rpc_msg call_msg;
-   XDR *xdrs = clp-xdr_stream;
-   CLIENT  *client = clp-client_object;
+   XDR *xdrs;
+   CLIENT  *client;
 
mutex_lock(clntraw_lock);
-   if (clp == NULL) {
+   if ((clp = clntraw_private) == NULL) {
clp = (struct clntraw_private *)calloc(1, sizeof (*clp));
if (clp == NULL) {
mutex_unlock(clntraw_lock);
@@ -110,6 +110,9 @@ clnt_raw_create(prog, vers)
clp-_raw_buf = __rpc_rawcombuf;
clntraw_private = clp;
}
+   xdrs = clp-xdr_stream;
+   client = clp-client_object;
+
/*
 * pre-serialize the static part of the call msg and stash it away
 */

Modified: stable/8/lib/libc/rpc/getnetconfig.c

svn commit: r200017 - in stable/7/lib/libc: gen rpc stdio yp

2009-12-01 Thread Garrett Wollman
Author: wollman
Date: Wed Dec  2 03:08:29 2009
New Revision: 200017
URL: http://svn.freebsd.org/changeset/base/200017

Log:
  MFC revs 199781,199782,199784,199786:
  
Eliminate dead stores.
  
In __mbsconv(), if prec was zero, nconv could have been used
uninitialized.  Initialize it to a safe value so that there's no
chance of returning an error if stack garbage happens to be equal to
(size_t)-1 or (size_t)-2.
  
In clnt_raw_create(), avoid minor race condition initializing the
file-scope variable clntraw_private.
  
  Mark head rev 199785 as merged; 7-STABLE's version of svc_raw_reply()
  doesn't have the same bug (or even look all that similar).
  
  Found by: Clang static analyzer

Modified:
  stable/7/lib/libc/gen/getcap.c
  stable/7/lib/libc/gen/getusershell.c
  stable/7/lib/libc/gen/wordexp.c
  stable/7/lib/libc/rpc/clnt_raw.c
  stable/7/lib/libc/rpc/getnetconfig.c
  stable/7/lib/libc/rpc/key_call.c
  stable/7/lib/libc/stdio/fgetws.c
  stable/7/lib/libc/stdio/fvwrite.c
  stable/7/lib/libc/stdio/vfwprintf.c
  stable/7/lib/libc/yp/yplib.c
Directory Properties:
  stable/7/lib/libc/   (props changed)

Modified: stable/7/lib/libc/gen/getcap.c
==
--- stable/7/lib/libc/gen/getcap.c  Wed Dec  2 02:47:29 2009
(r200016)
+++ stable/7/lib/libc/gen/getcap.c  Wed Dec  2 03:08:29 2009
(r200017)
@@ -647,7 +647,7 @@ int
 cgetnext(char **bp, char **db_array)
 {
size_t len;
-   int done, hadreaderr, i, savederrno, status;
+   int done, hadreaderr, savederrno, status;
char *cp, *line, *rp, *np, buf[BSIZE], nbuf[BSIZE];
u_int dummy;
 
@@ -658,7 +658,7 @@ cgetnext(char **bp, char **db_array)
(void)cgetclose();
return (-1);
}
-   for(;;) {
+   for (;;) {
if (toprec  !gottoprec) {
gottoprec = 1;
line = toprec;
@@ -709,7 +709,6 @@ cgetnext(char **bp, char **db_array)
/*
 * Line points to a name line.
 */
-   i = 0;
done = 0;
np = nbuf;
for (;;) {

Modified: stable/7/lib/libc/gen/getusershell.c
==
--- stable/7/lib/libc/gen/getusershell.cWed Dec  2 02:47:29 2009
(r200016)
+++ stable/7/lib/libc/gen/getusershell.cWed Dec  2 03:08:29 2009
(r200017)
@@ -124,7 +124,7 @@ _local_initshells(rv, cb_data, ap)
if ((fp = fopen(_PATH_SHELLS, r)) == NULL)
return NS_UNAVAIL;
 
-   sp = cp = line;
+   cp = line;
while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
while (*cp != '#'  *cp != '/'  *cp != '\0')
cp++;

Modified: stable/7/lib/libc/gen/wordexp.c
==
--- stable/7/lib/libc/gen/wordexp.c Wed Dec  2 02:47:29 2009
(r200016)
+++ stable/7/lib/libc/gen/wordexp.c Wed Dec  2 03:08:29 2009
(r200017)
@@ -282,7 +282,7 @@ we_check(const char *words, int flags)
if (c == '\0' || level != 0)
return (WRDE_SYNTAX);
} else
-   c = *--words;
+   --words;
break;
default:
break;

Modified: stable/7/lib/libc/rpc/clnt_raw.c
==
--- stable/7/lib/libc/rpc/clnt_raw.cWed Dec  2 02:47:29 2009
(r200016)
+++ stable/7/lib/libc/rpc/clnt_raw.cWed Dec  2 03:08:29 2009
(r200017)
@@ -92,13 +92,13 @@ clnt_raw_create(prog, vers)
rpcprog_t prog;
rpcvers_t vers;
 {
-   struct clntraw_private *clp = clntraw_private;
+   struct clntraw_private *clp;
struct rpc_msg call_msg;
-   XDR *xdrs = clp-xdr_stream;
-   CLIENT  *client = clp-client_object;
+   XDR *xdrs;
+   CLIENT  *client;
 
mutex_lock(clntraw_lock);
-   if (clp == NULL) {
+   if ((clp = clntraw_private) == NULL) {
clp = (struct clntraw_private *)calloc(1, sizeof (*clp));
if (clp == NULL) {
mutex_unlock(clntraw_lock);
@@ -110,6 +110,9 @@ clnt_raw_create(prog, vers)
clp-_raw_buf = __rpc_rawcombuf;
clntraw_private = clp;
}
+   xdrs = clp-xdr_stream;
+   client = clp-client_object;
+
/*
 * pre-serialize the static part of the call msg and stash it away
 */

Modified: stable/7/lib/libc/rpc/getnetconfig.c
==
--- stable/7/lib/libc/rpc/getnetconfig.cWed Dec  2 02:47:29 2009

svn commit: r199781 - head/lib/libc/stdio

2009-11-24 Thread Garrett Wollman
Author: wollman
Date: Wed Nov 25 04:21:42 2009
New Revision: 199781
URL: http://svn.freebsd.org/changeset/base/199781

Log:
  Eliminate dead store.
  
  Found by: Clang static analyzer
  MFC after:7 days

Modified:
  head/lib/libc/stdio/fvwrite.c

Modified: head/lib/libc/stdio/fvwrite.c
==
--- head/lib/libc/stdio/fvwrite.c   Wed Nov 25 02:39:33 2009
(r199780)
+++ head/lib/libc/stdio/fvwrite.c   Wed Nov 25 04:21:42 2009
(r199781)
@@ -60,7 +60,7 @@ __sfvwrite(fp, uio)
char *nl;
int nlknown, nldist;
 
-   if ((len = uio-uio_resid) == 0)
+   if (uio-uio_resid == 0)
return (0);
/* make sure we can write */
if (prepwrite(fp) != 0)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r199782 - head/lib/libc/stdio

2009-11-24 Thread Garrett Wollman
Author: wollman
Date: Wed Nov 25 04:27:55 2009
New Revision: 199782
URL: http://svn.freebsd.org/changeset/base/199782

Log:
  In __mbsconv(), if prec was zero, nconv could have been used
  uninitialized.  Initialize it to a safe value so that there's no
  chance of returning an error if stack garbage happens to be equal to
  (size_t)-1 or (size_t)-2.
  
  Found by: Clang static analyzer
  MFC after:7 days

Modified:
  head/lib/libc/stdio/vfwprintf.c

Modified: head/lib/libc/stdio/vfwprintf.c
==
--- head/lib/libc/stdio/vfwprintf.c Wed Nov 25 04:21:42 2009
(r199781)
+++ head/lib/libc/stdio/vfwprintf.c Wed Nov 25 04:27:55 2009
(r199782)
@@ -293,7 +293,7 @@ __mbsconv(char *mbsarg, int prec)
 * number of characters to print.
 */
p = mbsarg;
-   insize = nchars = 0;
+   insize = nchars = nconv = 0;
mbs = initial_mbs;
while (nchars != (size_t)prec) {
nconv = mbrlen(p, MB_CUR_MAX, mbs);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r199783 - head/lib/libc/stdio

2009-11-24 Thread Garrett Wollman
Author: wollman
Date: Wed Nov 25 04:35:54 2009
New Revision: 199783
URL: http://svn.freebsd.org/changeset/base/199783

Log:
  Make all three if conditions look similar by always initializing nsec
  and moving the default initialization of prec into the else clause.
  The clang static analyzer erroneously thought that nsec can be used
  uninitialized here; it was not actually possible, but better to make
  the code clearer.  (Clang can't know that sprintf() won't modify *pi
  behind the scenes.)

Modified:
  head/lib/libc/stdio/xprintf_time.c

Modified: head/lib/libc/stdio/xprintf_time.c
==
--- head/lib/libc/stdio/xprintf_time.c  Wed Nov 25 04:27:55 2009
(r199782)
+++ head/lib/libc/stdio/xprintf_time.c  Wed Nov 25 04:35:54 2009
(r199783)
@@ -64,7 +64,6 @@ __printf_render_time(struct __printf_io 
intmax_t t, tx;
int i, prec, nsec;
 
-   prec = 0;
if (pi-is_long) {
tv = *((struct timeval **)arg[0]);
t = tv-tv_sec;
@@ -78,6 +77,8 @@ __printf_render_time(struct __printf_io 
} else {
tp = *((time_t **)arg[0]);
t = *tp;
+   nsec = 0;
+   prec = 0;
}
 
p = buf;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r199784 - in head/lib/libc: gen rpc stdio yp

2009-11-24 Thread Garrett Wollman
Author: wollman
Date: Wed Nov 25 04:45:45 2009
New Revision: 199784
URL: http://svn.freebsd.org/changeset/base/199784

Log:
  Eliminate more dead stores.
  
  Found by: Clang static analyzer
  MFC after:7 days

Modified:
  head/lib/libc/gen/getcap.c
  head/lib/libc/gen/getusershell.c
  head/lib/libc/gen/wordexp.c
  head/lib/libc/rpc/getnetconfig.c
  head/lib/libc/rpc/key_call.c
  head/lib/libc/stdio/fgetws.c
  head/lib/libc/yp/yplib.c

Modified: head/lib/libc/gen/getcap.c
==
--- head/lib/libc/gen/getcap.c  Wed Nov 25 04:35:54 2009(r199783)
+++ head/lib/libc/gen/getcap.c  Wed Nov 25 04:45:45 2009(r199784)
@@ -647,7 +647,7 @@ int
 cgetnext(char **bp, char **db_array)
 {
size_t len;
-   int done, hadreaderr, i, savederrno, status;
+   int done, hadreaderr, savederrno, status;
char *cp, *line, *rp, *np, buf[BSIZE], nbuf[BSIZE];
u_int dummy;
 
@@ -658,7 +658,7 @@ cgetnext(char **bp, char **db_array)
(void)cgetclose();
return (-1);
}
-   for(;;) {
+   for (;;) {
if (toprec  !gottoprec) {
gottoprec = 1;
line = toprec;
@@ -709,7 +709,6 @@ cgetnext(char **bp, char **db_array)
/*
 * Line points to a name line.
 */
-   i = 0;
done = 0;
np = nbuf;
for (;;) {

Modified: head/lib/libc/gen/getusershell.c
==
--- head/lib/libc/gen/getusershell.cWed Nov 25 04:35:54 2009
(r199783)
+++ head/lib/libc/gen/getusershell.cWed Nov 25 04:45:45 2009
(r199784)
@@ -124,7 +124,7 @@ _local_initshells(rv, cb_data, ap)
if ((fp = fopen(_PATH_SHELLS, r)) == NULL)
return NS_UNAVAIL;
 
-   sp = cp = line;
+   cp = line;
while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
while (*cp != '#'  *cp != '/'  *cp != '\0')
cp++;

Modified: head/lib/libc/gen/wordexp.c
==
--- head/lib/libc/gen/wordexp.c Wed Nov 25 04:35:54 2009(r199783)
+++ head/lib/libc/gen/wordexp.c Wed Nov 25 04:45:45 2009(r199784)
@@ -320,7 +320,7 @@ we_check(const char *words, int flags)
if (c == '\0' || level != 0)
return (WRDE_SYNTAX);
} else
-   c = *--words;
+   --words;
break;
default:
break;

Modified: head/lib/libc/rpc/getnetconfig.c
==
--- head/lib/libc/rpc/getnetconfig.cWed Nov 25 04:35:54 2009
(r199783)
+++ head/lib/libc/rpc/getnetconfig.cWed Nov 25 04:45:45 2009
(r199784)
@@ -412,13 +412,13 @@ void *handlep;
  * Noone needs these entries anymore, then frees them.
  * Make sure all info in netconfig_info structure has been reinitialized.
  */
-q = p = ni.head;
+q = ni.head;
 ni.eof = ni.ref = 0;
 ni.head = NULL;
 ni.tail = NULL;
 mutex_unlock(ni_lock);
 
-while (q) {
+while (q != NULL) {
p = q-next;
if (q-ncp-nc_lookups != NULL) free(q-ncp-nc_lookups);
free(q-ncp);

Modified: head/lib/libc/rpc/key_call.c
==
--- head/lib/libc/rpc/key_call.cWed Nov 25 04:35:54 2009
(r199783)
+++ head/lib/libc/rpc/key_call.cWed Nov 25 04:45:45 2009
(r199784)
@@ -302,7 +302,7 @@ int vers;
void *localhandle;
struct netconfig *nconf;
struct netconfig *tpconf;
-   struct key_call_private *kcp = key_call_private_main;
+   struct key_call_private *kcp;
struct timeval wait_time;
struct utsname u;
int main_thread;

Modified: head/lib/libc/stdio/fgetws.c
==
--- head/lib/libc/stdio/fgetws.cWed Nov 25 04:35:54 2009
(r199783)
+++ head/lib/libc/stdio/fgetws.cWed Nov 25 04:45:45 2009
(r199784)
@@ -89,7 +89,7 @@ fgetws(wchar_t * __restrict ws, int n, F
if (!__mbsinit(fp-_mbstate))
/* Incomplete character */
goto error;
-   *wsp++ = L'\0';
+   *wsp = L'\0';
FUNLOCKFILE(fp);
 
return (ws);

Modified: head/lib/libc/yp/yplib.c
==
--- head/lib/libc/yp/yplib.cWed Nov 25 04:35:54 2009(r199783)
+++ head/lib/libc/yp/yplib.cWed Nov 25 04:45:45 2009(r199784)
@@ -241,7 +241,7 @@ static bool_t
 

svn commit: r199785 - head/lib/libc/rpc

2009-11-24 Thread Garrett Wollman
Author: wollman
Date: Wed Nov 25 04:49:41 2009
New Revision: 199785
URL: http://svn.freebsd.org/changeset/base/199785

Log:
  In svc_raw_reply(), don't leave stat uninitialized if the MSG_ACCEPTED
   SUCCESS case succeeds.  The stack garbage might be zero.
  
  Found by: Clang static analyzer
  MFC after:7 days

Modified:
  head/lib/libc/rpc/svc_raw.c

Modified: head/lib/libc/rpc/svc_raw.c
==
--- head/lib/libc/rpc/svc_raw.c Wed Nov 25 04:45:45 2009(r199784)
+++ head/lib/libc/rpc/svc_raw.c Wed Nov 25 04:49:41 2009(r199785)
@@ -176,9 +176,8 @@ svc_raw_reply(xprt, msg)
msg-acpted_rply.ar_results.proc = (xdrproc_t) xdr_void;
msg-acpted_rply.ar_results.where = NULL;
 
-   if (!xdr_replymsg(xdrs, msg) ||
-   !SVCAUTH_WRAP(SVC_AUTH(xprt), xdrs, xdr_proc, xdr_where))
-   stat = FALSE;
+   stat = xdr_replymsg(xdrs, msg) 
+   SVCAUTH_WRAP(SVC_AUTH(xprt), xdrs, xdr_proc, xdr_where);
} else {
stat = xdr_replymsg(xdrs, msg);
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r199786 - head/lib/libc/rpc

2009-11-24 Thread Garrett Wollman
Author: wollman
Date: Wed Nov 25 04:52:12 2009
New Revision: 199786
URL: http://svn.freebsd.org/changeset/base/199786

Log:
  In clnt_raw_create(), avoid minor race condition initializing the
  file-scope variable clntraw_private.
  
  Found by: Clang static analyzer
  MFC after:7 days

Modified:
  head/lib/libc/rpc/clnt_raw.c

Modified: head/lib/libc/rpc/clnt_raw.c
==
--- head/lib/libc/rpc/clnt_raw.cWed Nov 25 04:49:41 2009
(r199785)
+++ head/lib/libc/rpc/clnt_raw.cWed Nov 25 04:52:12 2009
(r199786)
@@ -92,13 +92,13 @@ clnt_raw_create(prog, vers)
rpcprog_t prog;
rpcvers_t vers;
 {
-   struct clntraw_private *clp = clntraw_private;
+   struct clntraw_private *clp;
struct rpc_msg call_msg;
-   XDR *xdrs = clp-xdr_stream;
-   CLIENT  *client = clp-client_object;
+   XDR *xdrs;
+   CLIENT  *client;
 
mutex_lock(clntraw_lock);
-   if (clp == NULL) {
+   if ((clp = clntraw_private) == NULL) {
clp = (struct clntraw_private *)calloc(1, sizeof (*clp));
if (clp == NULL) {
mutex_unlock(clntraw_lock);
@@ -110,6 +110,9 @@ clnt_raw_create(prog, vers)
clp-_raw_buf = __rpc_rawcombuf;
clntraw_private = clp;
}
+   xdrs = clp-xdr_stream;
+   client = clp-client_object;
+
/*
 * pre-serialize the static part of the call msg and stash it away
 */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r199787 - head/lib/libc/rpc

2009-11-24 Thread Garrett Wollman
Author: wollman
Date: Wed Nov 25 04:53:38 2009
New Revision: 199787
URL: http://svn.freebsd.org/changeset/base/199787

Log:
  Style: use structure assignment rather than memcpy() to copy a
  structure.

Modified:
  head/lib/libc/rpc/getrpcent.c

Modified: head/lib/libc/rpc/getrpcent.c
==
--- head/lib/libc/rpc/getrpcent.c   Wed Nov 25 04:52:12 2009
(r199786)
+++ head/lib/libc/rpc/getrpcent.c   Wed Nov 25 04:53:38 2009
(r199787)
@@ -698,7 +698,7 @@ rpc_marshal_func(char *buffer, size_t *b
return (NS_RETURN);
}
 
-   memcpy(new_rpc, rpc, sizeof(struct rpcent));
+   new_rpc = *rpc;
 
*buffer_size = desired_size;
memset(buffer, 0, desired_size);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn: head/usr.sbin/mergemaster

2009-01-02 Thread Garrett Wollman
On Fri, 02 Jan 2009 15:07:55 -0800, Doug Barton do...@freebsd.org said:

 Garrett Wollman wrote:
 It would be much better if the options that *nearly every user will
 want to use* are set correctly by default. 

 1. Past experience indicates that your average _developer_ is not very
 good at estimating what the average _user_ will want as the default.

Speaking as a user, far more than a developer these days, what
mergemaster does by default is not what I want.  I have about half a
dozen FreeBSD systems in various states of production, and they get
upgraded about once a year, if that, and always run the security
branch.

 4. I have said literally from day 1 that mergemaster should not ever
 change a file on a user's system without them taking an affirmative
 step for it to do so. Whether you agree with that idea or not, it is
 an expectation that I do not want to mess with.

Does anyone else have that expectation, or do they think of it as an
annoying quirk of the program and wish the author would make it be
more helpful by default?  Is there any evidence that the current
default behavior is the Right Thing for the typical user?  (Serious
question.  Maybe it solves some problem that's not the one that I
have; I haven't done a survey.)

-GAWollman
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r186401 - head/usr.bin/ncal

2008-12-22 Thread Garrett Wollman
Author: wollman
Date: Mon Dec 22 21:22:42 2008
New Revision: 186401
URL: http://svn.freebsd.org/changeset/base/186401

Log:
  Implement a new feature for the -m option: if the month number is
  followed by 'f' or 'p', use the following or preceding month of that
  number, respectively.  Document this.  Also includes other minor
  grammatical and punctuation fixes to the manual page (capitalize
  Easter, etc.).
  
  MFC after:1 month

Modified:
  head/usr.bin/ncal/ncal.1
  head/usr.bin/ncal/ncal.c

Modified: head/usr.bin/ncal/ncal.1
==
--- head/usr.bin/ncal/ncal.1Mon Dec 22 20:38:00 2008(r186400)
+++ head/usr.bin/ncal/ncal.1Mon Dec 22 21:22:42 2008(r186401)
@@ -30,7 +30,7 @@
 .Sh NAME
 .Nm cal ,
 .Nm ncal
-.Nd displays a calendar and the date of easter
+.Nd displays a calendar and the date of Easter
 .Sh SYNOPSIS
 .Nm
 .Op Fl jy
@@ -57,7 +57,7 @@ The
 .Nm
 utility displays a simple calendar in traditional format and
 .Nm ncal
-offers an alternative layout, more options and the date of easter.
+offers an alternative layout, more options and the date of Easter.
 The new format is a little cramped but it makes a year fit
 on a 25x80 terminal.
 If arguments are not specified,
@@ -68,16 +68,24 @@ The options are as follows:
 .It Fl J
 Display Julian Calendar, if combined with the
 .Fl e
-option, display date of easter according to the Julian Calendar.
+option, display date of Easter according to the Julian Calendar.
 .It Fl e
-Display date of easter (for western churches).
+Display date of Easter (for western churches).
 .It Fl j
 Display Julian days (days one-based, numbered from January 1).
 .It Fl m Ar month
 Display the specified
 .Ar month .
+If
+.Ar month
+is specified as a decimal number, it may be followed by the letter
+.Ql f
+or
+.Ql p
+to indicate the following or preceding month of that number,
+respectively.
 .It Fl o
-Display date of orthodox easter (Greek and Russian
+Display date of Orthodox Easter (Greek and Russian
 Orthodox Churches).
 .It Fl p
 Print the country codes and switching days from Julian to Gregorian
@@ -101,7 +109,7 @@ Print the number of the week below each 
 Display a calendar for the specified year.
 .El
 .Pp
-A single parameter specifies the year (1 - ) to be displayed;
+A single parameter specifies the year (1\(en) to be displayed;
 note the year must be fully specified:
 .Dq Li cal 89
 will
@@ -113,7 +121,7 @@ Month and year default to those of the c
 .Dq Li cal -m 8
 will display a calendar for the month of August in the current year).
 .Pp
-A year starts on Jan 1.
+A year starts on January 1.
 .Sh SEE ALSO
 .Xr calendar 3 ,
 .Xr strftime 3
@@ -132,7 +140,7 @@ The
 command and manual were written by
 .An Wolfgang Helbig Aq hel...@freebsd.org .
 .Sh BUGS
-The assignment of Julian\(emGregorian switching dates to
+The assignment of Julian\(enGregorian switching dates to
 country codes is historically naive for many countries.
 .Pp
 The

Modified: head/usr.bin/ncal/ncal.c
==
--- head/usr.bin/ncal/ncal.cMon Dec 22 20:38:00 2008(r186400)
+++ head/usr.bin/ncal/ncal.cMon Dec 22 21:22:42 2008(r186401)
@@ -162,7 +162,7 @@ char   *center(char *s, char *t, int w);
 void   mkmonth(int year, int month, int jd_flag, struct monthlines * monthl);
 voidmkmonthb(int year, int month, int jd_flag, struct monthlines * monthl);
 voidmkweekdays(struct weekdays * wds);
-int parsemonth(const char *s);
+int parsemonth(const char *s, int *m, int *y);
 voidprintcc(void);
 voidprinteaster(int year, int julian, int orthodox);
 voidprintmonth(int year, int month, int jd_flag);
@@ -322,11 +322,11 @@ main(int argc, char *argv[])
}
 
if (flag_month != NULL) {
-   m = parsemonth(flag_month);
-   if (m  1 || m  12)
+   if (parsemonth(flag_month, m, y)) {
errx(EX_USAGE,
%s is neither a month number (1..12) nor a name,
flag_month);
+   }
}
 
if (flag_easter)
@@ -859,18 +859,34 @@ center(char *s, char *t, int w)
 }
 
 int
-parsemonth(const char *s)
+parsemonth(const char *s, int *m, int *y)
 {
-   int v;
+   int nm, ny;
char *cp;
struct tm tm;
 
-   v = (int)strtol(s, cp, 10);
-   if (cp != s)
-   return (v);
-   if (strptime(s, %B, tm) != NULL)
-   return (tm.tm_mon + 1);
-   if (strptime(s, %b, tm) != NULL)
-   return (tm.tm_mon + 1);
-   return (0);
+   nm = (int)strtol(s, cp, 10);
+   if (cp != s) {
+   ny = *y;
+   if (*cp == '\0') {
+   ;   /* no special action */
+   } else if (*cp == 'f' || *cp == 'F') {
+   if (nm = *m)
+