[patch] Fix memory leak in dmeg.c

2017-08-31 Thread Nan Xiao
Hi tech@,

I am not a nitpicker. Though all memory will be reclaimed after process
exits, I still think it's a good habit to release all memory in heap.

Best Regards
Nan Xiao

Index: dmesg.c
===
RCS file: /cvs/src/sbin/dmesg/dmesg.c,v
retrieving revision 1.28
diff -u -p -r1.28 dmesg.c
--- dmesg.c 26 Aug 2017 08:53:20 - 1.28
+++ dmesg.c 31 Aug 2017 14:22:27 -
@@ -34,6 +34,7 @@
 #include 
 #include 

+#include 
 #include 
 #include 
 #include 
@@ -183,6 +184,14 @@ main(int argc, char *argv[])
  }
  if (!newl)
  putchar('\n');
+
+ if (memf == NULL && nlistf == NULL)
+ free(bufdata - offsetof(struct msgbuf, msg_bufc));
+ else {
+#ifndef NOKVM
+ free(bufdata);
+#endif
+ }
  return (0);
 }



Re: iked: Do not accept superfluous arguments

2017-08-31 Thread Klemens Nanni
On Wed, Aug 23, 2017 at 10:42:36PM +0200, Klemens Nanni wrote:
> Calling `iked reload' when I meant `ikectl reload' showed that iked
> happily returned 0 and and fired up another daemon.
> 
> Feedback?
> 
> Index: iked.c
> ===
> RCS file: /cvs/src/sbin/iked/iked.c,v
> retrieving revision 1.34
> diff -u -p -r1.34 iked.c
> --- iked.c23 Mar 2017 05:29:48 -  1.34
> +++ iked.c23 Aug 2017 20:39:12 -
> @@ -109,6 +109,11 @@ main(int argc, char *argv[])
>   usage();
>   }
>   }
> + argc -= optind;
> + argv += optind;
> +
> + if (argc)
> + usage();
>  
>   if ((env = calloc(1, sizeof(*env))) == NULL)
>   fatal("calloc: env");
> 
Bump. Would anyone mind getting this in? I'd like to spare other from
tripping over two running iked processes due to a simple typo.



Re: i386 zzz broken, Was: CVS: cvs.openbsd.org: src

2017-08-31 Thread lists
Wed, 30 Aug 2017 16:39:18 -0700 Mike Larkin 
> On Wed, Aug 30, 2017 at 12:48:20AM -0700, Mike Larkin wrote:
> > On Tue, Aug 29, 2017 at 04:32:04PM -0700, Mike Larkin wrote:  
> > > On Mon, Aug 28, 2017 at 11:18:13PM +0300, li...@wrant.com wrote:  
> > > > Mon, 28 Aug 2017 10:16:58 -0600 (MDT) Ted Unangst   
> > > > > CVSROOT:  /cvs
> > > > > Module name:  src
> > > > > Changes by:   t...@cvs.openbsd.org2017/08/28 10:16:58
> > > > > 
> > > > > Modified files:
> > > > >   usr.sbin/apmd  : apmd.8 apmd.c 
> > > > > 
> > > > > Log message:
> > > > > add -z and -Z options to auto suspend or hibernate when low on 
> > > > > battery.
> > > > > from Jesper Wallin
> > > > >   
> > > > 
> > > > Hi tech@,
> > > > 
> > > > Could someone please test and confirm suspend still works on i386?  I am
> > > > getting the laptop to wake but it's stuck, black screen, high fan speed,
> > > > no response, only long press on the power button works.  It used to work
> > > > flawless, I suspect it might be from the last few snapshots, can't tell.
> > > > 
> > > > Ready to provide details if this works elsewhere & someone's interested.
> > > > Please let me know if it's a known/expected issue, or better sendbug(1).
> > > > 
> > > > Kind regards,
> > > > Anton Lazarov
> > > >   
> > > 
> > > Hmm, I can repro this here even with qemu. It's stuck in lapic_delay.
> > > 
> > > I'll see if I can track down what's going wrong. It would also help if you
> > > could narrow down when it broke.
> > > 
> > > -ml
> > >   
> > 
> > I figured out what was going on, but it's unclear why this suddenly broke.
> > 
> > Once we get to the bottom of what caused the breakage, I'll commit a fix.
> > 
> > -ml
> >   
> 
> We figured out what was going wrong. I just committed a fix. Should be in
> snaps soon. Thanks for reporting it.
> 
> -ml

Wed, 30 Aug 2017 17:40:22 -0600 (MDT) Mike Larkin 
> CVSROOT:  /cvs
> Module name:  src
> Changes by:   mlar...@cvs.openbsd.org 2017/08/30 17:40:22
> 
> Modified files:
>   sys/arch/amd64/amd64: acpi_wakecode.S 
>   sys/arch/i386/i386: acpi_wakecode.S 
> 
> Log message:
> adjust ACPI resume-time saved stack location to account for a different
> layout used by clang on i386. Also add a clarification to amd64's version
> of the same (amd64 already had such an adjustment).
> 
> ok deraadt, tom, kettenis
> 

Hi Mike,

I just installed the snapshot immediately after it became available on
the mirrors, and can confirm suspend & resume works on my i386 laptop.
Hibernation works too.  Thank you very much for sorting this so quick.

Kind regards,
Anton Lazarov



armv7 a few tc_counter_mask fixes

2017-08-31 Thread Artturi Alm
Hi,

I was looking at /sys/sys/timetc.h:
46 struct timecounter {
 47 timecounter_get_t   *tc_get_timecount;
 48 /*
 49  * This function reads the counter.  It is not required to
 50  * mask any unimplemented bits out, as long as they are
 51  * constant.
 52  */

"as long as they are constant."
and came up w/diff below, because all of these return their fullest(32b):

182 u_int
183 agtimer_get_timecount(struct timecounter *tc)
184 {
185 return agtimer_readcnt64();


216 u_int
217 amptimer_get_timecount(struct timecounter *tc)
218 {
219 struct amptimer_softc *sc = amptimer_timecounter.tc_priv;
220 return bus_space_read_4(sc->sc_iot, sc->sc_ioh, GTIMER_CNT_LOW);


437 u_int
438 gptimer_get_timecount(struct timecounter *tc)
439 {
440 return bus_space_read_4(gptimer_iot, gptimer_ioh1, GP_TCRR);


tbh., i didn't have time to read kern_tc.c to see if it does really matter,
i think not, and it's obvious that this isn't critical or it'd be known by
now i guess, or if this does count as a bug at all, but i see no value in
stealing the msb from these tc sources :)

-Artturi


diff --git a/sys/arch/arm/cortex/agtimer.c b/sys/arch/arm/cortex/agtimer.c
index 8d622c058a4..160e22e6949 100644
--- a/sys/arch/arm/cortex/agtimer.c
+++ b/sys/arch/arm/cortex/agtimer.c
@@ -46,7 +46,7 @@ int32_t agtimer_frequency = TIMER_FREQUENCY;
 u_int agtimer_get_timecount(struct timecounter *);
 
 static struct timecounter agtimer_timecounter = {
-   agtimer_get_timecount, NULL, 0x7fff, 0, "agtimer", 0, NULL
+   agtimer_get_timecount, NULL, 0x, 0, "agtimer", 0, NULL
 };
 
 #define MAX_ARM_CPUS   8
diff --git a/sys/arch/arm/cortex/amptimer.c b/sys/arch/arm/cortex/amptimer.c
index 81880c1574a..66f0ccfed64 100644
--- a/sys/arch/arm/cortex/amptimer.c
+++ b/sys/arch/arm/cortex/amptimer.c
@@ -67,7 +67,7 @@ int32_t amptimer_frequency = TIMER_FREQUENCY;
 u_int amptimer_get_timecount(struct timecounter *);
 
 static struct timecounter amptimer_timecounter = {
-   amptimer_get_timecount, NULL, 0x7fff, 0, "amptimer", 0, NULL
+   amptimer_get_timecount, NULL, 0x, 0, "amptimer", 0, NULL
 };
 
 #define MAX_ARM_CPUS   8
diff --git a/sys/arch/armv7/omap/gptimer.c b/sys/arch/armv7/omap/gptimer.c
index e5fd9965ded..a2e3e4e97a2 100644
--- a/sys/arch/armv7/omap/gptimer.c
+++ b/sys/arch/armv7/omap/gptimer.c
@@ -118,7 +118,7 @@ int gptimer_irq = 0;
 u_int gptimer_get_timecount(struct timecounter *);
 
 static struct timecounter gptimer_timecounter = {
-   gptimer_get_timecount, NULL, 0x7fff, 0, "gptimer", 0, NULL
+   gptimer_get_timecount, NULL, 0x, 0, "gptimer", 0, NULL
 };
 
 volatile u_int32_t nexttickevent;



Re: some cvstags

2017-08-31 Thread Ian Sutton
On Fri, Sep 01, 2017 at 12:17:29AM +0300, Artturi Alm wrote:
> Hi,
> 
> rather obvious diff below.
> 
> -Artturi

Thanks, committed 



some cvstags

2017-08-31 Thread Artturi Alm
Hi,

rather obvious diff below.

-Artturi


diff --git a/sys/arch/armv7/omap/amdisplay.c b/sys/arch/armv7/omap/amdisplay.c
index 912e5407035..f42e201760b 100644
--- a/sys/arch/armv7/omap/amdisplay.c
+++ b/sys/arch/armv7/omap/amdisplay.c
@@ -1,3 +1,4 @@
+/* $OpenBSD$ */
 /*
  * Copyright (c) 2016 Ian Sutton 
  *
diff --git a/sys/arch/armv7/omap/amdisplayreg.h 
b/sys/arch/armv7/omap/amdisplayreg.h
index 79f6bdd0883..1fd44037a78 100644
--- a/sys/arch/armv7/omap/amdisplayreg.h
+++ b/sys/arch/armv7/omap/amdisplayreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD$ */
 /*
  * Copyright (c) 2016 Ian Sutton 
  *
diff --git a/sys/arch/armv7/omap/nxphdmi.c b/sys/arch/armv7/omap/nxphdmi.c
index db73c285b10..fc0338383fb 100644
--- a/sys/arch/armv7/omap/nxphdmi.c
+++ b/sys/arch/armv7/omap/nxphdmi.c
@@ -1,3 +1,4 @@
+/* $OpenBSD$ */
 /*
  * Copyright (c) 2016 Ian Sutton 
  * All rights reserved.
diff --git a/sys/arch/armv7/omap/nxphdmivar.h b/sys/arch/armv7/omap/nxphdmivar.h
index 0a7038270bd..87b8f874f5a 100644
--- a/sys/arch/armv7/omap/nxphdmivar.h
+++ b/sys/arch/armv7/omap/nxphdmivar.h
@@ -1,3 +1,4 @@
+/* $OpenBSD$ */
 /*
  * Copyright (c) 2016 Ian Sutton 
  *



Re: enum unsigned or not?

2017-08-31 Thread Tom Cosgrove
>>> patrick keshishian 31-Aug-17 20:40 >>>
>
> On Thu, Aug 31, 2017 at 12:13:19PM -0700, William Ahern wrote:
> > On Thu, Aug 31, 2017 at 02:08:07PM +0200, Otto Moerbeek wrote:
> > > Hi,
> > > 
> > > /usr/src/usr.sbin/sasyncd/carp.c:157:12: warning: comparison of
> > > unsigned enum expression < 0 is always false [-Wtautological-compare]
> > > if (state < 0 || state > FAIL)
> > > ~ ^ ~
> > > /usr/src/usr.sbin/sasyncd/carp.c:166:20: warning: comparison of
> > > unsigned enum expression < 0 is always false [-Wtautological-compare]
> > > if (current_state < 0 || current_state > FAIL) {
> > > ~ ^ ~
>
>   if (!(state >= INIT && state <= FAIL))
>   state = FAIL;
> and
>   if (!(current_sate >= INIT && current_state <= FAIL) {
>   log_err ...
>   ...
>   return;
>   }
>
> More better?

If the compiler is using an unsigned underlying type for the enum, the
comparison

state >= INIT

will give something along the lines of "expression >= 0 is always true"

I don't know what the best solution is here; I would defer to Otto!

Tom

> --patrick
>
> > > 
> > > this warning is a tiny bit interesting. A compiler is free to choose
> > > the type of the enum, as long as it can represent all given values.
> > > So another compiler might choose not to make it unsigned. So I came up
> > > with this fix that is not depending on the signedness of the type. But
> > > most of the time avoiding enum is better, I suppose.
> > 
> > It's free to choose the integer type of the enum, but enumeration members
> > (i.e. the constant identifiers) have int type.
> > 
> >   The identifiers in an enumerator list are declared as constants that have
> >   type int and may appear wherever such are permitted.
> > 
> >   C11 (N1570) 6.7.2.2p3.
> > 
> > Furthermore, the defining expression of the constant must be representable
> > as an int. 6.7.2.2p2.
> > 
> > I've always vascillated about which operand to cast, and to which type, when
> > silencing compilers' annoying warnings. But now that I've read the section
> > more closely I think I'll just cast the operand with enum type to int, all
> > things being equal.
> > 



refactoring of pf_find_or_create_ruleset()

2017-08-31 Thread Alexandr Nedvedicky
Hello,

long time ago mpi@ asked, what I would improve in PF to make the code ready for
SMP massage. Everybody knows PF is perfect, right? So it took me a while to
find a code for facelift.

Patch below breaks pf_find_or_create_ruleset() spaghetti to more chunks:

pf_find_or_create_ruleset()
which still tights all pieces together

pf_get_leaf_ruleset(*path, **path_remainder)
it traverses the path to the leaf, which exists PF.  let's assume this
is the path to ruleset administrator wants to add:

the/ruleset/that/exists/path/we/are/adding

the function will traverse the path to:

the/ruleset/that/exists

will return a pointer to the matching ruleset and it will
also update the path_remainder to:

path/we/are/adding

Thus the caller (pf_find_or_create_ruleset()), is able to create
the rulesets, which match path_remainder and attach them to
existing ruleset.

pf_create_anchor()
it just creates anchor and attaches it to parent.

I did run regression tests for pfctl. I had to workaround a test pf104.in.
The resolver always returned IPv4 for 'localhost' instead of IPv6. I eventually
gave up and skipped the test. No other problems popped up.

Do you think I should get it in?

thanks and
regards
sasha

8<---8<---8<--8<
diff -r 78ea302507cb src/sys/net/pf_ruleset.c
--- src/sys/net/pf_ruleset.cThu Aug 31 21:27:47 2017 +0200
+++ src/sys/net/pf_ruleset.cThu Aug 31 21:30:45 2017 +0200
@@ -133,95 +133,150 @@ pf_find_ruleset(const char *path)
 }
 
 struct pf_ruleset *
+pf_get_leaf_ruleset(char *path, char **path_remainder)
+{
+   struct pf_ruleset   *ruleset;
+   char*leaf, *p;
+   int  i = 0;
+
+   p = path;
+   while (*p == '/')
+   p++;
+
+   ruleset = pf_find_ruleset(p);
+   leaf = p;
+   while (ruleset == NULL) {
+   leaf = strrchr(p, '/');
+   if (leaf != NULL) {
+   *leaf = '\0';
+   i++;
+   ruleset = pf_find_ruleset(p);
+   } else {
+   leaf = path;
+   /*
+* if no path component exists, then main ruleset is
+* our parent.
+*/
+   ruleset = _main_ruleset;
+   }
+   }
+
+   if (path_remainder != NULL)
+   *path_remainder = leaf;
+
+   /* restore slashes in path.  */
+   while (i != 0) {
+   while (*leaf != '\0')
+   leaf++;
+   *leaf = '/';
+   i--;
+   }
+
+   return (ruleset);
+}
+
+struct pf_anchor *
+pf_create_anchor(struct pf_anchor *parent, const char *aname)
+{
+   struct pf_anchor*anchor, *dup;
+
+   if (!*aname || (strlen(aname) >= PF_ANCHOR_NAME_SIZE) ||
+   ((parent != NULL) && (strlen(parent->path) >= PF_ANCHOR_MAXPATH)))
+   return (NULL);
+
+   anchor = rs_malloc(sizeof(*anchor));
+   if (anchor == NULL)
+   return (NULL);
+
+   RB_INIT(>children);
+   strlcpy(anchor->name, aname, sizeof(anchor->name));
+   if (parent != _main_anchor) {
+   /*
+* Make sure path for levels 2, 3, ... is terminated by '/':
+*  1/2/3/...
+*/
+   strlcpy(anchor->path, parent->path, sizeof (anchor->path));
+   strlcat(anchor->path, "/", sizeof(anchor->path));
+   }
+   strlcat(anchor->path, anchor->name, sizeof(anchor->path));
+
+   if ((dup = RB_INSERT(pf_anchor_global, _anchors, anchor)) != NULL) {
+   DPFPRINTF(LOG_NOTICE,
+   "%s: RB_INSERT to global '%s' '%s' collides with '%s' '%s'",
+   __func__, anchor->path, anchor->name, dup->path, dup->name);
+   rs_free(anchor, sizeof(*anchor));
+   return (NULL);
+   }
+
+   if (parent != NULL) {
+   anchor->parent = parent;
+   dup = RB_INSERT(pf_anchor_node, >children, anchor);
+   if (dup != NULL) {
+   DPFPRINTF(LOG_NOTICE,
+   "%s: RB_INSERT to parent '%s' '%s' collides with "
+   "'%s' '%s'", __func__, anchor->path, anchor->name,
+   dup->path, dup->name);
+   RB_REMOVE(pf_anchor_global, _anchors,
+   anchor);
+   rs_free(anchor, sizeof(*anchor));
+   return (NULL);
+   }
+   }
+
+   pf_init_ruleset(>ruleset);
+   anchor->ruleset.anchor = anchor;
+
+   return (anchor);
+}
+
+struct pf_ruleset *
 pf_find_or_create_ruleset(const char *path)
 {
-   char*p, *q, *r;
+   

Re: enum unsigned or not?

2017-08-31 Thread patrick keshishian
On Thu, Aug 31, 2017 at 12:13:19PM -0700, William Ahern wrote:
> On Thu, Aug 31, 2017 at 02:08:07PM +0200, Otto Moerbeek wrote:
> > Hi,
> > 
> > /usr/src/usr.sbin/sasyncd/carp.c:157:12: warning: comparison of
> > unsigned enum expression < 0 is always false [-Wtautological-compare]
> > if (state < 0 || state > FAIL)
> > ~ ^ ~
> > /usr/src/usr.sbin/sasyncd/carp.c:166:20: warning: comparison of
> > unsigned enum expression < 0 is always false [-Wtautological-compare]
> > if (current_state < 0 || current_state > FAIL) {
> > ~ ^ ~

if (!(state >= INIT && state <= FAIL))
state = FAIL;
and
if (!(current_sate >= INIT && current_state <= FAIL) {
log_err ...
...
return;
}

More better?

--patrick

> > 
> > this warning is a tiny bit interesting. A compiler is free to choose
> > the type of the enum, as long as it can represent all given values.
> > So another compiler might choose not to make it unsigned. So I came up
> > with this fix that is not depending on the signedness of the type. But
> > most of the time avoiding enum is better, I suppose.
> 
> It's free to choose the integer type of the enum, but enumeration members
> (i.e. the constant identifiers) have int type.
> 
>   The identifiers in an enumerator list are declared as constants that have
>   type int and may appear wherever such are permitted.
> 
>   C11 (N1570) 6.7.2.2p3.
> 
> Furthermore, the defining expression of the constant must be representable
> as an int. 6.7.2.2p2.
> 
> I've always vascillated about which operand to cast, and to which type, when
> silencing compilers' annoying warnings. But now that I've read the section
> more closely I think I'll just cast the operand with enum type to int, all
> things being equal.
> 



Re: enum unsigned or not?

2017-08-31 Thread William Ahern
On Thu, Aug 31, 2017 at 02:08:07PM +0200, Otto Moerbeek wrote:
> Hi,
> 
> /usr/src/usr.sbin/sasyncd/carp.c:157:12: warning: comparison of
> unsigned enum expression < 0 is always false [-Wtautological-compare]
> if (state < 0 || state > FAIL)
> ~ ^ ~
> /usr/src/usr.sbin/sasyncd/carp.c:166:20: warning: comparison of
> unsigned enum expression < 0 is always false [-Wtautological-compare]
> if (current_state < 0 || current_state > FAIL) {
> ~ ^ ~
> 
> this warning is a tiny bit interesting. A compiler is free to choose
> the type of the enum, as long as it can represent all given values.
> So another compiler might choose not to make it unsigned. So I came up
> with this fix that is not depending on the signedness of the type. But
> most of the time avoiding enum is better, I suppose.

It's free to choose the integer type of the enum, but enumeration members
(i.e. the constant identifiers) have int type.

  The identifiers in an enumerator list are declared as constants that have
  type int and may appear wherever such are permitted.

  C11 (N1570) 6.7.2.2p3.

Furthermore, the defining expression of the constant must be representable
as an int. 6.7.2.2p2.

I've always vascillated about which operand to cast, and to which type, when
silencing compilers' annoying warnings. But now that I've read the section
more closely I think I'll just cast the operand with enum type to int, all
things being equal.



Re: enum unsigned or not?

2017-08-31 Thread Otto Moerbeek
On Thu, Aug 31, 2017 at 05:10:27PM +0200, Boudewijn Dijkstra wrote:

> Op Thu, 31 Aug 2017 14:08:07 +0200 schreef Otto Moerbeek :
> > /usr/src/usr.sbin/sasyncd/carp.c:157:12: warning: comparison of
> > unsigned enum expression < 0 is always false [-Wtautological-compare]
> > if (state < 0 || state > FAIL)
> > ~ ^ ~
> > /usr/src/usr.sbin/sasyncd/carp.c:166:20: warning: comparison of
> > unsigned enum expression < 0 is always false [-Wtautological-compare]
> > if (current_state < 0 || current_state > FAIL) {
> > ~ ^ ~
> > 
> > this warning is a tiny bit interesting. A compiler is free to choose
> > the type of the enum, as long as it can represent all given values.
> > So another compiler might choose not to make it unsigned. So I came up
> > with this fix that is not depending on the signedness of the type. But
> > most of the time avoiding enum is better, I suppose.
> > 
> > -Otto
> > 
> > Index: carp.c
> > ===
> > RCS file: /cvs/src/usr.sbin/sasyncd/carp.c,v
> > retrieving revision 1.15
> > diff -u -p -r1.15 carp.c
> > --- carp.c  27 Aug 2016 04:21:08 -  1.15
> > +++ carp.c  31 Aug 2017 12:03:59 -
> > @@ -154,7 +154,7 @@ carp_state_name(enum RUNSTATE state)
> >  {
> > static const char   *carpstate[] = CARPSTATES;
> > -   if (state < 0 || state > FAIL)
> > +   if ((unsigned)state > FAIL)
> > state = FAIL;
> > return carpstate[state];
> >  }
> > @@ -163,7 +163,7 @@ void
> >  carp_update_state(enum RUNSTATE current_state)
> >  {
> > -   if (current_state < 0 || current_state > FAIL) {
> > +   if ((unsigned)current_state > FAIL) {
> > log_err("carp_update_state: invalid carp state, abort");
> > cfgstate.runstate = FAIL;
> > return;
> > 
> 
> Doesn't the compiler warn about enum non-member assignment? If it does, then
> checking it would be redundant here, no?

Only in C++, which has stricter rule regarding to enums.

-Otto



Re: enum unsigned or not?

2017-08-31 Thread Boudewijn Dijkstra

Op Thu, 31 Aug 2017 14:08:07 +0200 schreef Otto Moerbeek :

/usr/src/usr.sbin/sasyncd/carp.c:157:12: warning: comparison of
unsigned enum expression < 0 is always false [-Wtautological-compare]
if (state < 0 || state > FAIL)
~ ^ ~
/usr/src/usr.sbin/sasyncd/carp.c:166:20: warning: comparison of
unsigned enum expression < 0 is always false [-Wtautological-compare]
if (current_state < 0 || current_state > FAIL) {
~ ^ ~

this warning is a tiny bit interesting. A compiler is free to choose
the type of the enum, as long as it can represent all given values.
So another compiler might choose not to make it unsigned. So I came up
with this fix that is not depending on the signedness of the type. But
most of the time avoiding enum is better, I suppose.

-Otto

Index: carp.c
===
RCS file: /cvs/src/usr.sbin/sasyncd/carp.c,v
retrieving revision 1.15
diff -u -p -r1.15 carp.c
--- carp.c  27 Aug 2016 04:21:08 -  1.15
+++ carp.c  31 Aug 2017 12:03:59 -
@@ -154,7 +154,7 @@ carp_state_name(enum RUNSTATE state)
 {
static const char   *carpstate[] = CARPSTATES;
-   if (state < 0 || state > FAIL)
+   if ((unsigned)state > FAIL)
state = FAIL;
return carpstate[state];
 }
@@ -163,7 +163,7 @@ void
 carp_update_state(enum RUNSTATE current_state)
 {
-   if (current_state < 0 || current_state > FAIL) {
+   if ((unsigned)current_state > FAIL) {
log_err("carp_update_state: invalid carp state, abort");
cfgstate.runstate = FAIL;
return;



Doesn't the compiler warn about enum non-member assignment? If it does,  
then checking it would be redundant here, no?



--
Gemaakt met Opera's e-mailprogramma: http://www.opera.com/mail/



Re: httpd: remove unused media_encoding field

2017-08-31 Thread Hiltjo Posthuma
On Sun, Aug 13, 2017 at 03:53:53PM +0200, Hiltjo Posthuma wrote:
> Hi,
> 
> This patch removes the unused media_encoding field, it was probably intended 
> to
> be used to add text-encoding information.
> 
> However: forcing a text-encoding can be useful in some cases.
> Currently in httpd.conf the text-encoding can be set with a hack for example:
> 
> types { "text"/"plain; charset=utf-8" txt c h }
> 
> This works because in parse.y the mediaoptsl grammar is defined as:
> STRING '/' STRING.
> However this might be incompatible with the mime.types format.
> 
> Anyway, patch below:
> 
> 
> diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c
> index 6d1d1ff34fe..ef3f95a649d 100644
> --- a/usr.sbin/httpd/httpd.c
> +++ b/usr.sbin/httpd/httpd.c
> @@ -1199,11 +1199,6 @@ media_add(struct mediatypes *types, struct media_type 
> *media)
>   return (NULL);
>  
>   memcpy(entry, media, sizeof(*entry));
> - if (media->media_encoding != NULL &&
> - (entry->media_encoding = strdup(media->media_encoding)) == NULL) {
> - free(entry);
> - return (NULL);
> - }
>   RB_INSERT(mediatypes, types, entry);
>  
>   return (entry);
> @@ -1214,7 +1209,6 @@ media_delete(struct mediatypes *types, struct 
> media_type *media)
>  {
>   RB_REMOVE(mediatypes, types, media);
>  
> - free(media->media_encoding);
>   free(media);
>  }
>  
> diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h
> index 05cbb8e3550..9a6530715c7 100644
> --- a/usr.sbin/httpd/httpd.h
> +++ b/usr.sbin/httpd/httpd.h
> @@ -53,7 +53,7 @@
>  #define HTTPD_LOGROOT"/logs"
>  #define HTTPD_ACCESS_LOG "access.log"
>  #define HTTPD_ERROR_LOG  "error.log"
> -#define HTTPD_DEFAULT_TYPE   { "bin", "application", "octet-stream", NULL }
> +#define HTTPD_DEFAULT_TYPE   { "bin", "application", "octet-stream" }
>  #define HTTPD_LOGVIS VIS_NL|VIS_TAB|VIS_CSTYLE
>  #define HTTPD_TLS_CERT   "/etc/ssl/server.crt"
>  #define HTTPD_TLS_KEY"/etc/ssl/private/server.key"
> @@ -438,7 +438,6 @@ struct media_type {
>   char media_name[MEDIATYPE_NAMEMAX];
>   char media_type[MEDIATYPE_TYPEMAX];
>   char media_subtype[MEDIATYPE_TYPEMAX];
> - char*media_encoding;
>   RB_ENTRY(media_type) media_entry;
>  };
>  RB_HEAD(mediatypes, media_type);
> diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y
> index 203ddd1b0bb..2fc50b1a1da 100644
> --- a/usr.sbin/httpd/parse.y
> +++ b/usr.sbin/httpd/parse.y
> @@ -1695,7 +1695,6 @@ load_config(const char *filename, struct httpd *x_conf)
>   (void)strlcpy(m.media_subtype,
>   mediatypes[i].media_subtype,
>   sizeof(m.media_subtype));
> - m.media_encoding = NULL;
>  
>   if (media_add(conf->sc_mediatypes, ) == NULL) {
>   log_warnx("failed to add default media \"%s\"",
> 

Any thoughts / OKs?

-- 
Kind regards,
Hiltjo



enum unsigned or not?

2017-08-31 Thread Otto Moerbeek
Hi,

/usr/src/usr.sbin/sasyncd/carp.c:157:12: warning: comparison of
unsigned enum expression < 0 is always false [-Wtautological-compare]
if (state < 0 || state > FAIL)
~ ^ ~
/usr/src/usr.sbin/sasyncd/carp.c:166:20: warning: comparison of
unsigned enum expression < 0 is always false [-Wtautological-compare]
if (current_state < 0 || current_state > FAIL) {
~ ^ ~

this warning is a tiny bit interesting. A compiler is free to choose
the type of the enum, as long as it can represent all given values.
So another compiler might choose not to make it unsigned. So I came up
with this fix that is not depending on the signedness of the type. But
most of the time avoiding enum is better, I suppose.

-Otto

Index: carp.c
===
RCS file: /cvs/src/usr.sbin/sasyncd/carp.c,v
retrieving revision 1.15
diff -u -p -r1.15 carp.c
--- carp.c  27 Aug 2016 04:21:08 -  1.15
+++ carp.c  31 Aug 2017 12:03:59 -
@@ -154,7 +154,7 @@ carp_state_name(enum RUNSTATE state)
 {
static const char   *carpstate[] = CARPSTATES;
 
-   if (state < 0 || state > FAIL)
+   if ((unsigned)state > FAIL)
state = FAIL;
return carpstate[state];
 }
@@ -163,7 +163,7 @@ void
 carp_update_state(enum RUNSTATE current_state)
 {
 
-   if (current_state < 0 || current_state > FAIL) {
+   if ((unsigned)current_state > FAIL) {
log_err("carp_update_state: invalid carp state, abort");
cfgstate.runstate = FAIL;
return;



ksh: histptr and undefined pointer comparisons

2017-08-31 Thread Jeremie Courreges-Anglas

I've noticed this some time ago and, while it doesn't seem to be
a problem in practice, it's still undefined.  C says what happens with
pointers:
- within the bounds of an array
- one past the last element of an array
but nothing about a pointer one element before the first element of an
array.

Thoughts?


Index: history.c
===
RCS file: /d/cvs/src/bin/ksh/history.c,v
retrieving revision 1.69
diff -u -p -p -u -r1.69 history.c
--- history.c   30 Aug 2017 17:08:45 -  1.69
+++ history.c   31 Aug 2017 12:01:48 -
@@ -39,6 +39,7 @@ static char   **hist_get_oldest(void);
 static voidhistbackup(void);
 
 static FILE*histfh;
+static char   **histbase;  /* actual start of the history[] allocation */
 static char   **current;   /* current position in history[] */
 static char*hname; /* current name of history file */
 static int hstarted;   /* set after hist_init() called */
@@ -557,8 +558,9 @@ sethistsize(int n)
memmove(history, histptr - offset, n * sizeof(char *));
}
 
-   history = areallocarray(history, n, sizeof(char *), APERM);
histsize = n;
+   histbase = areallocarray(histbase, n + 1, sizeof(char *), 
APERM);
+   history = histbase + 1;
histptr = history + offset;
}
 }
@@ -597,9 +599,15 @@ sethistfile(const char *name)
 void
 init_histvec(void)
 {
-   if (history == NULL) {
+   if (histbase == NULL) {
histsize = HISTORYSIZE;
-   history = areallocarray(NULL, histsize, sizeof(char *), APERM);
+   /*
+* allocate one extra element so that histptr always
+* lays within array bounds
+*/
+   histbase = areallocarray(NULL, histsize + 1, sizeof(char *),
+   APERM);
+   history = histbase + 1;
histptr = history - 1;
}
 }

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: [phess...@openbsd.org: add pinebook support to u-boot]

2017-08-31 Thread Jonathan Gray
On Thu, Aug 31, 2017 at 11:41:44AM +0200, Peter Hessler wrote:
> On 2017 Aug 31 (Thu) at 19:16:57 +1000 (+1000), Jonathan Gray wrote:
> :On Thu, Aug 31, 2017 at 10:59:20AM +0200, Peter Hessler wrote:
> :> On 2017 Aug 31 (Thu) at 10:41:41 +0200 (+0200), Peter Hessler wrote:
> :> :On 2017 Aug 27 (Sun) at 22:15:46 +0200 (+0200), Peter Hessler wrote:
> :> ::- Forwarded message from Peter Hessler  -
> :> ::taken from Icenowy Zheng's repository,
> :> ::commit bd656cab0c3e0669e977641c15095f32d7b0731f
> :> ::
> :> ::This gives us basic support for the Pine64 Pinebook
> :> ::
> :> ::OK?
> :> ::
> :> ::$ sysctl hw
> :> ::hw.machine=arm64
> :> ::hw.model=ARM Cortex-A53 r0p4
> :> ::hw.ncpu=1
> :> ::hw.byteorder=1234
> :> ::hw.pagesize=4096
> :> ::hw.disknames=sd0:d76c5b9369f79257
> :> ::hw.diskcount=1
> :> ::hw.product=Pinebook
> :> ::hw.physmem=2021924864
> :> ::hw.usermem=2021912576
> :> ::hw.ncpufound=1
> :> ::hw.allowpowerdown=1
> :> ::
> :> ::
> :> :
> :> :Updated to chase rc3, move new files to file/, slight simplification to
> :> :the defconfig.
> :> :
> :> :OK?
> :> :
> :> 
> :> Better version, sorry for the noise
> :
> :What is your intended change to the sopine configuration?
> :Changing the model/compat strings in the device tree?
> :
> 
> to start with, yes.  later, there will be more hardware supported.
> 
> 
> :The defconfig should drop CONFIG_SUN8I_EMAC=y as there is Ethernet.
> :
> :Current difference to sopine_baseboard being
> :-CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
> :+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pinebook"
> :
> :I see no reason why the dts can't be almost the same as
> :sun50i-a64-pine64-plus.dts:
> :
> :#include "sun50i-a64-pine64.dts"
> :
> :/ {
> : model = "Pinebook";
> : compatible = "pine64,pinebook", "allwinner,sun50i-a64";
> :};
> :
> 
> I pulled it from upstream.  
> https://github.com/Icenowy/u-boot/blob/sunxi64-beta-pb-lcd-lpddr3/arch/arm/dts/sun50i-a64-pinebook.dts

upstream is not a random branch on github it is http://git.denx.de/?p=u-boot.git

That branch also dates back to before many a64/pine64 changes went in.



Re: [phess...@openbsd.org: add pinebook support to u-boot]

2017-08-31 Thread Peter Hessler
On 2017 Aug 31 (Thu) at 19:16:57 +1000 (+1000), Jonathan Gray wrote:
:On Thu, Aug 31, 2017 at 10:59:20AM +0200, Peter Hessler wrote:
:> On 2017 Aug 31 (Thu) at 10:41:41 +0200 (+0200), Peter Hessler wrote:
:> :On 2017 Aug 27 (Sun) at 22:15:46 +0200 (+0200), Peter Hessler wrote:
:> ::- Forwarded message from Peter Hessler  -
:> ::taken from Icenowy Zheng's repository,
:> ::commit bd656cab0c3e0669e977641c15095f32d7b0731f
:> ::
:> ::This gives us basic support for the Pine64 Pinebook
:> ::
:> ::OK?
:> ::
:> ::$ sysctl hw
:> ::hw.machine=arm64
:> ::hw.model=ARM Cortex-A53 r0p4
:> ::hw.ncpu=1
:> ::hw.byteorder=1234
:> ::hw.pagesize=4096
:> ::hw.disknames=sd0:d76c5b9369f79257
:> ::hw.diskcount=1
:> ::hw.product=Pinebook
:> ::hw.physmem=2021924864
:> ::hw.usermem=2021912576
:> ::hw.ncpufound=1
:> ::hw.allowpowerdown=1
:> ::
:> ::
:> :
:> :Updated to chase rc3, move new files to file/, slight simplification to
:> :the defconfig.
:> :
:> :OK?
:> :
:> 
:> Better version, sorry for the noise
:
:What is your intended change to the sopine configuration?
:Changing the model/compat strings in the device tree?
:

to start with, yes.  later, there will be more hardware supported.


:The defconfig should drop CONFIG_SUN8I_EMAC=y as there is Ethernet.
:
:Current difference to sopine_baseboard being
:-CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
:+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pinebook"
:
:I see no reason why the dts can't be almost the same as
:sun50i-a64-pine64-plus.dts:
:
:#include "sun50i-a64-pine64.dts"
:
:/ {
:   model = "Pinebook";
:   compatible = "pine64,pinebook", "allwinner,sun50i-a64";
:};
:

I pulled it from upstream.  
https://github.com/Icenowy/u-boot/blob/sunxi64-beta-pb-lcd-lpddr3/arch/arm/dts/sun50i-a64-pinebook.dts

I can trim it down, whatever.  Is there any other bikeshedding that
people want to do for this board?


-- 
She said, `I know you ... you cannot sing'.  I said, `That's nothing,
you should hear me play piano.'
-- Morrisey



Re: [phess...@openbsd.org: add pinebook support to u-boot]

2017-08-31 Thread Jonathan Gray
On Thu, Aug 31, 2017 at 10:59:20AM +0200, Peter Hessler wrote:
> On 2017 Aug 31 (Thu) at 10:41:41 +0200 (+0200), Peter Hessler wrote:
> :On 2017 Aug 27 (Sun) at 22:15:46 +0200 (+0200), Peter Hessler wrote:
> ::- Forwarded message from Peter Hessler  -
> ::taken from Icenowy Zheng's repository,
> ::commit bd656cab0c3e0669e977641c15095f32d7b0731f
> ::
> ::This gives us basic support for the Pine64 Pinebook
> ::
> ::OK?
> ::
> ::$ sysctl hw
> ::hw.machine=arm64
> ::hw.model=ARM Cortex-A53 r0p4
> ::hw.ncpu=1
> ::hw.byteorder=1234
> ::hw.pagesize=4096
> ::hw.disknames=sd0:d76c5b9369f79257
> ::hw.diskcount=1
> ::hw.product=Pinebook
> ::hw.physmem=2021924864
> ::hw.usermem=2021912576
> ::hw.ncpufound=1
> ::hw.allowpowerdown=1
> ::
> ::
> :
> :Updated to chase rc3, move new files to file/, slight simplification to
> :the defconfig.
> :
> :OK?
> :
> 
> Better version, sorry for the noise

What is your intended change to the sopine configuration?
Changing the model/compat strings in the device tree?

The defconfig should drop CONFIG_SUN8I_EMAC=y as there is Ethernet.

Current difference to sopine_baseboard being
-CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pinebook"

I see no reason why the dts can't be almost the same as
sun50i-a64-pine64-plus.dts:

#include "sun50i-a64-pine64.dts"

/ {
model = "Pinebook";
compatible = "pine64,pinebook", "allwinner,sun50i-a64";
};

> 
> Index: sysutils/u-boot/Makefile
> ===
> RCS file: /cvs/openbsd/ports/sysutils/u-boot/Makefile,v
> retrieving revision 1.26
> diff -u -p -u -p -r1.26 Makefile
> --- sysutils/u-boot/Makefile  29 Aug 2017 07:14:50 -  1.26
> +++ sysutils/u-boot/Makefile  31 Aug 2017 08:42:35 -
> @@ -7,6 +7,7 @@ FLAVOR?=  arm
>  
>  COMMENT= U-Boot firmware
>  VERSION= 2017.09-rc3
> +REVISION=0
>  DISTNAME=u-boot-${VERSION}
>  PKGNAME= u-boot-${FLAVOR}-${VERSION:S/-//}
>  FULLPKGNAME= ${PKGNAME}
> @@ -57,6 +58,7 @@ SUNXI64=\
>   orangepi_prime \
>   orangepi_win \
>   pine64_plus \
> + pinebook \
>   sopine_baseboard
>  BOARDS=\
>   mvebu_espressobin-88f3720 \
> @@ -140,6 +142,8 @@ pre-build:
>  .for f in ${MODPY_ADJ_FILES}
>   ${MODPY_BIN_ADJ} ${WRKSRC}/${f}
>  .endfor
> + cp ${FILESDIR}/pinebook_defconfig ${WRKSRC}/configs/
> + cp ${FILESDIR}/sun50i-a64-pinebook.dts ${WRKSRC}/arch/arm/dts/
>  
>  do-build:
>  .for BOARD in ${BOARDS}
> Index: sysutils/u-boot/files/pinebook_defconfig
> ===
> RCS file: sysutils/u-boot/files/pinebook_defconfig
> diff -N sysutils/u-boot/files/pinebook_defconfig
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ sysutils/u-boot/files/pinebook_defconfig  30 Aug 2017 17:40:34 -
> @@ -0,0 +1,22 @@
> +CONFIG_ARM=y
> +CONFIG_ARCH_SUNXI=y
> +CONFIG_MACH_SUN50I=y
> +CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
> +CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
> +CONFIG_DRAM_CLK=552
> +CONFIG_DRAM_ZQ=3881949
> +CONFIG_DRAM_ODT_EN=y
> +CONFIG_MMC0_CD_PIN=""
> +CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> +CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pinebook"
> +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> +CONFIG_SPL=y
> +# CONFIG_CMD_IMLS is not set
> +# CONFIG_CMD_FLASH is not set
> +# CONFIG_CMD_FPGA is not set
> +# CONFIG_SPL_DOS_PARTITION is not set
> +# CONFIG_SPL_ISO_PARTITION is not set
> +# CONFIG_SPL_EFI_PARTITION is not set
> +CONFIG_SPL_SPI_SUNXI=y
> +CONFIG_SUN8I_EMAC=y
> +CONFIG_USB_EHCI_HCD=y
> Index: sysutils/u-boot/files/sun50i-a64-pinebook.dts
> ===
> RCS file: sysutils/u-boot/files/sun50i-a64-pinebook.dts
> diff -N sysutils/u-boot/files/sun50i-a64-pinebook.dts
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ sysutils/u-boot/files/sun50i-a64-pinebook.dts 30 Aug 2017 17:42:18 
> -
> @@ -0,0 +1,91 @@
> +/*
> + * Copyright (c) 2016 ARM Ltd.
> + *
> + * This file is dual-licensed: you can use it either under the terms
> + * of the GPL or the X11 license, at your option. Note that this dual
> + * licensing only applies to this file, and not this project as a
> + * whole.
> + *
> + *  a) This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of the
> + * License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * Or, alternatively,
> + *
> + *  b) Permission is hereby granted, free of charge, to any person
> + * obtaining a copy of this software and associated documentation
> + * 

Re: [phess...@openbsd.org: add pinebook support to u-boot]

2017-08-31 Thread Peter Hessler
On 2017 Aug 31 (Thu) at 10:41:41 +0200 (+0200), Peter Hessler wrote:
:On 2017 Aug 27 (Sun) at 22:15:46 +0200 (+0200), Peter Hessler wrote:
::- Forwarded message from Peter Hessler  -
::taken from Icenowy Zheng's repository,
::commit bd656cab0c3e0669e977641c15095f32d7b0731f
::
::This gives us basic support for the Pine64 Pinebook
::
::OK?
::
::$ sysctl hw
::hw.machine=arm64
::hw.model=ARM Cortex-A53 r0p4
::hw.ncpu=1
::hw.byteorder=1234
::hw.pagesize=4096
::hw.disknames=sd0:d76c5b9369f79257
::hw.diskcount=1
::hw.product=Pinebook
::hw.physmem=2021924864
::hw.usermem=2021912576
::hw.ncpufound=1
::hw.allowpowerdown=1
::
::
:
:Updated to chase rc3, move new files to file/, slight simplification to
:the defconfig.
:
:OK?
:

Better version, sorry for the noise

Index: sysutils/u-boot/Makefile
===
RCS file: /cvs/openbsd/ports/sysutils/u-boot/Makefile,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 Makefile
--- sysutils/u-boot/Makefile29 Aug 2017 07:14:50 -  1.26
+++ sysutils/u-boot/Makefile31 Aug 2017 08:42:35 -
@@ -7,6 +7,7 @@ FLAVOR?=arm
 
 COMMENT=   U-Boot firmware
 VERSION=   2017.09-rc3
+REVISION=  0
 DISTNAME=  u-boot-${VERSION}
 PKGNAME=   u-boot-${FLAVOR}-${VERSION:S/-//}
 FULLPKGNAME=   ${PKGNAME}
@@ -57,6 +58,7 @@ SUNXI64=\
orangepi_prime \
orangepi_win \
pine64_plus \
+   pinebook \
sopine_baseboard
 BOARDS=\
mvebu_espressobin-88f3720 \
@@ -140,6 +142,8 @@ pre-build:
 .for f in ${MODPY_ADJ_FILES}
${MODPY_BIN_ADJ} ${WRKSRC}/${f}
 .endfor
+   cp ${FILESDIR}/pinebook_defconfig ${WRKSRC}/configs/
+   cp ${FILESDIR}/sun50i-a64-pinebook.dts ${WRKSRC}/arch/arm/dts/
 
 do-build:
 .for BOARD in ${BOARDS}
Index: sysutils/u-boot/files/pinebook_defconfig
===
RCS file: sysutils/u-boot/files/pinebook_defconfig
diff -N sysutils/u-boot/files/pinebook_defconfig
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sysutils/u-boot/files/pinebook_defconfig30 Aug 2017 17:40:34 -
@@ -0,0 +1,22 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_MACH_SUN50I=y
+CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
+CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
+CONFIG_DRAM_CLK=552
+CONFIG_DRAM_ZQ=3881949
+CONFIG_DRAM_ODT_EN=y
+CONFIG_MMC0_CD_PIN=""
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pinebook"
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_ISO_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_SPL_SPI_SUNXI=y
+CONFIG_SUN8I_EMAC=y
+CONFIG_USB_EHCI_HCD=y
Index: sysutils/u-boot/files/sun50i-a64-pinebook.dts
===
RCS file: sysutils/u-boot/files/sun50i-a64-pinebook.dts
diff -N sysutils/u-boot/files/sun50i-a64-pinebook.dts
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sysutils/u-boot/files/sun50i-a64-pinebook.dts   30 Aug 2017 17:42:18 
-
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016 ARM Ltd.
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, 

Re: [phess...@openbsd.org: add pinebook support to u-boot]

2017-08-31 Thread Peter Hessler
On 2017 Aug 27 (Sun) at 22:15:46 +0200 (+0200), Peter Hessler wrote:
:- Forwarded message from Peter Hessler  -
:taken from Icenowy Zheng's repository,
:commit bd656cab0c3e0669e977641c15095f32d7b0731f
:
:This gives us basic support for the Pine64 Pinebook
:
:OK?
:
:$ sysctl hw
:hw.machine=arm64
:hw.model=ARM Cortex-A53 r0p4
:hw.ncpu=1
:hw.byteorder=1234
:hw.pagesize=4096
:hw.disknames=sd0:d76c5b9369f79257
:hw.diskcount=1
:hw.product=Pinebook
:hw.physmem=2021924864
:hw.usermem=2021912576
:hw.ncpufound=1
:hw.allowpowerdown=1
:
:

Updated to chase rc3, move new files to file/, slight simplification to
the defconfig.

OK?

Index: sysutils/u-boot/Makefile
===
RCS file: /cvs/openbsd/ports/sysutils/u-boot/Makefile,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 Makefile
--- sysutils/u-boot/Makefile29 Aug 2017 07:14:50 -  1.26
+++ sysutils/u-boot/Makefile31 Aug 2017 08:37:57 -
@@ -7,6 +7,7 @@ FLAVOR?=arm
 
 COMMENT=   U-Boot firmware
 VERSION=   2017.09-rc3
+REVISION=  0
 DISTNAME=  u-boot-${VERSION}
 PKGNAME=   u-boot-${FLAVOR}-${VERSION:S/-//}
 FULLPKGNAME=   ${PKGNAME}
@@ -57,6 +58,7 @@ SUNXI64=\
orangepi_prime \
orangepi_win \
pine64_plus \
+   pinebook \
sopine_baseboard
 BOARDS=\
mvebu_espressobin-88f3720 \
@@ -140,6 +142,9 @@ pre-build:
 .for f in ${MODPY_ADJ_FILES}
${MODPY_BIN_ADJ} ${WRKSRC}/${f}
 .endfor
+   cp ${FILESDIR}/pinebook_defconfig ${WRKSRC}/configs/
+   cp ${FILESDIR}/sun50i-a64-pinebook.dts ${WRKSRC}/arch/arm/dts/
+   cp ${FILESDIR}/sun50i-a64-pine64-common.dtsi ${WRKSRC}/arch/arm/dts/
 
 do-build:
 .for BOARD in ${BOARDS}
Index: sysutils/u-boot/files/pinebook_defconfig
===
RCS file: sysutils/u-boot/files/pinebook_defconfig
diff -N sysutils/u-boot/files/pinebook_defconfig
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sysutils/u-boot/files/pinebook_defconfig30 Aug 2017 17:40:34 -
@@ -0,0 +1,22 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_MACH_SUN50I=y
+CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
+CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
+CONFIG_DRAM_CLK=552
+CONFIG_DRAM_ZQ=3881949
+CONFIG_DRAM_ODT_EN=y
+CONFIG_MMC0_CD_PIN=""
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pinebook"
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_ISO_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_SPL_SPI_SUNXI=y
+CONFIG_SUN8I_EMAC=y
+CONFIG_USB_EHCI_HCD=y
Index: sysutils/u-boot/files/sun50i-a64-pinebook.dts
===
RCS file: sysutils/u-boot/files/sun50i-a64-pinebook.dts
diff -N sysutils/u-boot/files/sun50i-a64-pinebook.dts
--- /dev/null   1 Jan 1970 00:00:00 -
+++ sysutils/u-boot/files/sun50i-a64-pinebook.dts   30 Aug 2017 17:42:18 
-
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016 ARM Ltd.
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF 

Re: include pinebook firmware in the install media

2017-08-31 Thread Peter Hessler
On 2017 Aug 27 (Sun) at 21:54:07 +0200 (+0200), Peter Hessler wrote:
:(this depends on the patch to u-boot I just sent to ports@)
:
:If we should manage to boot on a Pinebook machine, we should install the
:correct firmware for it.
:
:OK?
:

Updated to a now working copy!  This grew bsd.rd a bit.  After
discussion with patrick@, we decided to grow from 7.5M to 9M.

This survives a bsd.rd Upgrade on my pinebook.  Still depends on the
u-boot port update, a new version will be emailed shortly.

OK?

Index: distrib/arm64/ramdisk/Makefile
===
RCS file: /cvs/src/distrib/arm64/ramdisk/Makefile,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 Makefile
--- distrib/arm64/ramdisk/Makefile  22 Aug 2017 23:20:00 -  1.3
+++ distrib/arm64/ramdisk/Makefile  31 Aug 2017 08:23:18 -
@@ -19,6 +19,7 @@ MAKEFSARGS_RD=-o disklabel=${DISKTYPE},
 
 DIRS=\
pine64 \
+   pinebook \
rpi
 
 .ifndef DESTDIR
Index: distrib/arm64/ramdisk/install.md
===
RCS file: /cvs/src/distrib/arm64/ramdisk/install.md,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 install.md
--- distrib/arm64/ramdisk/install.md22 Aug 2017 23:20:00 -  1.7
+++ distrib/arm64/ramdisk/install.md31 Aug 2017 08:23:18 -
@@ -40,6 +40,7 @@ md_installboot() {
 
case $(sysctl -n hw.product) in
*Pine64*)   _plat=pine64;;
+   *Pinebook*) _plat=pinebook;;
*'Raspberry Pi'*)   _plat=rpi;;
esac
 
@@ -52,7 +53,7 @@ md_installboot() {
_mdec=/usr/mdec/$_plat
 
case $_plat in
-   pine64)
+   pine64|pinebook)
dd if=$_mdec/u-boot-sunxi-with-spl.bin of=${_disk}c \
bs=1024 seek=8 >/dev/null 2>&1
;;
Index: distrib/arm64/ramdisk/list
===
RCS file: /cvs/src/distrib/arm64/ramdisk/list,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 list
--- distrib/arm64/ramdisk/list  22 Aug 2017 23:20:00 -  1.5
+++ distrib/arm64/ramdisk/list  31 Aug 2017 08:23:18 -
@@ -125,5 +125,6 @@ COPY/usr/local/share/raspberrypi-firmwa
 COPY   /usr/local/share/u-boot/rpi_3/u-boot.bin usr/mdec/rpi/u-boot.bin
 
 COPY   /usr/local/share/u-boot/pine64_plus/u-boot-sunxi-with-spl.bin 
usr/mdec/pine64/u-boot-sunxi-with-spl.bin
+COPY   /usr/local/share/u-boot/pinebook/u-boot-sunxi-with-spl.bin 
usr/mdec/pinebook/u-boot-sunxi-with-spl.bin
 
 TZ
Index: etc/etc.arm64/disktab
===
RCS file: /cvs/src/etc/etc.arm64/disktab,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 disktab
--- etc/etc.arm64/disktab   11 Jan 2017 17:05:29 -  1.1
+++ etc/etc.arm64/disktab   31 Aug 2017 08:23:18 -
@@ -2,9 +2,9 @@
 
 # Leave nc=16; adjust size using: ns
 rdroot|ramdiskroot|RAM-disk root FS image:\
-   :dt=rdroot:se#512:nc#16:nt#2:ns#480:\
-   :ta=4.2BSD:oa#0:pa#15360:fa#512:ba#4096:\
-   :ob#0:pb#0:oc#0:pc#15360:
+   :dt=rdroot:se#512:nc#16:nt#2:ns#576:\
+   :ta=4.2BSD:oa#0:pa#18432:fa#512:ba#4096:\
+   :ob#0:pb#0:oc#0:pc#18432:
 
 miniroot:\
:dt=rdroot:se#512:nc#9:nt#16:ns#256:\
Index: sys/arch/arm64/conf/RAMDISK
===
RCS file: /cvs/src/sys/arch/arm64/conf/RAMDISK,v
retrieving revision 1.35
diff -u -p -u -p -r1.35 RAMDISK
--- sys/arch/arm64/conf/RAMDISK 28 Aug 2017 11:16:04 -  1.35
+++ sys/arch/arm64/conf/RAMDISK 31 Aug 2017 08:23:18 -
@@ -30,7 +30,7 @@ optionNO_PROPOLICE
 option BOOT_CONFIG
 
 option RAMDISK_HOOKS
-option MINIROOTSIZE=15360
+option MINIROOTSIZE=18432
 
 option FFS
 option FFS2




-- 
"Wrong," said Renner.

"The tactful way," Rod said quietly, "the polite way to disagree with
the Senator would be to say, `That turns out not to be the case.'"



Re: [PATCH] VMD: Ensure disk is a regular file prior to vm boot

2017-08-31 Thread Mike Larkin
On Wed, Aug 30, 2017 at 04:56:20PM -0700, Carlos Cardenas wrote:
> Add check(s) in vmd/vmctl to ensure a VM's disk are regular files.
> 
> Tested with the following:
> vmctl start "test1" -d /dev/sd3c #block device
> vmctl start "test2" -d /dev/rsd3c #char device
> vmctl start "test3" -d fifo #named pipe
> 
> Comments? Ok?
> 

Looks good, committed. Thanks!

-ml

> diff --git usr.sbin/vmctl/vmctl.c usr.sbin/vmctl/vmctl.c
> index f694f61e48c..e3db6a78c5b 100644
> --- usr.sbin/vmctl/vmctl.c
> +++ usr.sbin/vmctl/vmctl.c
> @@ -204,6 +204,11 @@ vm_start_complete(struct imsg *imsg, int *ret, int 
> autoconnect)
>   warnx("could not find specified disk image(s)");
>   *ret = ENOENT;
>   break;
> + case VMD_DISK_INVALID:
> + warnx("specified disk image(s) are "
> +"not regular files");
> + *ret = ENOENT;
> + break;
>   default:
>   errno = res;
>   warn("start vm command failed");
> diff --git usr.sbin/vmd/config.c usr.sbin/vmd/config.c
> index 1e1166f8263..ced7ab666b4 100644
> --- usr.sbin/vmd/config.c
> +++ usr.sbin/vmd/config.c
> @@ -20,6 +20,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -157,6 +158,7 @@ config_setvm(struct privsep *ps, struct vmd_vm *vm, 
> uint32_t peerid, uid_t uid)
>   struct vmd_if   *vif;
>   struct vmop_create_params *vmc = >vm_params;
>   struct vm_create_params *vcp = >vmc_params;
> + struct stat  stat_buf;
>   unsigned int i;
>   int  fd = -1, vmboot = 0;
>   int  kernfd = -1, *diskfds = NULL, *tapfds = NULL;
> @@ -225,6 +227,19 @@ config_setvm(struct privsep *ps, struct vmd_vm *vm, 
> uint32_t peerid, uid_t uid)
>  
>   /* Open disk images for child */
>   for (i = 0 ; i < vcp->vcp_ndisks; i++) {
> +/* Stat disk[i] to ensure it is a regular file */
> +if (stat(vcp->vcp_disks[i], _buf) == -1) {
> + log_warn("%s: can't open disk %s", __func__,
> + vcp->vcp_disks[i]);
> + errno = VMD_DISK_MISSING;
> + goto fail;
> +}
> +if (S_ISREG(stat_buf.st_mode) == 0) {
> + log_warn("%s: disk %s is not a regular file", __func__,
> + vcp->vcp_disks[i]);
> + errno = VMD_DISK_INVALID;
> + goto fail;
> +}
>   if ((diskfds[i] =
>   open(vcp->vcp_disks[i], O_RDWR)) == -1) {
>   log_warn("%s: can't open disk %s", __func__,
> diff --git usr.sbin/vmd/vmd.h usr.sbin/vmd/vmd.h
> index 57bdb71cd5f..daeffa7c80e 100644
> --- usr.sbin/vmd/vmd.h
> +++ usr.sbin/vmd/vmd.h
> @@ -53,6 +53,7 @@
>  /* vmd -> vmctl error codes */
>  #define VMD_BIOS_MISSING 1001
>  #define VMD_DISK_MISSING 1002
> +#define VMD_DISK_INVALID 1003
>  
>  /* 100.64.0.0/10 from rfc6598 (IPv4 Prefix for Shared Address Space) */
>  #define VMD_DHCP_PREFIX  "100.64.0.0/10"
> -- 
> 2.14.1
> 



Re: [PATCH] vm.conf: Clarify VM name constraints

2017-08-31 Thread Mike Larkin
On Thu, Aug 31, 2017 at 08:11:55AM +0200, Jasper Lievisse Adriaanse wrote:
> On Wed, Aug 30, 2017 at 05:11:26PM -0700, Carlos Cardenas wrote:
> > Add VM name constraints to match those in vmctl.8 manpage.
> > 
> > Comments? Ok?
> Applied, thanks.
>  
> > diff --git usr.sbin/vmd/vm.conf.5 usr.sbin/vmd/vm.conf.5
> > index d1e68dbce5d..77a7a4e8cea 100644
> > --- usr.sbin/vmd/vm.conf.5
> > +++ usr.sbin/vmd/vm.conf.5
> > @@ -108,7 +108,9 @@ section starts with a declaration of the virtual machine
> >  .Ar name :
> >  .Bl -tag -width Ds
> >  .It Ic vm Ar name Brq ...
> > -This name can be any string, and is typically a hostname.
> > +The name can be any alphanumeric string along with '.', '-', and '_'  
> > +characters.  However, it cannot start with '.', '-', or '_'.  
> > +Typically the name is a hostname.
> >  .El
> >  .Pp
> >  Followed by a block of parameters that is enclosed in curly brackets:
> > -- 
> > 2.14.1
> > 
> 
> -- 
> jasper
> 

Ah, thanks. You beat me to it :)



Re: [PATCH] VMD: Ensure disk is a regular file prior to vm boot

2017-08-31 Thread Mike Larkin
On Thu, Aug 31, 2017 at 06:56:45AM +0100, Raf Czlonka wrote:
> Hi Carlos,
> 
> Doesn't this mean that, even though it might not be possible to do
> this today (is it?), you're effectively disabling the usage of
> physical disks for VMs, i.e. equivalent of a raw disk device used
> in other hypervisors?
> 
> Regards,
> 
> Raf
> 

Use of raw block or character devices is not supported today and is not
easily achievable in the near term. Using a block device is blocked
in the kernel UIPC layer and using a character device doesn't work because
of some limitations in the seeking capability of such devices.

Today if you try to use such devices you are presented with a confusing
and misleading error message. Carlos' diff is a step in the right direction.
Should someone come along later and make raw devices work, this diff can
be easily removed.

-ml


> On Thu, Aug 31, 2017 at 12:56:20AM BST, Carlos Cardenas wrote:
> > Add check(s) in vmd/vmctl to ensure a VM's disk are regular files.
> > 
> > Tested with the following:
> > vmctl start "test1" -d /dev/sd3c #block device
> > vmctl start "test2" -d /dev/rsd3c #char device
> > vmctl start "test3" -d fifo #named pipe
> > 
> > Comments? Ok?
> > 
> > diff --git usr.sbin/vmctl/vmctl.c usr.sbin/vmctl/vmctl.c
> > index f694f61e48c..e3db6a78c5b 100644
> > --- usr.sbin/vmctl/vmctl.c
> > +++ usr.sbin/vmctl/vmctl.c
> > @@ -204,6 +204,11 @@ vm_start_complete(struct imsg *imsg, int *ret, int 
> > autoconnect)
> > warnx("could not find specified disk image(s)");
> > *ret = ENOENT;
> > break;
> > +   case VMD_DISK_INVALID:
> > +   warnx("specified disk image(s) are "
> > +"not regular files");
> > +   *ret = ENOENT;
> > +   break;
> > default:
> > errno = res;
> > warn("start vm command failed");
> > diff --git usr.sbin/vmd/config.c usr.sbin/vmd/config.c
> > index 1e1166f8263..ced7ab666b4 100644
> > --- usr.sbin/vmd/config.c
> > +++ usr.sbin/vmd/config.c
> > @@ -20,6 +20,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  
> >  #include 
> > @@ -157,6 +158,7 @@ config_setvm(struct privsep *ps, struct vmd_vm *vm, 
> > uint32_t peerid, uid_t uid)
> > struct vmd_if   *vif;
> > struct vmop_create_params *vmc = >vm_params;
> > struct vm_create_params *vcp = >vmc_params;
> > +   struct stat  stat_buf;
> > unsigned int i;
> > int  fd = -1, vmboot = 0;
> > int  kernfd = -1, *diskfds = NULL, *tapfds = NULL;
> > @@ -225,6 +227,19 @@ config_setvm(struct privsep *ps, struct vmd_vm *vm, 
> > uint32_t peerid, uid_t uid)
> >  
> > /* Open disk images for child */
> > for (i = 0 ; i < vcp->vcp_ndisks; i++) {
> > +/* Stat disk[i] to ensure it is a regular file */
> > +if (stat(vcp->vcp_disks[i], _buf) == -1) {
> > +   log_warn("%s: can't open disk %s", __func__,
> > +   vcp->vcp_disks[i]);
> > +   errno = VMD_DISK_MISSING;
> > +   goto fail;
> > +}
> > +if (S_ISREG(stat_buf.st_mode) == 0) {
> > +   log_warn("%s: disk %s is not a regular file", __func__,
> > +   vcp->vcp_disks[i]);
> > +   errno = VMD_DISK_INVALID;
> > +   goto fail;
> > +}
> > if ((diskfds[i] =
> > open(vcp->vcp_disks[i], O_RDWR)) == -1) {
> > log_warn("%s: can't open disk %s", __func__,
> > diff --git usr.sbin/vmd/vmd.h usr.sbin/vmd/vmd.h
> > index 57bdb71cd5f..daeffa7c80e 100644
> > --- usr.sbin/vmd/vmd.h
> > +++ usr.sbin/vmd/vmd.h
> > @@ -53,6 +53,7 @@
> >  /* vmd -> vmctl error codes */
> >  #define VMD_BIOS_MISSING   1001
> >  #define VMD_DISK_MISSING   1002
> > +#define VMD_DISK_INVALID   1003
> >  
> >  /* 100.64.0.0/10 from rfc6598 (IPv4 Prefix for Shared Address Space) */
> >  #define VMD_DHCP_PREFIX"100.64.0.0/10"
> > -- 
> > 2.14.1
> > 
> 
> -- 
> Raf Czlonka
> Support Systems Analyst
> Clinical School Computing Service, School of Clinical Medicine
> University of Cambridge, Box 111 Cambridge Biomedical Campus
> Cambridge, CB2 0SP, Tel. 01223 (7)46728
> 



Re: Unbreak DEBUG for nfsd(8)

2017-08-31 Thread Otto Moerbeek
On Wed, Aug 30, 2017 at 08:01:36PM +0100, Ricardo Mestre wrote:

> On 19:30 Wed 30 Aug , Otto Moerbeek wrote:
> > On Wed, Aug 30, 2017 at 05:54:16PM +0100, Ricardo Mestre wrote:
> > 
> > > Hi,
> > > 
> > > Unbreak DEBUG for nfsd(8), this one was caught with cppcheck.
> > > 
> > > It has been broken for about 7 years ago when a couple of errx calls, 
> > > which had
> > > string format arguments, were replaced by syslog calls.
> > 
> > Can you please formulate this without using a GNU extension, i.e. the
> > standard knows 
> > 
> > #define X A(a, ...) bla
> > 
> > but not 
> > 
> > #define X A(a...)   bla
> > 
> > -Otto
> > 
> 
> Hi Otto,
> 
> Something like this then?
> 
> I also had to convert a few syslog calls since fprintf doesn't know about %m,
> so in those cases I added strerror to them.

Looks good.

-Otto
> 
> Index: nfsd.c
> ===
> RCS file: /cvs/src/sbin/nfsd/nfsd.c,v
> retrieving revision 1.36
> diff -u -p -u -r1.36 nfsd.c
> --- nfsd.c7 Jun 2016 01:29:38 -   1.36
> +++ nfsd.c30 Aug 2017 18:57:56 -
> @@ -64,7 +64,11 @@
>  
>  /* Global defs */
>  #ifdef DEBUG
> -#define  syslog(e, s)fprintf(stderr,(s))
> +#define  syslog(e, s, ...)   \
> +do { \
> + fprintf(stderr, (s), ##__VA_ARGS__);\
> + fprintf(stderr, "\n");  \
> +} while (0)
>  int  debug = 1;
>  #else
>  int  debug = 0;
> @@ -163,13 +167,15 @@ main(int argc, char *argv[])
>   if (udpflag &&
>   (!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) ||
>!pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT))) {
> - syslog(LOG_ERR, "can't register with portmap for UDP 
> (%m).");
> + syslog(LOG_ERR, "can't register with portmap for UDP 
> (%s).",
> + strerror(errno));
>   return (1);
>   }
>   if (tcpflag &&
>   (!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) ||
>!pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT))) {
> - syslog(LOG_ERR, "can't register with portmap for TCP 
> (%m).");
> + syslog(LOG_ERR, "can't register with portmap for TCP 
> (%s).",
> + strerror(errno));
>   return (1);
>   }
>   return (0);
> @@ -182,7 +188,7 @@ main(int argc, char *argv[])
>   for (i = 0; i < nfsdcnt; i++) {
>   switch (fork()) {
>   case -1:
> - syslog(LOG_ERR, "fork: %m");
> + syslog(LOG_ERR, "fork: %s", strerror(errno));
>   return (1);
>   case 0:
>   break;
> @@ -193,7 +199,7 @@ main(int argc, char *argv[])
>   setproctitle("server");
>   nsd.nsd_nfsd = NULL;
>   if (nfssvc(NFSSVC_NFSD, ) < 0) {
> - syslog(LOG_ERR, "nfssvc: %m");
> + syslog(LOG_ERR, "nfssvc: %s", strerror(errno));
>   return (1);
>   }
>   return (0);
> @@ -240,7 +246,7 @@ main(int argc, char *argv[])
>   }
>   if (setsockopt(tcpsock,
>   SOL_SOCKET, SO_REUSEADDR, , sizeof(on)) < 0)
> - syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m");
> + syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %s", 
> strerror(errno));
>   memset(, 0, sizeof inetaddr);
>   inetaddr.sin_family = AF_INET;
>   inetaddr.sin_addr.s_addr = INADDR_ANY;
> @@ -284,7 +290,7 @@ main(int argc, char *argv[])
>   if (connect_type_cnt > 1) {
>   ret = poll(, 1, INFTIM);
>   if (ret < 1) {
> - syslog(LOG_ERR, "poll failed: %m");
> + syslog(LOG_ERR, "poll failed: %s", 
> strerror(errno));
>   return (1);
>   }
>   
> @@ -297,14 +303,14 @@ main(int argc, char *argv[])
>   if (errno == EWOULDBLOCK || errno == EINTR ||
>   errno == ECONNABORTED)
>   continue;
> - syslog(LOG_ERR, "accept failed: %m");
> + syslog(LOG_ERR, "accept failed: %s", 
> strerror(errno));
>   return (1);
>   }
>   memset(inetpeer.sin_zero, 0, sizeof(inetpeer.sin_zero));
>   if (setsockopt(msgsock, SOL_SOCKET,
>   SO_KEEPALIVE, , sizeof(on)) < 0)
>   syslog(LOG_ERR,
> - "setsockopt SO_KEEPALIVE: %m");
> +  

Re: [PATCH] vm.conf: Clarify VM name constraints

2017-08-31 Thread Jasper Lievisse Adriaanse
On Wed, Aug 30, 2017 at 05:11:26PM -0700, Carlos Cardenas wrote:
> Add VM name constraints to match those in vmctl.8 manpage.
> 
> Comments? Ok?
Applied, thanks.
 
> diff --git usr.sbin/vmd/vm.conf.5 usr.sbin/vmd/vm.conf.5
> index d1e68dbce5d..77a7a4e8cea 100644
> --- usr.sbin/vmd/vm.conf.5
> +++ usr.sbin/vmd/vm.conf.5
> @@ -108,7 +108,9 @@ section starts with a declaration of the virtual machine
>  .Ar name :
>  .Bl -tag -width Ds
>  .It Ic vm Ar name Brq ...
> -This name can be any string, and is typically a hostname.
> +The name can be any alphanumeric string along with '.', '-', and '_'  
> +characters.  However, it cannot start with '.', '-', or '_'.  
> +Typically the name is a hostname.
>  .El
>  .Pp
>  Followed by a block of parameters that is enclosed in curly brackets:
> -- 
> 2.14.1
> 

-- 
jasper