Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Pawel Jakub Dawidek
On Mon, Jun 04, 2012 at 09:34:49PM +, Andrey A. Chernov wrote:
> Author: ache
> Date: Mon Jun  4 21:34:49 2012
> New Revision: 236582
> URL: http://svn.freebsd.org/changeset/base/236582
> 
> Log:
>   1) IEEE Std 1003.1-2008, "errno" section, is explicit that
>   
>   "The setting of errno after a successful call to a function is
>   unspecified unless the description of that function specifies that
>   errno shall not be modified."

Very interesting. However free(3) is always successful. Maybe we need
more context here, but the sentence above might talk about functions
that can either succeed or fail and such functions do set errno on
failure, but we don't know what they do to errno on success - they
sometimes interact with the errno, free(3) never does.

I aware that my interpretation might be too wishful, but it is pretty
obvious to save errno value when calling a function that can eventually
fail - when we save the errno we don't know if it will fail or not, so
we have to do that, but requiring to save errno when calling a void
function that can't fail is simply silly and complicates the code
without a reason.

>   However, free() in IEEE Std 1003.1-2008 does not mention its interaction
>   with errno, so MAY modify it after successful call
>   (it depends on particular free() implementation, OS-specific, etc.).

Expecting documentation to describe interaction with some global
variable that it doesn't need is pretty silly too (ok, errno is special,
but still). It make sense to describe all the cases when the function
actually is sometimes using the global variable, but for a function that
never fails and should never touch the global it doesn't make sense.
Maybe that's why it doesn't mention interaction with errno?

I agree that the standards aren't clear, but if saving errno around
free(3) is the way to go, then I'm sure we have much more problems in
our code, even if it is not suppose to be portable it should be correct
- we never know who and when will take the code and port it.

I guess what I'm trying to say here is that this is much bigger change
than it looks and we should probably agree on some global rule here.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpFISCr9twym.pgp
Description: PGP signature


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Dimitry Andric
On 2012-06-04 23:34, Andrey A. Chernov wrote:> Author: ache
> Date: Mon Jun  4 21:34:49 2012
> New Revision: 236582
> URL: http://svn.freebsd.org/changeset/base/236582
> 
> Log:
>   1) IEEE Std 1003.1-2008, "errno" section, is explicit that
>   
>   "The setting of errno after a successful call to a function is
>   unspecified unless the description of that function specifies that
>   errno shall not be modified."
>   
>   However, free() in IEEE Std 1003.1-2008 does not mention its interaction
>   with errno, so MAY modify it after successful call
>   (it depends on particular free() implementation, OS-specific, etc.).

Actually, it says the following:

  RETURN VALUE

  The free() function shall not return a value.

  ERRORS

  No errors are defined.

How much clearer do you want it? ;)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Konstantin Belousov
On Tue, Jun 05, 2012 at 10:08:09AM +0200, Dimitry Andric wrote:
> On 2012-06-04 23:34, Andrey A. Chernov wrote:> Author: ache
> > Date: Mon Jun  4 21:34:49 2012
> > New Revision: 236582
> > URL: http://svn.freebsd.org/changeset/base/236582
> > 
> > Log:
> >   1) IEEE Std 1003.1-2008, "errno" section, is explicit that
> >   
> >   "The setting of errno after a successful call to a function is
> >   unspecified unless the description of that function specifies that
> >   errno shall not be modified."
> >   
> >   However, free() in IEEE Std 1003.1-2008 does not mention its interaction
> >   with errno, so MAY modify it after successful call
> >   (it depends on particular free() implementation, OS-specific, etc.).
> 
> Actually, it says the following:
> 
>   RETURN VALUE
> 
>   The free() function shall not return a value.
> 
>   ERRORS
> 
>   No errors are defined.
> 
> How much clearer do you want it? ;)
Not to mention that the patch was committed to _our_ implementation of
libc, which uses _our_ free, and not some abstract free(3). Our free changing
errno means that process state is so messed that worrying about realpath(3)
correctness is beyond any expectations.

I already described my POV to ache, but it seems that nobody listens. It just
a season, it seems.


pgpP5T65GIEKL.pgp
Description: PGP signature


svn commit: r236602 - in head/sys/cam: ata scsi

2012-06-05 Thread Alexander Motin
Author: mav
Date: Tue Jun  5 09:45:42 2012
New Revision: 236602
URL: http://svn.freebsd.org/changeset/base/236602

Log:
  Tune and add some missing CAM_DEBUG() points for better consistency.

Modified:
  head/sys/cam/ata/ata_da.c
  head/sys/cam/ata/ata_pmp.c
  head/sys/cam/scsi/scsi_cd.c
  head/sys/cam/scsi/scsi_da.c
  head/sys/cam/scsi/scsi_pt.c

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Tue Jun  5 06:43:45 2012(r236601)
+++ head/sys/cam/ata/ata_da.c   Tue Jun  5 09:45:42 2012(r236602)
@@ -436,9 +436,8 @@ adaopen(struct disk *dp)
softc = (struct ada_softc *)periph->softc;
softc->flags |= ADA_FLAG_OPEN;
 
-   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE,
-   ("adaopen: disk=%s%d (unit %d)\n", dp->d_name, dp->d_unit,
-periph->unit_number));
+   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH,
+   ("adaopen\n"));
 
if ((softc->flags & ADA_FLAG_PACK_INVALID) != 0) {
/* Invalidate our pack information. */
@@ -469,6 +468,10 @@ adaclose(struct disk *dp)
}
 
softc = (struct ada_softc *)periph->softc;
+
+   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH,
+   ("adaclose\n"));
+
/* We only sync the cache if the drive is capable of it. */
if ((softc->flags & ADA_FLAG_CAN_FLUSHCACHE) != 0 &&
(softc->flags & ADA_FLAG_PACK_INVALID) == 0) {
@@ -542,6 +545,8 @@ adastrategy(struct bio *bp)
 
cam_periph_lock(periph);
 
+   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("adastrategy(%p)\n", bp));
+
/*
 * If the device has been made invalid, error out
 */
@@ -1167,6 +1172,8 @@ adastart(struct cam_periph *periph, unio
struct ada_softc *softc = (struct ada_softc *)periph->softc;
struct ccb_ataio *ataio = &start_ccb->ataio;
 
+   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("adastart\n"));
+
switch (softc->state) {
case ADA_STATE_NORMAL:
{
@@ -1175,7 +1182,7 @@ adastart(struct cam_periph *periph, unio
 
/* Execute immediate CCB if waiting. */
if (periph->immediate_priority <= periph->pinfo.priority) {
-   CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE,
+   CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE,
("queuing for immediate ccb\n"));
start_ccb->ccb_h.ccb_state = ADA_CCB_WAITING;
SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h,
@@ -1467,6 +1474,9 @@ adadone(struct cam_periph *periph, union
 
softc = (struct ada_softc *)periph->softc;
ataio = &done_ccb->ataio;
+
+   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("adadone\n"));
+
switch (ataio->ccb_h.ccb_state & ADA_CCB_TYPE_MASK) {
case ADA_CCB_BUFFER_IO:
case ADA_CCB_TRIM:

Modified: head/sys/cam/ata/ata_pmp.c
==
--- head/sys/cam/ata/ata_pmp.c  Tue Jun  5 06:43:45 2012(r236601)
+++ head/sys/cam/ata/ata_pmp.c  Tue Jun  5 09:45:42 2012(r236602)
@@ -429,7 +429,9 @@ pmpstart(struct cam_periph *periph, unio
 
softc = (struct pmp_softc *)periph->softc;
ataio = &start_ccb->ataio;
-   
+
+   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("pmpstart\n"));
+
if (softc->restart) {
softc->restart = 0;
softc->state = min(softc->state, PMP_STATE_PRECONFIG);
@@ -560,7 +562,7 @@ pmpdone(struct cam_periph *periph, union
softc = (struct pmp_softc *)periph->softc;
ataio = &done_ccb->ataio;
 
-   CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("pmpdone\n"));
+   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("pmpdone\n"));
 
priority = done_ccb->ccb_h.pinfo.priority;
 

Modified: head/sys/cam/scsi/scsi_cd.c
==
--- head/sys/cam/scsi/scsi_cd.c Tue Jun  5 06:43:45 2012(r236601)
+++ head/sys/cam/scsi/scsi_cd.c Tue Jun  5 09:45:42 2012(r236602)
@@ -1014,6 +1014,9 @@ cdopen(struct disk *dp)
return (error);
}
 
+   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH,
+   ("cdopen\n"));
+
/*
 * Check for media, and set the appropriate flags.  We don't bail
 * if we don't have media, but then we don't allow anything but the
@@ -1051,6 +1054,9 @@ cdclose(struct disk *dp)
cam_periph_lock(periph);
cam_periph_hold(periph, PRIBIO);
 
+   CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH,
+   ("cdclose\n"));
+
if ((softc->flags & CD_FLAG_DISC_REMOVABLE) != 0)
cdprevent(periph, PR_ALLOW);
 
@@ -1395,7 +1401,8 @@ cdstrategy(struct bio *bp)
}
 
cam_periph_lock(periph);
-   CAM_DEB

svn commit: r236604 - head/sys/cam/scsi

2012-06-05 Thread Alexander Motin
Author: mav
Date: Tue Jun  5 10:08:22 2012
New Revision: 236604
URL: http://svn.freebsd.org/changeset/base/236604

Log:
  Do not reinvent a wheel and let default error handler do its job.

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Tue Jun  5 09:49:31 2012(r236603)
+++ head/sys/cam/scsi/scsi_da.c Tue Jun  5 10:08:22 2012(r236604)
@@ -1016,30 +1016,9 @@ daclose(struct disk *dp)
   SSD_FULL_SIZE,
   5 * 60 * 1000);
 
-   cam_periph_runccb(ccb, /*error_routine*/NULL, /*cam_flags*/0,
- /*sense_flags*/SF_RETRY_UA,
+   cam_periph_runccb(ccb, daerror, /*cam_flags*/0,
+ /*sense_flags*/SF_RETRY_UA | SF_QUIET_IR,
  softc->disk->d_devstat);
-
-   if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
-   if ((ccb->ccb_h.status & CAM_STATUS_MASK) ==
-CAM_SCSI_STATUS_ERROR) {
-   int asc, ascq;
-   int sense_key, error_code;
-
-   scsi_extract_sense_len(&ccb->csio.sense_data,
-   ccb->csio.sense_len - ccb->csio.sense_resid,
-   &error_code, &sense_key, &asc, &ascq,
-   /*show_errors*/ 1);
-   if (sense_key != SSD_KEY_ILLEGAL_REQUEST)
-   scsi_sense_print(&ccb->csio);
-   } else {
-   xpt_print(periph->path, "Synchronize cache "
-   "failed, status == 0x%x, scsi status == "
-   "0x%x\n", ccb->csio.ccb_h.status,
-   ccb->csio.scsi_status);
-   }
-   }
-
xpt_release_ccb(ccb);
 
}
@@ -2541,8 +2520,8 @@ daprevent(struct cam_periph *periph, int
 SSD_FULL_SIZE,
 5000);
 
-   error = cam_periph_runccb(ccb, /*error_routine*/NULL, CAM_RETRY_SELTO,
- SF_RETRY_UA, softc->disk->d_devstat);
+   error = cam_periph_runccb(ccb, daerror, CAM_RETRY_SELTO,
+   SF_RETRY_UA | SF_QUIET_IR, softc->disk->d_devstat);
 
if (error == 0) {
if (action == PR_ALLOW)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236605 - head/sys/cam

2012-06-05 Thread Alexander Motin
Author: mav
Date: Tue Jun  5 10:23:41 2012
New Revision: 236605
URL: http://svn.freebsd.org/changeset/base/236605

Log:
  Replace #ifdef CAMDEBUG + if + panic() with single KASSERT().

Modified:
  head/sys/cam/cam_xpt.c

Modified: head/sys/cam/cam_xpt.c
==
--- head/sys/cam/cam_xpt.c  Tue Jun  5 10:08:22 2012(r236604)
+++ head/sys/cam/cam_xpt.c  Tue Jun  5 10:23:41 2012(r236605)
@@ -3226,13 +3226,8 @@ xpt_run_dev_allocq(struct cam_eb *bus)
("running device %p\n", device));
 
drvq = &device->drvq;
-
-#ifdef CAMDEBUG
-   if (drvq->entries <= 0) {
-   panic("xpt_run_dev_allocq: "
- "Device on queue without any work to do");
-   }
-#endif
+   KASSERT(drvq->entries > 0, ("xpt_run_dev_allocq: "
+   "Device on queue without any work to do"));
if ((work_ccb = xpt_get_ccb(device)) != NULL) {
devq->alloc_openings--;
devq->alloc_active++;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236613 - in head/sys/cam: ata scsi

2012-06-05 Thread Alexander Motin
Author: mav
Date: Tue Jun  5 11:48:32 2012
New Revision: 236613
URL: http://svn.freebsd.org/changeset/base/236613

Log:
  Tune and add some more CAM_DEBUG() points for the probe sequences.

Modified:
  head/sys/cam/ata/ata_xpt.c
  head/sys/cam/scsi/scsi_xpt.c

Modified: head/sys/cam/ata/ata_xpt.c
==
--- head/sys/cam/ata/ata_xpt.c  Tue Jun  5 11:42:34 2012(r236612)
+++ head/sys/cam/ata/ata_xpt.c  Tue Jun  5 11:48:32 2012(r236613)
@@ -96,6 +96,7 @@ typedef enum {
PROBE_PM_PRV,
PROBE_IDENTIFY_SES,
PROBE_IDENTIFY_SAFTE,
+   PROBE_DONE,
PROBE_INVALID
 } probe_action;
 
@@ -115,6 +116,7 @@ static char *probe_action_text[] = {
"PROBE_PM_PRV",
"PROBE_IDENTIFY_SES",
"PROBE_IDENTIFY_SAFTE",
+   "PROBE_DONE",
"PROBE_INVALID"
 };
 
@@ -122,7 +124,7 @@ static char *probe_action_text[] = {
 do {   \
char **text;\
text = probe_action_text;   \
-   CAM_DEBUG((softc)->periph->path, CAM_DEBUG_INFO,\
+   CAM_DEBUG((softc)->periph->path, CAM_DEBUG_PROBE,   \
("Probe %s to %s\n", text[(softc)->action], \
text[(newaction)]));\
(softc)->action = (newaction);  \
@@ -251,6 +253,8 @@ proberegister(struct cam_periph *periph,
if (status != CAM_REQ_CMP) {
return (status);
}
+   CAM_DEBUG(periph->path, CAM_DEBUG_PROBE, ("Probe started\n"));
+
/*
 * Ensure nobody slip in until probe finish.
 */
@@ -653,11 +657,8 @@ negotiate:
ata_28bit_cmd(ataio, ATA_SEP_ATTN, 0xEC, 0x00,
sizeof(softc->ident_data) / 4);
break;
-   case PROBE_INVALID:
-   CAM_DEBUG(path, CAM_DEBUG_INFO,
-   ("probestart: invalid action state\n"));
default:
-   break;
+   panic("probestart: invalid action state 0x%x\n", softc->action);
}
xpt_action(start_ccb);
 }
@@ -776,6 +777,7 @@ probedone(struct cam_periph *periph, uni
 */
 device_fail:   if ((path->device->flags & CAM_DEV_UNCONFIGURED) == 0)
xpt_async(AC_LOST_DEVICE, path, NULL);
+   PROBE_SET_ACTION(softc, PROBE_INVALID);
found = 0;
goto done;
}
@@ -787,8 +789,8 @@ noerror:
{
int sign = (done_ccb->ataio.res.lba_high << 8) +
done_ccb->ataio.res.lba_mid;
-   if (bootverbose)
-   xpt_print(path, "SIGNATURE: %04x\n", sign);
+   CAM_DEBUG(path, CAM_DEBUG_PROBE,
+   ("SIGNATURE: %04x\n", sign));
if (sign == 0x &&
done_ccb->ccb_h.target_id != 15) {
path->device->protocol = PROTO_ATA;
@@ -1053,6 +1055,7 @@ notsata:
xpt_async(AC_FOUND_DEVICE, done_ccb->ccb_h.path,
done_ccb);
}
+   PROBE_SET_ACTION(softc, PROBE_DONE);
break;
case PROBE_INQUIRY:
case PROBE_FULL_INQUIRY:
@@ -1094,6 +1097,7 @@ notsata:
xpt_action(done_ccb);
xpt_async(AC_FOUND_DEVICE, done_ccb->ccb_h.path, 
done_ccb);
}
+   PROBE_SET_ACTION(softc, PROBE_DONE);
break;
}
case PROBE_PM_PID:
@@ -1162,6 +1166,7 @@ notsata:
xpt_action(done_ccb);
xpt_async(AC_SCSI_AEN, done_ccb->ccb_h.path, done_ccb);
}
+   PROBE_SET_ACTION(softc, PROBE_DONE);
break;
case PROBE_IDENTIFY_SES:
case PROBE_IDENTIFY_SAFTE:
@@ -1204,12 +1209,10 @@ notsata:
xpt_async(AC_FOUND_DEVICE, done_ccb->ccb_h.path,
done_ccb);
}
+   PROBE_SET_ACTION(softc, PROBE_DONE);
break;
-   case PROBE_INVALID:
-   CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_INFO,
-   ("probedone: invalid action state\n"));
default:
-   break;
+   panic("probedone: invalid action state 0x%x\n", softc->action);
}
 done:
if (softc->restart) {
@@ -1219,6 +1222,7 @@ done:
return;
}
xpt_release_ccb(done_ccb);
+   CAM_DEBUG(periph->path, CAM_DEBUG_PROBE, ("Probe completed\n"));
while ((done_ccb = (union ccb *)TAILQ_FIRST(&softc->request_ccbs))) {
TAILQ_REMOVE(&softc->request_ccbs,
&done_ccb->ccb_h, periph_links.tqe);

Modified: head/sys/cam/scsi/

svn commit: r236614 - head/gnu/lib/libsupc++

2012-06-05 Thread Dag-Erling Smorgrav
Author: des
Date: Tue Jun  5 12:34:08 2012
New Revision: 236614
URL: http://svn.freebsd.org/changeset/base/236614

Log:
  Add mangled symbols for operator new / delete on 64-bit platforms.
  
  Reported by:  decke@
  MFC after:1 week

Modified:
  head/gnu/lib/libsupc++/Version.map

Modified: head/gnu/lib/libsupc++/Version.map
==
--- head/gnu/lib/libsupc++/Version.map  Tue Jun  5 11:48:32 2012
(r236613)
+++ head/gnu/lib/libsupc++/Version.map  Tue Jun  5 12:34:08 2012
(r236614)
@@ -126,11 +126,19 @@ CXXABI_1.3 {
 # __gnu_cxx::_verbose_terminate_handler()
 _ZN9__gnu_cxx27__verbose_terminate_handlerEv;
 
-# new / delete operators
+# operator new and new[], 32-bit size_t
 _Znaj;
 _ZnajRKSt9nothrow_t;
 _Znwj;
 _ZnwjRKSt9nothrow_t;
+
+# operator new and new[], 64-bit size_t
+_Znam;
+_ZnamRKSt9nothrow_t;
+_Znwm;
+_ZnwmRKSt9nothrow_t;
+
+# operator delete and delete[]
 _ZdaPv;
 _ZdaPvRKSt9nothrow_t;
 _ZdlPv;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 10:08:09AM +0200, Dimitry Andric wrote:
> On 2012-06-04 23:34, Andrey A. Chernov wrote:> Author: ache
> > Date: Mon Jun  4 21:34:49 2012
> > New Revision: 236582
> > URL: http://svn.freebsd.org/changeset/base/236582
> > 
> > Log:
> >   1) IEEE Std 1003.1-2008, "errno" section, is explicit that
> >   
> >   "The setting of errno after a successful call to a function is
> >   unspecified unless the description of that function specifies that
> >   errno shall not be modified."
> >   
> >   However, free() in IEEE Std 1003.1-2008 does not mention its interaction
> >   with errno, so MAY modify it after successful call
> >   (it depends on particular free() implementation, OS-specific, etc.).
> 
> Actually, it says the following:
> 
>   RETURN VALUE
> 
>   The free() function shall not return a value.
> 
>   ERRORS
> 
>   No errors are defined.
> 
> How much clearer do you want it? ;)

It is pretty clear.
The function is not specified that errno shall not be modified.
You mstake errors with direct mention of not modified errno, as POSIX 
requires.

Moreover, standard metion "unsuccessful call" case for free() where errno 
state is totally undefined.

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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 11:35:53AM +0300, Konstantin Belousov wrote:
> Not to mention that the patch was committed to _our_ implementation of
> libc, which uses _our_ free, and not some abstract free(3). Our free changing
> errno means that process state is so messed that worrying about realpath(3)
> correctness is beyond any expectations.

We can't stay with "our free" concept but with "some abstract free" 
instead. The code must be portable and even "our free" can be replaced in 
the future.

About errno changing, look at "our free" code pass, potential candidates 
(as Garrett mentions) are utrace, assert, idalloc - I don't look deep to 
say for sure. But it does not really matter because the whole "our free" 
concept is flawed.

> I already described my POV to ache, but it seems that nobody listens. It just
> a season, it seems.

You deside to not answer to the free() discussion which follows your 
initial commit, which means either you agree with change or you are not 
interested. It looks strange that you just consider to answer now and keep 
silence at the time of discussion.

-- 
http://ache.vniz.net/


pgpgaVwvf3Xir.pgp
Description: PGP signature


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 04:39:01PM +0400, Andrey Chernov wrote:
> > Actually, it says the following:
> > 
> >   RETURN VALUE
> > 
> >   The free() function shall not return a value.
> > 
> >   ERRORS
> > 
> >   No errors are defined.
> > 
> > How much clearer do you want it? ;)
> 
> It is pretty clear.
> The function is not specified that errno shall not be modified.
> You mstake errors with direct mention of not modified errno, as POSIX 
> requires.
> 
> Moreover, standard metion "unsuccessful call" case for free() where errno 
> state is totally undefined.

BTW, this interpretation is not my invention, look at this discussion
where Austin Groupd agrees that it is the case:
http://austingroupbugs.net/view.php?id=385

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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Joerg Sonnenberger
On Tue, Jun 05, 2012 at 04:39:01PM +0400, Andrey Chernov wrote:
> Moreover, standard metion "unsuccessful call" case for free() where errno 
> state is totally undefined.

...which would be a programming mistake in first place and is valid as
justification.

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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 09:47:42AM +0200, Pawel Jakub Dawidek wrote:
> >   "The setting of errno after a successful call to a function is
> >   unspecified unless the description of that function specifies that
> >   errno shall not be modified."
> 
> Very interesting. However free(3) is always successful. Maybe we need
> more context here, but the sentence above might talk about functions
> that can either succeed or fail and such functions do set errno on
> failure, but we don't know what they do to errno on success - they
> sometimes interact with the errno, free(3) never does.

According to Austing Group interpretation, this setence talks about 
funtions which always succeed too, please see
http://austingroupbugs.net/view.php?id=385

> I aware that my interpretation might be too wishful, but it is pretty
> obvious to save errno value when calling a function that can eventually
> fail - when we save the errno we don't know if it will fail or not, so
> we have to do that, but requiring to save errno when calling a void
> function that can't fail is simply silly and complicates the code
> without a reason.

It still can fail due to internal errors, it just not returns failure.
For internal errors POSIX states that errno state is unspecified.

> I agree that the standards aren't clear, but if saving errno around
> free(3) is the way to go, then I'm sure we have much more problems in
> our code, even if it is not suppose to be portable it should be correct
> - we never know who and when will take the code and port it.

Currently they are pretty clear in that moment, although I agree that if 
POSIX says it should not modify errno, the life will be easy. Lets look at 
their further movement, since they are already aware of this specific 
problem.

> I guess what I'm trying to say here is that this is much bigger change
> than it looks and we should probably agree on some global rule here.

...which not violate standards.

-- 
http://ache.vniz.net/


pgpaMiikMNPHJ.pgp
Description: PGP signature


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Dag-Erling Smørgrav
Pawel Jakub Dawidek  writes:
> Very interesting. However free(3) is always successful. Maybe we need
> more context here, but the sentence above might talk about functions
> that can either succeed or fail and such functions do set errno on
> failure, but we don't know what they do to errno on success - they
> sometimes interact with the errno, free(3) never does.

Even if free() itself never fails, it might have side effects such as
unmapping a slab, logging a KTR event etc. which can modify errno.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 02:55:20PM +0200, Joerg Sonnenberger wrote:
> On Tue, Jun 05, 2012 at 04:39:01PM +0400, Andrey Chernov wrote:
> > Moreover, standard metion "unsuccessful call" case for free() where errno 
> > state is totally undefined.
> 
> ...which would be a programming mistake in first place and is valid as
> justification.

Not only that (I mean programming mistake in the realpath). F.e. internal 
free/malloc state can be damaged by other code even earlier. But all of 
this is not the case, since POSIX allows it to modify errno on _success_,
which is main reason of the change.
Please see 
http://austingroupbugs.net/view.php?id=385

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


svn commit: r236615 - head/sys/netinet6

2012-06-05 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Jun  5 13:27:37 2012
New Revision: 236615
URL: http://svn.freebsd.org/changeset/base/236615

Log:
  Plug two interface address refcount leaks in early error return cases
  in the ioctl path.
  
  Reported by:  rpaulo
   Reviewed by: emax
  MFC after:3 days

Modified:
  head/sys/netinet6/in6.c

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Tue Jun  5 12:34:08 2012(r236614)
+++ head/sys/netinet6/in6.c Tue Jun  5 13:27:37 2012(r236615)
@@ -1667,14 +1667,19 @@ in6_lifaddr_ioctl(struct socket *so, u_l
hostid = IFA_IN6(ifa);
 
/* prefixlen must be <= 64. */
-   if (64 < iflr->prefixlen)
+   if (64 < iflr->prefixlen) {
+   if (ifa != NULL)
+   ifa_free(ifa);
return EINVAL;
+   }
prefixlen = iflr->prefixlen;
 
/* hostid part must be zero. */
sin6 = (struct sockaddr_in6 *)&iflr->addr;
if (sin6->sin6_addr.s6_addr32[2] != 0 ||
sin6->sin6_addr.s6_addr32[3] != 0) {
+   if (ifa != NULL)
+   ifa_free(ifa);
return EINVAL;
}
} else
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 03:10:06PM +0200, Dag-Erling Sm??rgrav wrote:
> Pawel Jakub Dawidek  writes:
> > Very interesting. However free(3) is always successful. Maybe we need
> > more context here, but the sentence above might talk about functions
> > that can either succeed or fail and such functions do set errno on
> > failure, but we don't know what they do to errno on success - they
> > sometimes interact with the errno, free(3) never does.
> 
> Even if free() itself never fails, it might have side effects such as
> unmapping a slab, logging a KTR event etc. which can modify errno.

I totally agree. Even if our free() will be cleaned in this sense or save 
errno internally, we need the code which not relays on some particular 
implementation but works in general scope with any standard-conformant 
free().

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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Mon, Jun 04, 2012 at 09:34:49PM +, Andrey A. Chernov wrote:
>   1) IEEE Std 1003.1-2008, "errno" section, is explicit that
>   
>   "The setting of errno after a successful call to a function is
>   unspecified unless the description of that function specifies that
>   errno shall not be modified."
>   
>   However, free() in IEEE Std 1003.1-2008 does not mention its interaction
>   with errno, so MAY modify it after successful call
>   (it depends on particular free() implementation, OS-specific, etc.).

I see this subject brings some attention, so I prefer to exmpain details.
Here is the quote from the future standard change:
http://austingroupbugs.net/view.php?id=385

"However, earlier versions of this standard did not require this, and the
same example had to be written as:

// buf was obtained by malloc(buflen)
ret = write(fd, buf, buflen);
if (ret < 0) {
int save = errno;
free(buf);
errno = save;
return ret;
}
"

All we have now is "earlier version of standard". Until they'll publish 
future version, we need to stay this recommendation.

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


svn commit: r236617 - head/sys/arm/at91

2012-06-05 Thread Warner Losh
Author: imp
Date: Tue Jun  5 14:19:59 2012
New Revision: 236617
URL: http://svn.freebsd.org/changeset/base/236617

Log:
  Remove dead code.

Modified:
  head/sys/arm/at91/at91rm92reg.h

Modified: head/sys/arm/at91/at91rm92reg.h
==
--- head/sys/arm/at91/at91rm92reg.h Tue Jun  5 13:57:02 2012
(r236616)
+++ head/sys/arm/at91/at91rm92reg.h Tue Jun  5 14:19:59 2012
(r236617)
@@ -91,146 +91,6 @@
 #define AT91RM92_SYS_BASE  0x000
 #define AT91RM92_SYS_SIZE  0x1000
 
-#if  0
-/* Interrupt Controller */
-#define IC_SMR (0) /* Source mode register */
-#define IC_SVR (128) /* Source vector register */
-#define IC_IVR (256) /* IRQ vector register */
-#define IC_FVR (260) /* FIQ vector register */
-#define IC_ISR (264) /* Interrupt status register */
-#define IC_IPR (268) /* Interrupt pending register */
-#define IC_IMR (272) /* Interrupt status register */
-#define IC_CISR(276) /* Core interrupt status register 
*/
-#define IC_IECR(288) /* Interrupt enable command 
register */
-#define IC_IDCR(292) /* Interrupt disable command 
register */
-#define IC_ICCR(296) /* Interrupt clear command 
register */
-#define IC_ISCR(300) /* Interrupt set command register 
*/
-#define IC_EOICR   (304) /* End of interrupt command register */
-#define IC_SPU (308) /* Spurious vector register */
-#define IC_DCR (312) /* Debug control register */
-#define IC_FFER(320) /* Fast forcing enable register */
-#define IC_FFDR(324) /* Fast forcing disable register 
*/
-#define IC_FFSR(328) /* Fast forcing status register */
-
-
-#define PIOA_PER   (0x400) /* PIO Enable Register */
-#define PIOA_PDR   (0x400 + 4) /* PIO Disable Register */
-#define PIOA_PSR   (0x400 + 8) /* PIO status register */
-#define PIOA_OER   (0x400 + 16) /* Output enable register */
-#define PIOA_ODR   (0x400 + 20) /* Output disable register */
-#define PIOA_OSR   (0x400 + 24) /* Output status register */
-#define PIOA_IFER  (0x400 + 32) /* Input filter enable register */
-#define PIOA_IFDR  (0x400 + 36) /* Input filter disable register */
-#define PIOA_IFSR  (0x400 + 40) /* Input filter status register */
-#define PIOA_SODR  (0x400 + 48) /* Set output data register */
-#define PIOA_CODR  (0x400 + 52) /* Clear output data register */
-#define PIOA_ODSR  (0x400 + 56) /* Output data status register */
-#define PIOA_PDSR  (0x400 + 60) /* Pin data status register */
-#define PIOA_IER   (0x400 + 64) /* Interrupt enable register */
-#define PIOA_IDR   (0x400 + 68) /* Interrupt disable register */
-#define PIOA_IMR   (0x400 + 72) /* Interrupt mask register */
-#define PIOA_ISR   (0x400 + 76) /* Interrupt status register */
-#define PIOA_MDER  (0x400 + 80) /* Multi driver enable register */
-#define PIOA_MDDR  (0x400 + 84) /* Multi driver disable register */
-#define PIOA_MDSR  (0x400 + 88) /* Multi driver status register */
-#define PIOA_PPUDR (0x400 + 96) /* Pull-up disable register */
-#define PIOA_PPUER (0x400 + 100) /* Pull-up enable register */
-#define PIOA_PPUSR (0x400 + 104) /* Pad pull-up status register */
-#define PIOA_ASR   (0x400 + 112) /* Select A register */
-#define PIOA_BSR   (0x400 + 116) /* Select B register */
-#define PIOA_ABSR  (0x400 + 120) /* AB Select status register */
-#define PIOA_OWER  (0x400 + 160) /* Output Write enable register */
-#define PIOA_OWDR  (0x400 + 164) /* Output write disable register 
*/
-#define PIOA_OWSR  (0x400 + 168) /* Output write status register */
-#define PIOB_PER   (0x400) /* PIO Enable Register */
-#define PIOB_PDR   (0x600 + 4) /* PIO Disable Register */
-#define PIOB_PSR   (0x600 + 8) /* PIO status register */
-#define PIOB_OER   (0x600 + 16) /* Output enable register */
-#define PIOB_ODR   (0x600 + 20) /* Output disable register */
-#define PIOB_OSR   (0x600 + 24) /* Output status register */
-#define PIOB_IFER  (0x600 + 32) /* Input filter enable register */
-#define PIOB_IFDR  (0x600 + 36) /* Input filter disable register */
-#define PIOB_IFSR  (0x600 + 40) /* Input filter status register */
-#define PIOB_SODR  (0x600 + 48) /* Set output data register */
-#define PIOB_CODR  (0x600 + 52) /* Clear ou

Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Joerg Sonnenberger
On Tue, Jun 05, 2012 at 05:13:05PM +0400, Andrey Chernov wrote:
> On Tue, Jun 05, 2012 at 02:55:20PM +0200, Joerg Sonnenberger wrote:
> > On Tue, Jun 05, 2012 at 04:39:01PM +0400, Andrey Chernov wrote:
> > > Moreover, standard metion "unsuccessful call" case for free() where errno 
> > > state is totally undefined.
> > 
> > ...which would be a programming mistake in first place and is valid as
> > justification.
> 
> Not only that (I mean programming mistake in the realpath). F.e. internal 
> free/malloc state can be damaged by other code even earlier. But all of 
> this is not the case, since POSIX allows it to modify errno on _success_,
> which is main reason of the change.
> Please see 
> http://austingroupbugs.net/view.php?id=385

That is about explicitly recognizing how stupid the notion of free(3)
not preserving errno is. Seriously, before you start to randomly bloat
code all over the place, restricting the behavior of free(3) to be
sensible is a much saner option.

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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 04:25:10PM +0200, Joerg Sonnenberger wrote:
> > Please see 
> > http://austingroupbugs.net/view.php?id=385
> 
> That is about explicitly recognizing how stupid the notion of free(3)
> not preserving errno is. Seriously, before you start to randomly bloat
> code all over the place, restricting the behavior of free(3) to be
> sensible is a much saner option.

I agree that saving errno inside free() itself will make life easy, 
but I just follow their recommendation:

"However, earlier versions of this standard did not require this, and the
same example had to be written as:

// buf was obtained by malloc(buflen)
ret = write(fd, buf, buflen);
if (ret < 0) {
int save = errno;
free(buf);
errno = save;
return ret;
}
"

All we have now is "earlier version of this standard". Until they'll 
publish the future version, we can't ignore the recommendation.

BTW, if general consensus will be to track unpublished standard, I will 
back out my change (in hope our malloc() maintainer will change free() to 
directly save errno).

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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Joerg Sonnenberger
On Tue, Jun 05, 2012 at 06:31:14PM +0400, Andrey Chernov wrote:
> BTW, if general consensus will be to track unpublished standard, I will 
> back out my change (in hope our malloc() maintainer will change free() to 
> directly save errno).

The standard is quite irrelevant here. FreeBSD is free to require a more
restricted behavior of free(3).

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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Marcel Moolenaar

On Jun 5, 2012, at 7:31 AM, Andrey Chernov wrote:

> On Tue, Jun 05, 2012 at 04:25:10PM +0200, Joerg Sonnenberger wrote:
>>> Please see 
>>> http://austingroupbugs.net/view.php?id=385
>> 
>> That is about explicitly recognizing how stupid the notion of free(3)
>> not preserving errno is. Seriously, before you start to randomly bloat
>> code all over the place, restricting the behavior of free(3) to be
>> sensible is a much saner option.
> 
> I agree that saving errno inside free() itself will make life easy, 
> but I just follow their recommendation:
> 
> "However, earlier versions of this standard did not require this, and the
> same example had to be written as:
> 
>// buf was obtained by malloc(buflen)
>ret = write(fd, buf, buflen);
>if (ret < 0) {
>int save = errno;
>free(buf);
>errno = save;
>return ret;
>}
> "
> 
> All we have now is "earlier version of this standard". Until they'll 
> publish the future version, we can't ignore the recommendation.
> 
> BTW, if general consensus will be to track unpublished standard, I will 
> back out my change (in hope our malloc() maintainer will change free() to 
> directly save errno).

We do know where things are heading towards, so it seems very reasonable
to not change our current code, even if it is not in compliance with the
currently published version (or the "earlier version of this standard"
as you call it in the context of the unpublished version) and wait until
we have more clarity. Often times our code has been non-compliant for
many years and our non-compliance is shared with many implementations,
so I see little reason to push for an immediate compliancy.

If we the resolution of the ID 385 indicates that a future version
will have the suggested text, then one can definitely argue that it's
not unreasonable to start changing our functions to match the new text
(like free(3)) and change all consumers to depend on it.

I do not see a reason to revert the change under discussion just yet as
it just adds to the churn without there being anything concrete, but I
do suggest we won't "fix" any other code in the mean time. Our time is
probably better spent auditing our source base and documenting where we
depend on the yet-to-be-published behaviour and where we are strictly
in compliance with the current version. This can will help us in the
future when we want to clean things up.

Just my $0.02,


-- 
Marcel Moolenaar
mar...@xcllnt.net


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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 08:23:20AM -0700, Marcel Moolenaar wrote:
> If we the resolution of the ID 385 indicates that a future version
> will have the suggested text, then one can definitely argue that it's
> not unreasonable to start changing our functions to match the new text
> (like free(3)) and change all consumers to depend on it.

It is already reach Resolved status, exact link if of the final changes
is http://austingroupbugs.net/view.php?id=385#c713

But considering all feedback I got at this moment (including private ones)
I decide to back out my change and fill PR for malloc() maintainer to 
save errno directly in free() instead.

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


svn commit: r236618 - head/lib/libc/stdlib

2012-06-05 Thread Andrey A. Chernov
Author: ache
Date: Tue Jun  5 16:16:33 2012
New Revision: 236618
URL: http://svn.freebsd.org/changeset/base/236618

Log:
  1) Although unpublished version of standard
  http://austingroupbugs.net/view.php?id=385#c713
  (Resolved state) recommend this way for the current standard (called
  "earlier" in the text)
  
  "However, earlier versions of this standard did not require this, and the
  same example had to be written as:
  
  // buf was obtained by malloc(buflen)
  ret = write(fd, buf, buflen);
  if (ret < 0) {
  int save = errno;
  free(buf);
  errno = save;
  return ret;
  }
  "
  
  from feedback I have for previous commit it seems that many people prefer
  to avoid mass code change needed for current standard compliance
  and prefer to track unpublished standard instead, which requires now
  that free() itself must save errno, not its usage code.
  
  So, I back out "save errno across free()" part of previous commit,
  and will fill PR for changing free() isntead.
  
  2) Remove now unused serrno.
  
  MFC after:  1 week

Modified:
  head/lib/libc/stdlib/realpath.c

Modified: head/lib/libc/stdlib/realpath.c
==
--- head/lib/libc/stdlib/realpath.c Tue Jun  5 14:19:59 2012
(r236617)
+++ head/lib/libc/stdlib/realpath.c Tue Jun  5 16:16:33 2012
(r236618)
@@ -54,7 +54,7 @@ realpath(const char * __restrict path, c
char *p, *q, *s;
size_t left_len, resolved_len;
unsigned symlinks;
-   int m, serrno, slen;
+   int m, slen;
char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
 
if (path == NULL) {
@@ -82,11 +82,9 @@ realpath(const char * __restrict path, c
left_len = strlcpy(left, path + 1, sizeof(left));
} else {
if (getcwd(resolved, PATH_MAX) == NULL) {
-   if (m) {
-   serrno = errno;
+   if (m)
free(resolved);
-   errno = serrno;
-   } else {
+   else {
resolved[0] = '.';
resolved[1] = '\0';
}
@@ -144,11 +142,8 @@ realpath(const char * __restrict path, c
 * occurence to not implement lookahead.
 */
if (lstat(resolved, &sb) != 0) {
-   if (m) {
-   serrno = errno;
+   if (m)
free(resolved);
-   errno = serrno;
-   }
return (NULL);
}
if (!S_ISDIR(sb.st_mode)) {
@@ -188,11 +183,8 @@ realpath(const char * __restrict path, c
if (lstat(resolved, &sb) != 0) {
if (errno != ENOENT || p != NULL)
errno = ENOTDIR;
-   if (m) {
-   serrno = errno;
+   if (m)
free(resolved);
-   errno = serrno;
-   }
return (NULL);
}
if (S_ISLNK(sb.st_mode)) {
@@ -204,11 +196,8 @@ realpath(const char * __restrict path, c
}
slen = readlink(resolved, symlink, sizeof(symlink) - 1);
if (slen < 0) {
-   if (m) {
-   serrno = errno;
+   if (m)
free(resolved);
-   errno = serrno;
-   }
return (NULL);
}
symlink[slen] = '\0';
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236619 - head/sys/geom/multipath

2012-06-05 Thread Alexander Motin
Author: mav
Date: Tue Jun  5 16:46:34 2012
New Revision: 236619
URL: http://svn.freebsd.org/changeset/base/236619

Log:
  Add missing newlines into XML output.
  
  MFC after:3 days
  Sponsored by: iXsystems, Inc.

Modified:
  head/sys/geom/multipath/g_multipath.c

Modified: head/sys/geom/multipath/g_multipath.c
==
--- head/sys/geom/multipath/g_multipath.c   Tue Jun  5 16:16:33 2012
(r236618)
+++ head/sys/geom/multipath/g_multipath.c   Tue Jun  5 16:46:34 2012
(r236619)
@@ -1314,7 +1314,7 @@ g_multipath_dumpconf(struct sbuf *sb, co
if (sc == NULL)
return;
if (cp != NULL) {
-   sbuf_printf(sb, "%s%s", indent,
+   sbuf_printf(sb, "%s%s\n", indent,
(cp->index & MP_NEW) ? "NEW" :
(cp->index & MP_LOST) ? "LOST" :
(cp->index & MP_FAIL) ? "FAIL" :
@@ -1323,17 +1323,17 @@ g_multipath_dumpconf(struct sbuf *sb, co
 sc->sc_active_active == 2 ? "READ" : "PASSIVE");
} else {
good = g_multipath_good(gp);
-   sbuf_printf(sb, "%s%s", indent,
+   sbuf_printf(sb, "%s%s\n", indent,
good == 0 ? "BROKEN" :
(good != sc->sc_ndisks || sc->sc_ndisks == 1) ?
"DEGRADED" : "OPTIMAL");
}
if (cp == NULL && pp == NULL) {
-   sbuf_printf(sb, "%s%s", indent, sc->sc_uuid);
-   sbuf_printf(sb, "%sActive/%s", indent,
+   sbuf_printf(sb, "%s%s\n", indent, sc->sc_uuid);
+   sbuf_printf(sb, "%sActive/%s\n", indent,
sc->sc_active_active == 2 ? "Read" :
sc->sc_active_active == 1 ? "Active" : "Passive");
-   sbuf_printf(sb, "%s%s", indent,
+   sbuf_printf(sb, "%s%s\n", indent,
sc->sc_uuid[0] == 0 ? "MANUAL" : "AUTOMATIC");
}
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 05:17:33PM +0200, Joerg Sonnenberger wrote:
> On Tue, Jun 05, 2012 at 06:31:14PM +0400, Andrey Chernov wrote:
> > BTW, if general consensus will be to track unpublished standard, I will 
> > back out my change (in hope our malloc() maintainer will change free() to 
> > directly save errno).
> 
> The standard is quite irrelevant here. FreeBSD is free to require a more
> restricted behavior of free(3).

I am not supporter of "our" concept for standard API. Having 
ours only restricted free() will make harder to write portable code 
because people tends relay on what works for them and not on standards.
But in the light of upcoming new standard version which require the same, 
it is acceptable at least.

BTW, the change backed out, PR for free() filled instead.

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


Re: svn commit: r236593 - head/share/man/man4

2012-06-05 Thread David O'Brien
On Tue, Jun 05, 2012 at 11:07:48AM +1200, Andrew Thompson wrote:
> Does the race have to be managed between the parent SET_PID ioctl and
> the child doing something?

Thank you for catching that.  I committed an older version of that.
(had copies of this on multiple machines...)

-- 
-- David  (obr...@freebsd.org)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236620 - in head: share/man/man4 tools/regression/filemon

2012-06-05 Thread David E. O'Brien
Author: obrien
Date: Tue Jun  5 17:36:28 2012
New Revision: 236620
URL: http://svn.freebsd.org/changeset/base/236620

Log:
  Correct examples to the latest version I had.

Modified:
  head/share/man/man4/filemon.4
  head/tools/regression/filemon/filemontest.c

Modified: head/share/man/man4/filemon.4
==
--- head/share/man/man4/filemon.4   Tue Jun  5 16:46:34 2012
(r236619)
+++ head/share/man/man4/filemon.4   Tue Jun  5 17:36:28 2012
(r236620)
@@ -127,18 +127,19 @@ open_filemon(void)
O_CREAT | O_WRONLY | O_TRUNC, DEFFILEMODE)) == -1)
err(1, "open(filemon.out)");
 
-   if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) < 0)
+   if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1)
err(1, "Cannot set filemon log file descriptor");
/* Set up these two fd's to close on exec. */
(void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC);
(void)fcntl(fm_log, F_SETFD, FD_CLOEXEC);
 
if ((child = fork()) == 0) {
+   child = getpid();
+   if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1)
+   err(1, "Cannot set filemon PID");
/* Do something here. */
return 0;
} else {
-   if (ioctl(fm_fd, FILEMON_SET_PID, &child) < 0)
-   err(1, "Cannot set filemon PID");
wait(&child);
close(fm_fd);
}

Modified: head/tools/regression/filemon/filemontest.c
==
--- head/tools/regression/filemon/filemontest.c Tue Jun  5 16:46:34 2012
(r236619)
+++ head/tools/regression/filemon/filemontest.c Tue Jun  5 17:36:28 2012
(r236620)
@@ -54,22 +54,27 @@ main(void) {
if ((fm_log = mkstemp(log_name)) == -1)
err(1, "mkstemp(%s)", log_name);
 
-   if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) < 0)
+   if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1)
err(1, "Cannot set filemon log file descriptor");
 
/* Set up these two fd's to close on exec. */
(void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC);
(void)fcntl(fm_log, F_SETFD, FD_CLOEXEC);
 
-   if ((child = fork()) == 0) {
+   switch (child = fork()) {
+   case 0:
+   child = getpid();
+   if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1)
+   err(1, "Cannot set filemon PID to %d", child);
system("./test_script.sh");
-   return 0;
-   } else {
-   if (ioctl(fm_fd, FILEMON_SET_PID, &child) < 0)
-   err(1, "Cannot set filemon PID");
+   break;
+   case -1:
+   err(1, "Cannot fork");
+   default:
wait(&child);
close(fm_fd);
 // printf("Results in %s\n", log_name);
+   break;
}
return 0;
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236621 - head/sys/modules

2012-06-05 Thread David E. O'Brien
Author: obrien
Date: Tue Jun  5 17:44:54 2012
New Revision: 236621
URL: http://svn.freebsd.org/changeset/base/236621

Log:
  Only build filemon(4) on x86.

Modified:
  head/sys/modules/Makefile

Modified: head/sys/modules/Makefile
==
--- head/sys/modules/Makefile   Tue Jun  5 17:36:28 2012(r236620)
+++ head/sys/modules/Makefile   Tue Jun  5 17:44:54 2012(r236621)
@@ -5,7 +5,8 @@
 # Modules that include binary-only blobs of microcode should be selectable by
 # MK_SOURCELESS_UCODE option (see below).
 
-SUBDIR=${_3dfx} \
+SUBDIR=\
+   ${_3dfx} \
${_3dfx_linux} \
${_aac} \
accf_data \
@@ -358,9 +359,12 @@ SUBDIR=${_3dfx} \
${_zfs} \
zlib \
 
+.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
+_filemon=  filemon
+.endif
+
 .if ${MACHINE_CPUARCH} != "powerpc" && ${MACHINE_CPUARCH} != "arm" && \
${MACHINE_CPUARCH} != "mips"
-_filemon=  filemon
 _syscons=  syscons
 _vpo=  vpo
 .endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236622 - head/share/man/man4

2012-06-05 Thread Joel Dahl
Author: joel (doc committer)
Date: Tue Jun  5 17:46:50 2012
New Revision: 236622
URL: http://svn.freebsd.org/changeset/base/236622

Log:
  Various mdoc fixes.

Modified:
  head/share/man/man4/filemon.4

Modified: head/share/man/man4/filemon.4
==
--- head/share/man/man4/filemon.4   Tue Jun  5 17:44:54 2012
(r236621)
+++ head/share/man/man4/filemon.4   Tue Jun  5 17:46:50 2012
(r236622)
@@ -93,20 +93,25 @@ R
 and one for
 W.
 .Sh IOCTLS
-User mode programs communicate with the filemon driver through a
+User mode programs communicate with the
+.Nm filemon
+driver through a
 number of ioctls which are described below.
 Each takes a single argument.
 .Bl -tag -width FILEMON_SET_PID
 .It Dv FILEMON_SET_FD
 Write the internal tracing buffer to the supplied open file descriptor.
-.It Dv FILEMON_SET_PID .
+.It Dv FILEMON_SET_PID
 Child process ID to trace.
 .El
-.Pp
 .Sh RETURN VALUES
 The ioctl returns zero on success and non-zero on failure.
+.Sh FILES
+.Bl -tag -width /dev/zero
+.It Pa /dev/filemon
+.El
 .Sh EXAMPLES
-.Bd -literal -offset indent
+.Bd -literal
 #include 
 #include 
 #include 
@@ -152,10 +157,6 @@ Creates a file named
 and configures the
 .Nm
 device to write the filemon buffer contents to it.
-.Sh FILES
-.Bl -tag -width /dev/zero
-.It Pa /dev/filemon
-.El
 .Sh SEE ALSO
 .Xr dtrace 1 ,
 .Xr ktrace 1 ,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236623 - head/share/man/man4

2012-06-05 Thread David E. O'Brien
Author: obrien
Date: Tue Jun  5 17:49:11 2012
New Revision: 236623
URL: http://svn.freebsd.org/changeset/base/236623

Log:
  RAID is an acronym.

Modified:
  head/share/man/man4/mpt.4

Modified: head/share/man/man4/mpt.4
==
--- head/share/man/man4/mpt.4   Tue Jun  5 17:46:50 2012(r236622)
+++ head/share/man/man4/mpt.4   Tue Jun  5 17:49:11 2012(r236623)
@@ -124,15 +124,15 @@ Dell PowerEdge 1750 thru 2850
 IBM eServer xSeries 335
 .El
 .Pp
-These systems also contain Integrated Raid Mirroring and Integrated
-Raid Mirroring Enhanced which this driver also supports.
+These systems also contain Integrated RAID Mirroring and Integrated
+RAID Mirroring Enhanced which this driver also supports.
 .Pp
 The
 .Tn SAS
 controller chips are also present on many new AMD/Opteron based systems,
 like the Sun 4100.
 Note that this controller can drive both SAS and SATA
-drives or a mix of them at the same time. The Integrated Raid Mirroring
+drives or a mix of them at the same time. The Integrated RAID Mirroring
 available for these controllers is poorly supported at best.
 .Pp
 The
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236624 - head/share/man/man4

2012-06-05 Thread Joel Dahl
Author: joel (doc committer)
Date: Tue Jun  5 17:58:47 2012
New Revision: 236624
URL: http://svn.freebsd.org/changeset/base/236624

Log:
  Remove end of line whitespace.

Modified:
  head/share/man/man4/bce.4

Modified: head/share/man/man4/bce.4
==
--- head/share/man/man4/bce.4   Tue Jun  5 17:49:11 2012(r236623)
+++ head/share/man/man4/bce.4   Tue Jun  5 17:58:47 2012(r236624)
@@ -213,57 +213,57 @@ Enable/Disable strict RX frame size chec
 Enable/Disable frame header/payload splitting (default 1).
 .It Va hw.bce.rx_pages
 Set the number of memory pages assigned to recieve packets by the driver.
-Due to alignment issues, this value can only be of the set 
+Due to alignment issues, this value can only be of the set
 1, 2, 4 or 8 (default 2).
 .It Va hw.bce.tx_pages
-Set the number of memory pages assigned to transmit packets 
+Set the number of memory pages assigned to transmit packets
 by the driver.
-Due to alignment issues, this value can only be of the set 
+Due to alignment issues, this value can only be of the set
 1, 2, 4 or 8 (default 2).
 .It Va hw.bce.rx_ticks
-Time in microsecond ticks to wait before generating a status 
+Time in microsecond ticks to wait before generating a status
 block updates due to RX processing activity.
 Values from 0-100 are valid.
 A value of 0 disables this status block update.
-Cannot be set to 0 if hw.bce.rx_quick_cons_trip is also 0 
+Cannot be set to 0 if hw.bce.rx_quick_cons_trip is also 0
 (default 18).
 .It Va hw.bce.rx_ticks_int
-Time in microsecond ticks to wait during RX interrupt 
+Time in microsecond ticks to wait during RX interrupt
 processing before generating a status block update.
 Values from 0-100 are valid.
 Valid values are in the range from 0-100.
 A value of 0 disables this status block update (default 18).
 .It Va hw.bce.rx_quick_cons_trip
-Number of RX Quick BD Chain entries that must be completed 
+Number of RX Quick BD Chain entries that must be completed
 before a status block is generated.
 Values from 0-256 are valid.
 A value of 0 disables this status block update.
 Cannot be set to 0 if hw.bce.rx_ticks is also 0 (default 6).
 .It Va hw.bce.rx_quick_cons_trip_int
-Number of RX quick BD entries that must be completed before 
+Number of RX quick BD entries that must be completed before
 a status block is generated duing interrupt processing.
 Values from 0-256 are valid.
 A value of 0 disables this status block update (default 6).
 .It Va hw.bce.tx_ticks
-Time in microsecond ticks to wait before a status block 
+Time in microsecond ticks to wait before a status block
 update is generated due to TX activitiy.
 Values from 0-100 are valid.
 A value of 0 disables this status block update.
-Cannot be set to 0 if hw.bce.tx_quick_cons_trip is also 0 
+Cannot be set to 0 if hw.bce.tx_quick_cons_trip is also 0
 (default 80).
 .It Va hw.bce.tx_ticks_int
-Time in microsecond ticks to wait in interrupt processing 
+Time in microsecond ticks to wait in interrupt processing
 before a status block update is generated due to TX activity
 Values from 0-100 are valid.
 A value of 0 disables this status block update (default 80).
 .It Va hw.bce.tx_cons_trip
-How many TX Quick BD Chain entries that must be completed 
+How many TX Quick BD Chain entries that must be completed
 before a status block is generated.
 Values from 0-100 are valid.
 A value of 0 disables this status block update.
 Cannot be set to 0 if hw.bce.tx_ticks is also 0 (default 20).
 .It Va hw.bce.tx_cons_trip_int
-How many TX Quick BD Chain entries that must be completed 
+How many TX Quick BD Chain entries that must be completed
 before a status block is generated during an interrupt.
 Values from 0-100 are valid.
 A value of 0 disables this status block update (default 20).
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236625 - head/sbin/camcontrol

2012-06-05 Thread Joel Dahl
Author: joel (doc committer)
Date: Tue Jun  5 18:07:20 2012
New Revision: 236625
URL: http://svn.freebsd.org/changeset/base/236625

Log:
  Minor spelling fixes.

Modified:
  head/sbin/camcontrol/camcontrol.8

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Tue Jun  5 17:58:47 2012
(r236624)
+++ head/sbin/camcontrol/camcontrol.8   Tue Jun  5 18:07:20 2012
(r236625)
@@ -738,7 +738,7 @@ Set the partial pathway timeout value, i
 See the
 .Tn ANSI
 .Tn SAS
-Protcol Layer (SPL)
+Protocol Layer (SPL)
 specification for more information on this field.
 .It Fl a Ar enable|disable
 Enable or disable SATA slumber phy power conditions.
@@ -1109,7 +1109,7 @@ Do not ask for confirmation.
 Run in simulation mode.
 Packet sizes that will be sent are shown, but no actual packet is sent to the
 device.
-No confimation is asked in simulation mode.
+No confirmation is asked in simulation mode.
 .It Fl v
 Besides showing sense information in case of a failure, the verbose option
 causes
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r236621 - head/sys/modules

2012-06-05 Thread Marcel Moolenaar

On Jun 5, 2012, at 10:44 AM, David E. O'Brien wrote:

> Author: obrien
> Date: Tue Jun  5 17:44:54 2012
> New Revision: 236621
> URL: http://svn.freebsd.org/changeset/base/236621
> 
> Log:
>  Only build filemon(4) on x86.

Why?

-- 
Marcel Moolenaar
mar...@xcllnt.net


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


svn commit: r236626 - in head: lib/libelf lib/libgssapi sbin/ifconfig

2012-06-05 Thread Joel Dahl
Author: joel (doc committer)
Date: Tue Jun  5 18:19:52 2012
New Revision: 236626
URL: http://svn.freebsd.org/changeset/base/236626

Log:
  Remove repeated words.

Modified:
  head/lib/libelf/elf_begin.3
  head/lib/libgssapi/gss_unwrap.3
  head/lib/libgssapi/gss_wrap.3
  head/sbin/ifconfig/ifconfig.8

Modified: head/lib/libelf/elf_begin.3
==
--- head/lib/libelf/elf_begin.3 Tue Jun  5 18:07:20 2012(r236625)
+++ head/lib/libelf/elf_begin.3 Tue Jun  5 18:19:52 2012(r236626)
@@ -252,7 +252,7 @@ was created.
 .It Bq Er ELF_E_ARGUMENT
 An
 .Xr ar 1
-archive was opened with with
+archive was opened with
 .Ar cmd
 set to
 .Dv ELF_C_RDWR .

Modified: head/lib/libgssapi/gss_unwrap.3
==
--- head/lib/libgssapi/gss_unwrap.3 Tue Jun  5 18:07:20 2012
(r236625)
+++ head/lib/libgssapi/gss_unwrap.3 Tue Jun  5 18:19:52 2012
(r236626)
@@ -100,7 +100,7 @@ Protected message.
 .It output_message_buffer
 Buffer to receive unwrapped message.
 Storage associated with this buffer must
-be freed by the application after use use
+be freed by the application after use
 with a call to
 .Xr gss_release_buffer 3 .
 .It conf_state

Modified: head/lib/libgssapi/gss_wrap.3
==
--- head/lib/libgssapi/gss_wrap.3   Tue Jun  5 18:07:20 2012
(r236625)
+++ head/lib/libgssapi/gss_wrap.3   Tue Jun  5 18:19:52 2012
(r236626)
@@ -118,7 +118,7 @@ Integrity and data origin services only 
 .It output_message_buffer
 Buffer to receive protected message.
 Storage associated with this buffer must
-be freed by the application after use use
+be freed by the application after use
 with a call to
 .Xr gss_release_buffer 3 .
 .El

Modified: head/sbin/ifconfig/ifconfig.8
==
--- head/sbin/ifconfig/ifconfig.8   Tue Jun  5 18:07:20 2012
(r236625)
+++ head/sbin/ifconfig/ifconfig.8   Tue Jun  5 18:19:52 2012
(r236626)
@@ -2051,7 +2051,7 @@ Send broadcast path requests every two s
 Nodes on the mesh without a path to this root mesh station with try to
 discover a path to us.
 .It Cm PROACTIVE
-Send broadcast path requests every two seconds and every node must reply with
+Send broadcast path requests every two seconds and every node must reply
 with a path reply even if it already has a path to this root mesh station.
 .It Cm RANN
 Send broadcast root announcement (RANN) frames.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236627 - head/sys/dev/ixgbe

2012-06-05 Thread Maksim Yevmenkin
Author: emax
Date: Tue Jun  5 18:48:02 2012
New Revision: 236627
URL: http://svn.freebsd.org/changeset/base/236627

Log:
  Before it gets lost in the noise.
  
  Put a bandaid to prevent ixgbe(4) from completely locking up the system
  under high load. Our platform has a few CPU cores and a single active
  ixgbe(4) port with 4 queues. Under high enough traffic load, at about
  7.5GBs and 700,000 packets/sec (outbound), the entire system would
  deadlock. What we found was that each CPU was in an endless loop on a
  different ix taskqueue thread. The OACTIVE flag had gotten set on each
  queue, and the ixgbe_handle_queue() function was continuously rescheduling
  itself via the taskqueue_enqueue. Since all CPUs were busy with their
  taskqueue threads, the ixgbe_local_timer() function couldn't run to clear
  the OACTIVE flag.
  
  Submitted by: scottl
  MFC after:1 week

Modified:
  head/sys/dev/ixgbe/ixgbe.c

Modified: head/sys/dev/ixgbe/ixgbe.c
==
--- head/sys/dev/ixgbe/ixgbe.c  Tue Jun  5 18:19:52 2012(r236626)
+++ head/sys/dev/ixgbe/ixgbe.c  Tue Jun  5 18:48:02 2012(r236627)
@@ -1368,7 +1368,7 @@ ixgbe_handle_que(void *context, int pend
ixgbe_start_locked(txr, ifp);
 #endif
IXGBE_TX_UNLOCK(txr);
-   if (more || (ifp->if_drv_flags & IFF_DRV_OACTIVE)) {
+   if (more) {
taskqueue_enqueue(que->tq, &que->que_task);
return;
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236628 - head/cddl/lib/libdtrace

2012-06-05 Thread George V. Neville-Neil
Author: gnn
Date: Tue Jun  5 18:58:05 2012
New Revision: 236628
URL: http://svn.freebsd.org/changeset/base/236628

Log:
  Add DTrace's io.d, which handles tranlsations for file, buffer and
  device info structures as well as the fds[] array.  This is a raw
  version of the file, unmodified, to be used as a baseline.

Added:
  head/cddl/lib/libdtrace/io.d   (contents, props changed)

Added: head/cddl/lib/libdtrace/io.d
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/cddl/lib/libdtrace/io.dTue Jun  5 18:58:05 2012
(r236628)
@@ -0,0 +1,220 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * $FreeBSD$
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident  "%Z%%M% %I% %E% SMI"
+
+#pragma D depends_on module unix
+#pragma D depends_on provider io
+
+inline int B_BUSY = B_BUSY;
+#pragma D binding "1.0" B_BUSY
+inline int B_DONE = 0x0200;
+#pragma D binding "1.0" B_DONE
+inline int B_ERROR = B_ERROR;
+#pragma D binding "1.0" B_ERROR
+inline int B_PAGEIO = B_PAGEIO;
+#pragma D binding "1.0" B_PAGEIO
+inline int B_PHYS = B_PHYS;
+#pragma D binding "1.0" B_PHYS
+inline int B_READ = B_READ;
+#pragma D binding "1.0" B_READ
+inline int B_WRITE = B_WRITE;
+#pragma D binding "1.0" B_WRITE
+inline int B_ASYNC = 0x0004;
+#pragma D binding "1.0" B_ASYNC
+
+typedef struct bufinfo {
+   int b_flags;/* buffer status */
+   size_t b_bcount;/* number of bytes */
+   caddr_t b_addr; /* buffer address */
+   uint64_t b_lblkno;  /* block # on device */
+   uint64_t b_blkno;   /* expanded block # on device */
+   size_t b_resid; /* # of bytes not transferred */
+   size_t b_bufsize;   /* size of allocated buffer */
+   caddr_t b_iodone;   /* I/O completion routine */
+   int b_error;/* expanded error field */
+   dev_t b_edev;   /* extended device */
+} bufinfo_t;
+
+#pragma D binding "1.0" translator
+translator bufinfo_t < struct buf *B > {
+   b_flags = B->b_flags;
+   b_addr = B->b_un.b_addr;
+   b_bcount = B->b_bcount;
+   b_lblkno = B->_b_blkno._f;
+   b_blkno = sizeof (long) == 8 ? B->_b_blkno._f : B->_b_blkno._p._l;
+   b_resid = B->b_resid;
+   b_bufsize = B->b_bufsize;
+   b_iodone = (caddr_t)B->b_iodone;
+   b_error = B->b_error;
+   b_edev = B->b_edev;
+}; 
+
+typedef struct devinfo {
+   int dev_major;  /* major number */
+   int dev_minor;  /* minor number */
+   int dev_instance;   /* instance number */
+   string dev_name;/* name of device */
+   string dev_statname;/* name of device + instance/minor */
+   string dev_pathname;/* pathname of device */
+} devinfo_t;
+
+#pragma D binding "1.0" translator
+translator devinfo_t < struct buf *B > {
+   dev_major = B->b_dip != NULL ? getmajor(B->b_edev) :
+   getmajor(B->b_file->v_vfsp->vfs_dev);
+   dev_minor = B->b_dip != NULL ? getminor(B->b_edev) :
+   getminor(B->b_file->v_vfsp->vfs_dev);
+   dev_instance = B->b_dip == NULL ? 
+   getminor(B->b_file->v_vfsp->vfs_dev) :
+   ((struct dev_info *)B->b_dip)->devi_instance;
+   dev_name = B->b_dip == NULL ? "nfs" :
+   stringof(`devnamesp[getmajor(B->b_edev)].dn_name);
+   dev_statname = strjoin(B->b_dip == NULL ? "nfs" :
+   stringof(`devnamesp[getmajor(B->b_edev)].dn_name),
+   lltostr(B->b_dip == NULL ? getminor(B->b_file->v_vfsp->vfs_dev) :
+   ((struct dev_info *)B->b_dip)->devi_instance == 0 &&
+   ((struct dev_info *)B->b_dip)->devi_parent != NULL &&
+   ((struct dev_info *)B->b_dip)->devi_parent->devi_node_name ==
+   "pseudo" ? getminor(B->b_edev) :
+   ((struct dev_info *)B->b_dip)->devi_instance));
+   dev_pathname = B->b_dip == NULL ? "" :
+   ddi_pathname(B->b_dip

Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Bruce Evans

On Tue, 5 Jun 2012, Andrey Chernov wrote:


On Tue, Jun 05, 2012 at 09:47:42AM +0200, Pawel Jakub Dawidek wrote:

  "The setting of errno after a successful call to a function is
  unspecified unless the description of that function specifies that
  errno shall not be modified."


Very interesting. However free(3) is always successful. Maybe we need
more context here, but the sentence above might talk about functions
that can either succeed or fail and such functions do set errno on
failure, but we don't know what they do to errno on success - they
sometimes interact with the errno, free(3) never does.


According to Austing Group interpretation, this setence talks about
funtions which always succeed too, please see
http://austingroupbugs.net/view.php?id=385


This has very little to do with POSIX.  It is a basic part of Standard
C that the C library may, at its option, clobber errno, gratuitously
or otherwise.  From n869.txt:

   [#3]  The  value of errno is zero at program startup, but is
   never set to zero by any library function.159)  The value of
   errno  may  be  set  to  nonzero  by a library function call
   whether or not there is an error, provided the use of  errno
   is not documented in the description of the function in this
   International Standard.

Use of errno is not documented for free(); thus free() is permitted to
clobber errno.

POSIX may require errno to not be clobbered, especially for its functions.
It probably shouldn't do this for Standard C library functions like free(),
since this would be an extension and any use of the extension would give
unnecessarily unportanle code.


I aware that my interpretation might be too wishful, but it is pretty
obvious to save errno value when calling a function that can eventually
fail - when we save the errno we don't know if it will fail or not, so
we have to do that, but requiring to save errno when calling a void
function that can't fail is simply silly and complicates the code
without a reason.


This has very little to do with success or failure.  It does complicate
the code for callers, but actually simplifies the library.  Since most
libary functions aren't required to preserve errno, they can call each
other without having save and restore errno when they call each other.


It still can fail due to internal errors, it just not returns failure.
For internal errors POSIX states that errno state is unspecified.


I agree that the standards aren't clear, but if saving errno around
free(3) is the way to go, then I'm sure we have much more problems in
our code, even if it is not suppose to be portable it should be correct
- we never know who and when will take the code and port it.


Currently they are pretty clear in that moment, although I agree that if
POSIX says it should not modify errno, the life will be easy. Lets look at
their further movement, since they are already aware of this specific
problem.


They are perfectly clear.


I guess what I'm trying to say here is that this is much bigger change
than it looks and we should probably agree on some global rule here.


...which not violate standards.


Yes, its completion is a very large and ugly change.  realpath() is a
POSIX interface, so any code that implements or uses it can safely assume
POSIX requirements.  But non-POSIX code can only safely assume Standard
C requirements.  OTOH, the libary can assume anything that it wants and
implements for itself, since it is the implementation so it can make
free() easy to use for itself, with any extensions that aren't incompatible
with Standard C.  Since free() is allowed to clobber errno, it is also
allowed to do a null clobber as a compatible extension.

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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Wed, Jun 06, 2012 at 04:57:29AM +1000, Bruce Evans wrote:
> POSIX may require errno to not be clobbered, especially for its functions.
> It probably shouldn't do this for Standard C library functions like free(),
> since this would be an extension and any use of the extension would give
> unnecessarily unportanle code.

POSIX feels itself like they own all Standard C functions now. See 
"Resolved state" text for upcoming standard there:

"At line 30583 [XSH free DESCRIPTION], add a paragraph with CX shading:

The free() function shall not modify errno if ptr is a null pointer
or a pointer previously returned as if by malloc() and not yet 
deallocated.

At line 30591 [APPLICATION USAGE], add a new paragraph:

Because the free() function does not modify errno for valid pointers, it
is safe to use it in cleanup code without corrupting earlier errors, ..."

> OTOH, the libary can assume anything that it wants and
> implements for itself, since it is the implementation so it can make
> free() easy to use for itself, with any extensions that aren't incompatible
> with Standard C.  Since free() is allowed to clobber errno, it is also
> allowed to do a null clobber as a compatible extension.

Yes, it is safe for free() itself to save errno and still stay compliant 
with both current and upcoming POSIX and with Standard C. But any code
which rely on that is compliant with upcoming POSIX only. Since people 
don't want mass changes in that area, this is some sort of compromise
acceptable for me (in case free() itself will save/restore errno, of 
course).

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


svn commit: r236629 - head/include

2012-06-05 Thread Ed Schouten
Author: ed
Date: Tue Jun  5 19:42:57 2012
New Revision: 236629
URL: http://svn.freebsd.org/changeset/base/236629

Log:
  Fix a small typo. Fireware -> firmware.
  
  MFC after:2 weeks

Modified:
  head/include/fmtmsg.h

Modified: head/include/fmtmsg.h
==
--- head/include/fmtmsg.h   Tue Jun  5 18:58:05 2012(r236628)
+++ head/include/fmtmsg.h   Tue Jun  5 19:42:57 2012(r236629)
@@ -32,7 +32,7 @@
 /* Source of condition is... */
 #defineMM_HARD 0x0001  /* ...hardware. */
 #defineMM_SOFT 0x0002  /* ...software. */
-#defineMM_FIRM 0x0004  /* ...fireware. */
+#defineMM_FIRM 0x0004  /* ...firmware. */
 
 /* Condition detected by... */
 #defineMM_APPL 0x0010  /* ...application. */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236634 - head/usr.sbin/pmcstat

2012-06-05 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jun  5 20:08:59 2012
New Revision: 236634
URL: http://svn.freebsd.org/changeset/base/236634

Log:
  Don't crash trying to load symbols from striped file.
  
  PR:   bin/167361
  Submitted by: Slawa Olhovchenkov 
  Silence from: jkoshy

Modified:
  head/usr.sbin/pmcstat/pmcstat_log.c

Modified: head/usr.sbin/pmcstat/pmcstat_log.c
==
--- head/usr.sbin/pmcstat/pmcstat_log.c Tue Jun  5 19:59:09 2012
(r236633)
+++ head/usr.sbin/pmcstat/pmcstat_log.c Tue Jun  5 20:08:59 2012
(r236634)
@@ -564,6 +564,8 @@ pmcstat_image_add_symbols(struct pmcstat
}
 
image->pi_symcount += newsyms;
+   if (image->pi_symcount == 0)
+   return;
 
assert(newsyms <= nfuncsyms);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Bruce Evans

On Tue, 5 Jun 2012, Andrey Chernov wrote:


On Wed, Jun 06, 2012 at 04:57:29AM +1000, Bruce Evans wrote:

POSIX may require errno to not be clobbered, especially for its functions.
It probably shouldn't do this for Standard C library functions like free(),
since this would be an extension and any use of the extension would give
unnecessarily unportanle code.


POSIX feels itself like they own all Standard C functions now. See


Not really.  They can extend anything they want...


"Resolved state" text for upcoming standard there:

"At line 30583 [XSH free DESCRIPTION], add a paragraph with CX shading:

The free() function shall not modify errno if ptr is a null pointer
or a pointer previously returned as if by malloc() and not yet
deallocated.


...but the have to mark it as an extension, as they do here.


At line 30591 [APPLICATION USAGE], add a new paragraph:

Because the free() function does not modify errno for valid pointers, it
is safe to use it in cleanup code without corrupting earlier errors, ..."


This is essentially unusable (so a bad idea).  Instead of unconditionally
saving and restoring errno around calls to free(), portable POSIX code
can soon use a messy ifdef to avoid doing this in some cases, but still
has to do it in other cases.  The results is just bloat and complexity
at the source level:

#if _POSIX_VERSION < mumble
int sverrno;
#endif
...
if (wantfree)
#if _POSIX_VERSION < mumble
{   /* I made these braces condtional ... */
sverrno = errno;
#endif
free(p);
#if _POSIX_VERSION < mumble
errno = sverrno;
}   /* ... to maximise the ugliness */
#endif


OTOH, the libary can assume anything that it wants and
implements for itself, since it is the implementation so it can make
free() easy to use for itself, with any extensions that aren't incompatible
with Standard C.  Since free() is allowed to clobber errno, it is also
allowed to do a null clobber as a compatible extension.


Yes, it is safe for free() itself to save errno and still stay compliant
with both current and upcoming POSIX and with Standard C. But any code
which rely on that is compliant with upcoming POSIX only. Since people
don't want mass changes in that area, this is some sort of compromise
acceptable for me (in case free() itself will save/restore errno, of
course).


libc has lots of magic non-conforming code.  A little more won't hurt.

However, free() is currently not careful about errno.  It begins with
an optional utrace() call, and this can in theory fail with errno ENOMEM
even if there are no bugs in malloc() (all other errors from utrace()
indicate bugs in the caller, assuming that the list of errnos in its man
page is complete).  malloc.c makes a few other sys(lib?)calls and never
saves errno.  I don't know if the others are reachable from free().

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


Re: svn commit: r236593 - head/share/man/man4

2012-06-05 Thread Gavin Atkinson
On Mon, 4 Jun 2012, David E. O'Brien wrote:
> Author: obrien
> Date: Mon Jun  4 22:59:06 2012
> New Revision: 236593
> URL: http://svn.freebsd.org/changeset/base/236593
> 
> Log:
>   Add a man page for filemon(4) [r236592].

[...]

> Added: head/share/man/man4/filemon.4
> ==
> --- /dev/null 00:00:00 1970   (empty, because file is newly added)
> +++ head/share/man/man4/filemon.4 Mon Jun  4 22:59:06 2012
> (r236593)
> @@ -0,0 +1,166 @@
> +.\" Copyright (c) 2012
> +.\"  David E. O'Brien .  All rights reserved.
> +.\"
> +.\" Redistribution and use in source and binary forms, with or without
> +.\" modification, are permitted provided that the following conditions
> +.\" are met:
> +.\" 1. Redistributions of source code must retain the above copyright
> +.\"notice, this list of conditions and the following disclaimer.
> +.\" 2. Redistributions in binary form must reproduce the above copyright
> +.\"notice, this list of conditions and the following disclaimer in the
> +.\"documentation and/or other materials provided with the distribution.
> +.\" 3. All advertising materials mentioning features or use of this software
> +.\"must display the following acknowledgement:
> +.\"  This product includes software developed by David E. O'Brien and
> +.\"  contributors.
> +.\" 4. Neither the name of the author nor the names of its contributors
> +.\"may be used to endorse or promote products derived from this software
> +.\"without specific prior written permission.

The man page has a four-clause license, but the code itself uses the 
two-clause license.  Is there any chance that the man page license could 
lose the third and fourth clauses to match?

Thanks,

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


svn commit: r236637 - head/share/man/man4

2012-06-05 Thread David E. O'Brien
Author: obrien
Date: Tue Jun  5 20:32:38 2012
New Revision: 236637
URL: http://svn.freebsd.org/changeset/base/236637

Log:
  mdoc police.
  
  Submitted by: ru
  Much thanks to:   ru

Modified:
  head/share/man/man4/filemon.4

Modified: head/share/man/man4/filemon.4
==
--- head/share/man/man4/filemon.4   Tue Jun  5 20:27:41 2012
(r236636)
+++ head/share/man/man4/filemon.4   Tue Jun  5 20:32:38 2012
(r236637)
@@ -50,64 +50,70 @@ responds to two
 calls.
 .Pp
 System calls are denoted using the following single letters:
+.Pp
 .Bl -tag -width indent -compact
-.It Dq Li C
+.It Ql C
 .Xr chdir 2
-.It Dq Li D
+.It Ql D
 .Xr unlink 2
-.It Dq Li E
+.It Ql E
 .Xr exec 2
-.It Dq Li F
+.It Ql F
 .Xr fork 2 ,
 .Xr vfork 2
-.It Dq Li L
+.It Ql L
 .Xr link 2 ,
 .Xr linkat 2 ,
 .Xr symlink 2 ,
 .Xr symlinkat 2
-.It Dq Li M
+.It Ql M
 .Xr rename 2
-.It Dq Li R
+.It Ql R
 .Xr open 2
 for read
-.It Dq Li S
+.It Ql S
 .Xr stat 2
-.It Dq Li W
+.It Ql W
 .Xr open 2
 for write
-.It Dq Li X
+.It Ql X
 .Xr _exit 2
 .El
 .Pp
 Note that
-.Dq R
+.Ql R
 following
-.Dq W
+.Ql W
 records can represent a single
 .Xr open 2
 for R/W,
 or two seperate
 .Xr open 2
 calls, one for
-R
+.Ql R
 and one for
-W.
+.Ql W .
 .Sh IOCTLS
 User mode programs communicate with the
-.Nm filemon
-driver through a
-number of ioctls which are described below.
+.Nm
+driver through a number of ioctls which are described below.
 Each takes a single argument.
-.Bl -tag -width FILEMON_SET_PID
+.Bl -tag -width ".Dv FILEMON_SET_PID"
 .It Dv FILEMON_SET_FD
 Write the internal tracing buffer to the supplied open file descriptor.
 .It Dv FILEMON_SET_PID
 Child process ID to trace.
 .El
 .Sh RETURN VALUES
-The ioctl returns zero on success and non-zero on failure.
+.\" .Rv -std ioctl
+The
+.Fn ioctl
+function returns the value 0 if successful;
+otherwise the value \-1 is returned and the global variable
+.Va errno
+is set to indicate the error.
 .Sh FILES
-.Bl -tag -width /dev/zero
+.Bl -tag -width ".Pa /dev/filemon"
 .It Pa /dev/filemon
 .El
 .Sh EXAMPLES
@@ -127,7 +133,7 @@ open_filemon(void)
int fm_fd, fm_log;
 
if ((fm_fd = open("/dev/filemon", O_RDWR)) == -1)
-   err(1, "open(\"/dev/filemon\", O_RDWR)");
+   err(1, "open(\e"/dev/filemon\e", O_RDWR)");
if ((fm_log = open("filemon.out",
O_CREAT | O_WRONLY | O_TRUNC, DEFFILEMODE)) == -1)
err(1, "open(filemon.out)");
@@ -156,7 +162,9 @@ Creates a file named
 .Pa filemon.out
 and configures the
 .Nm
-device to write the filemon buffer contents to it.
+device to write the
+.Nm
+buffer contents to it.
 .Sh SEE ALSO
 .Xr dtrace 1 ,
 .Xr ktrace 1 ,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236639 - head/sys/cam/ata

2012-06-05 Thread Alexander Motin
Author: mav
Date: Tue Jun  5 20:39:12 2012
New Revision: 236639
URL: http://svn.freebsd.org/changeset/base/236639

Log:
  Use default error handler when flushing disk caches.

Modified:
  head/sys/cam/ata/ata_da.c

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Tue Jun  5 20:34:56 2012(r236638)
+++ head/sys/cam/ata/ata_da.c   Tue Jun  5 20:39:12 2012(r236639)
@@ -490,7 +490,7 @@ adaclose(struct disk *dp)
ata_48bit_cmd(&ccb->ataio, ATA_FLUSHCACHE48, 0, 0, 0);
else
ata_28bit_cmd(&ccb->ataio, ATA_FLUSHCACHE, 0, 0, 0);
-   cam_periph_runccb(ccb, /*error_routine*/NULL, /*cam_flags*/0,
+   cam_periph_runccb(ccb, adaerror, /*cam_flags*/0,
/*sense_flags*/0, softc->disk->d_devstat);
 
if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236640 - head/share/man/man4

2012-06-05 Thread Michael Tuexen
Author: tuexen
Date: Tue Jun  5 20:48:13 2012
New Revision: 236640
URL: http://svn.freebsd.org/changeset/base/236640

Log:
  The cmsg_len field includes the cmsg header. So use CMSG_LEN().
  
  MFC after: 3 days

Modified:
  head/share/man/man4/ip.4

Modified: head/share/man/man4/ip.4
==
--- head/share/man/man4/ip.4Tue Jun  5 20:39:12 2012(r236639)
+++ head/share/man/man4/ip.4Tue Jun  5 20:48:13 2012(r236640)
@@ -165,7 +165,7 @@ The
 .Vt cmsghdr
 fields have the following values:
 .Bd -literal
-cmsg_len = sizeof(struct in_addr)
+cmsg_len = CMSG_LEN(sizeof(struct in_addr))
 cmsg_level = IPPROTO_IP
 cmsg_type = IP_RECVDSTADDR
 .Ed
@@ -184,7 +184,7 @@ structure followed by the
 address.
 The cmsghdr fields should have the following values:
 .Bd -literal
-cmsg_len = sizeof(struct in_addr)
+cmsg_len = CMSG_LEN(sizeof(struct in_addr))
 cmsg_level = IPPROTO_IP
 cmsg_type = IP_SENDSRCADDR
 .Ed
@@ -279,7 +279,7 @@ that contains a cmsghdr structure follow
 .Tn TTL .
 The cmsghdr fields have the following values:
 .Bd -literal
-cmsg_len = sizeof(u_char)
+cmsg_len = CMSG_LEN(sizeof(u_char))
 cmsg_level = IPPROTO_IP
 cmsg_type = IP_RECVTTL
 .Ed
@@ -307,7 +307,7 @@ The
 .Vt cmsghdr
 fields have the following values:
 .Bd -literal
-cmsg_len = sizeof(struct sockaddr_dl)
+cmsg_len = CMSG_LEN(sizeof(struct sockaddr_dl))
 cmsg_level = IPPROTO_IP
 cmsg_type = IP_RECVIF
 .Ed
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Wed, Jun 06, 2012 at 06:11:01AM +1000, Bruce Evans wrote:
> This is essentially unusable (so a bad idea).  Instead of unconditionally
> saving and restoring errno around calls to free(), portable POSIX code
> can soon use a messy ifdef to avoid doing this in some cases, but still
> has to do it in other cases.  The results is just bloat and complexity
> at the source level:

It looks like they now consider POSIX as moving target where previous 
POSIX versions compatibility is not so essential to care about much. I 
don't have other interpretation of their decision to suddenly accept 
free() as not modifying errno. Since they clearly indicate code 
differences for old and new standard, they are well aware of them and of 
resulting code bloating.

> However, free() is currently not careful about errno.  It begins with
> an optional utrace() call, and this can in theory fail with errno ENOMEM
> even if there are no bugs in malloc() (all other errors from utrace()
> indicate bugs in the caller, assuming that the list of errnos in its man
> page is complete).  malloc.c makes a few other sys(lib?)calls and never
> saves errno.  I don't know if the others are reachable from free().

I fill PR about that:
http://www.freebsd.org/cgi/query-pr.cgi?pr=168719

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


Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Joerg Sonnenberger
On Wed, Jun 06, 2012 at 01:01:54AM +0400, Andrey Chernov wrote:
> On Wed, Jun 06, 2012 at 06:11:01AM +1000, Bruce Evans wrote:
> > This is essentially unusable (so a bad idea).  Instead of unconditionally
> > saving and restoring errno around calls to free(), portable POSIX code
> > can soon use a messy ifdef to avoid doing this in some cases, but still
> > has to do it in other cases.  The results is just bloat and complexity
> > at the source level:
> 
> It looks like they now consider POSIX as moving target where previous 
> POSIX versions compatibility is not so essential to care about much. I 
> don't have other interpretation of their decision to suddenly accept 
> free() as not modifying errno. Since they clearly indicate code 
> differences for old and new standard, they are well aware of them and of 
> resulting code bloating.

Can you please stop the unjustified rants? The "new" behavior of free(3)
doesn't break any existing code, so it is certainly compatible with
"old" free(3). The "new" behavior can be obtained easily for code that
wants to be portable to "old" implementations using the C preprocessor
and a small inline wrapper. As such, there is no code bloating.

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


svn commit: r236644 - head/tools/tools/ifpifa

2012-06-05 Thread Maksim Yevmenkin
Author: emax
Date: Tue Jun  5 21:35:47 2012
New Revision: 236644
URL: http://svn.freebsd.org/changeset/base/236644

Log:
  Add a very simple debug tool that would dump list of interfaces,
  addresses on each interface, and, associated refcounter. I found
  it handy to check for address refcounter leaks.

Added:
  head/tools/tools/ifpifa/
  head/tools/tools/ifpifa/Makefile   (contents, props changed)
  head/tools/tools/ifpifa/ifpifa.c   (contents, props changed)

Added: head/tools/tools/ifpifa/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/ifpifa/MakefileTue Jun  5 21:35:47 2012
(r236644)
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+PROG=  ifpifa
+NO_MAN=
+WARNS?=6
+BINDIR?=/usr/local/bin
+DPADD=${LIBKVM}
+LDADD=-lkvm
+
+.include 

Added: head/tools/tools/ifpifa/ifpifa.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/ifpifa/ifpifa.cTue Jun  5 21:35:47 2012
(r236644)
@@ -0,0 +1,190 @@
+/*-
+ * Copyright (c) 2012 maksim yevmenkin 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* gcc -Wall -ggdb ifpifa.c -lkvm -o ifpifa */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+__FBSDID("$FreeBSD$");
+
+static struct nlistnl[] = {
+#define N_IFNET 0
+{ .n_name = "_ifnet", },
+   { .n_name = NULL, },
+};
+
+static int
+kread(kvm_t *kd, u_long addr, char *buffer, int size)
+{
+   if (kd == NULL || buffer == NULL)
+   return (-1);
+ 
+   if (kvm_read(kd, addr, buffer, size) != size) {
+   warnx("kvm_read: %s", kvm_geterr(kd));
+   return (-1);
+   }
+ 
+   return (0);
+}
+
+int
+main(void)
+{
+   kvm_t *kd;
+   char errbuf[_POSIX2_LINE_MAX];
+   u_long ifnetaddr, ifnetaddr_next;
+   u_long ifaddraddr, ifaddraddr_next;
+struct ifnet ifnet;
+struct ifnethead ifnethead;
+union {
+   struct ifaddr ifa;
+   struct in_ifaddr in;
+   struct in6_ifaddr in6;
+} ifaddr;
+   union {
+   struct sockaddr *sa;
+   struct sockaddr_dl *sal;
+   struct sockaddr_in *sa4;
+   struct sockaddr_in6 *sa6;
+   } sa;
+   char addr[INET6_ADDRSTRLEN];
+
+   kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
+   if (kd == NULL) {
+   warnx("kvm_openfiles: %s", errbuf);
+   exit(0);
+   }
+
+   if (kvm_nlist(kd, nl) < 0) {
+warnx("kvm_nlist: %s", kvm_geterr(kd));
+goto out;
+}
+
+   if (nl[N_IFNET].n_type == 0) {
+   warnx("kvm_nlist: no namelist");
+   goto out;
+   }
+
+   if (kread(kd, nl[N_IFNET].n_value,
+ (char *) &ifnethead, sizeof(ifnethead)) != 0)
+   goto out;
+
+   for (ifnetaddr = (u_long) TAILQ_FIRST(&ifnethead);
+ifnetaddr != 0;
+ifnetaddr = ifnetaddr_next) {
+   if (kread(kd, ifnetaddr, (char *) &ifnet, sizeof(ifnet)) != 0)
+   goto out;
+   ifnetaddr_next = (u_long) TAILQ_NEXT(&ifnet, if_link);
+
+   printf("%s\n", ifnet.if_xname);
+
+   for (ifaddraddr = (u_long) TAILQ_FIRST(&ifnet.if_addrhead);
+ifaddrad

Re: svn commit: r236582 - head/lib/libc/stdlib

2012-06-05 Thread Andrey Chernov
On Tue, Jun 05, 2012 at 11:30:34PM +0200, Joerg Sonnenberger wrote:
> On Wed, Jun 06, 2012 at 01:01:54AM +0400, Andrey Chernov wrote:
> > On Wed, Jun 06, 2012 at 06:11:01AM +1000, Bruce Evans wrote:
> > > This is essentially unusable (so a bad idea).  Instead of unconditionally
> > > saving and restoring errno around calls to free(), portable POSIX code
> > > can soon use a messy ifdef to avoid doing this in some cases, but still
> > > has to do it in other cases.  The results is just bloat and complexity
> > > at the source level:
> > 
> > It looks like they now consider POSIX as moving target where previous 
> > POSIX versions compatibility is not so essential to care about much. I 
> > don't have other interpretation of their decision to suddenly accept 
> > free() as not modifying errno. Since they clearly indicate code 
> > differences for old and new standard, they are well aware of them and of 
> > resulting code bloating.
> 
> Can you please stop the unjustified rants? The "new" behavior of free(3)
> doesn't break any existing code, so it is certainly compatible with
> "old" free(3). The "new" behavior can be obtained easily for code that
> wants to be portable to "old" implementations using the C preprocessor
> and a small inline wrapper. As such, there is no code bloating.

Could you please read more carefully, if you decide to stay in the topic?
I already say exactly that few messages behind:

> Yes, it is safe for free() itself to save errno and still stay compliant
> with both current and upcoming POSIX and with Standard C. 

> But any code which rely on that is compliant with upcoming POSIX only. 

It means that when some program wants to conform to current POSIX and 
future POSIX, it either must save errno across the free() in any case or 
use code bloating, just reduced by CPP macro you suggest, not eliminated.

And I don't think it is good decision from POSIX side, from compatibility 
point of view. Are you pretend to attack my personal opinion or what?

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


svn commit: r236645 - head/tools/tools/ifpifa

2012-06-05 Thread Maksim Yevmenkin
Author: emax
Date: Tue Jun  5 22:02:27 2012
New Revision: 236645
URL: http://svn.freebsd.org/changeset/base/236645

Log:
  Fix license
  
  Pointed by:   brueffer

Modified:
  head/tools/tools/ifpifa/ifpifa.c

Modified: head/tools/tools/ifpifa/ifpifa.c
==
--- head/tools/tools/ifpifa/ifpifa.cTue Jun  5 21:35:47 2012
(r236644)
+++ head/tools/tools/ifpifa/ifpifa.cTue Jun  5 22:02:27 2012
(r236645)
@@ -3,7 +3,7 @@
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
+ * modification, are permitted providing that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *notice, this list of conditions and the following disclaimer.
@@ -11,17 +11,17 @@
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 /* gcc -Wall -ggdb ifpifa.c -lkvm -o ifpifa */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236649 - head/sys/dev/ae

2012-06-05 Thread Kevin Lo
Author: kevlo
Date: Wed Jun  6 02:42:30 2012
New Revision: 236649
URL: http://svn.freebsd.org/changeset/base/236649

Log:
  Check the return value of pci_find_cap()

Modified:
  head/sys/dev/ae/if_ae.c

Modified: head/sys/dev/ae/if_ae.c
==
--- head/sys/dev/ae/if_ae.c Wed Jun  6 01:01:12 2012(r236648)
+++ head/sys/dev/ae/if_ae.c Wed Jun  6 02:42:30 2012(r236649)
@@ -1381,12 +1381,13 @@ ae_pm_init(ae_softc_t *sc)
/*
 * Configure PME.
 */
-   pci_find_cap(sc->dev, PCIY_PMG, &pmc);
-   pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2);
-   pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
-   if ((ifp->if_capenable & IFCAP_WOL) != 0)
-   pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
-   pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
+   if (pci_find_cap(dev, PCIY_PMG, &pmc) == 0) {
+   pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2);
+   pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
+   if ((ifp->if_capenable & IFCAP_WOL) != 0)
+   pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
+   pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
+   }
 }
 
 static int
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r236658 - head/sys/arm/at91

2012-06-05 Thread Warner Losh
Author: imp
Date: Wed Jun  6 06:19:52 2012
New Revision: 236658
URL: http://svn.freebsd.org/changeset/base/236658

Log:
  Enhance the Atmel SoC chip identification routines to account for more
  SoC variants.  Fold the AT91SAM9XE chips into the AT91SAM9260
  handling, where appropriate.  The following SoCs/SoC families are recognized:
at91cap9, at91rm9200, at91sam9260, at91sam9261, at91sam9263,
at91sam9g10, at91sam9g20, at91sam9g45, at91sam9n12, at91sam9rl,
at91sam9x5
  and the following variations are also recognized:
at91rm9200_bga, at91rm9200_pqfp, at91sam9xe, at91sam9g45, at91sam9m10,
at91sam9g46, at91sam9m11, at91sam9g15, at91sam9g25, at91sam9g35,
at91sam9x25, at91sam9x35
  This is only the identification routine: no additional Atmel devices
  are supported at this time.
  
  # With these changes, I'm able to boot to the point of identification
  # on a few different Atmel SoCs that we don't yet support using the
  # KB920X config file -- someday tht will be an ATMEL config file...

Modified:
  head/sys/arm/at91/at91.c
  head/sys/arm/at91/at91_machdep.c
  head/sys/arm/at91/at91_mci.c
  head/sys/arm/at91/at91_pmc.c
  head/sys/arm/at91/at91reg.h
  head/sys/arm/at91/at91rm9200.c
  head/sys/arm/at91/at91sam9260.c
  head/sys/arm/at91/at91sam9g20.c
  head/sys/arm/at91/at91var.h

Modified: head/sys/arm/at91/at91.c
==
--- head/sys/arm/at91/at91.cWed Jun  6 04:39:05 2012(r236657)
+++ head/sys/arm/at91/at91.cWed Jun  6 06:19:52 2012(r236658)
@@ -54,8 +54,6 @@ static void at91_eoi(void *);
 
 extern const struct pmap_devmap at91_devmap[];
 
-uint32_t at91_chip_id;
-
 uint32_t at91_master_clock;
 
 static int

Modified: head/sys/arm/at91/at91_machdep.c
==
--- head/sys/arm/at91/at91_machdep.cWed Jun  6 04:39:05 2012
(r236657)
+++ head/sys/arm/at91/at91_machdep.cWed Jun  6 06:19:52 2012
(r236658)
@@ -232,6 +232,156 @@ at91_ramsize(void)
return (1 << (cols + rows + banks + bw));
 }
 
+const char *soc_type_name[] = {
+   [AT91_T_CAP9] = "at91cap9",
+   [AT91_T_RM9200] = "at91rm9200",
+   [AT91_T_SAM9260] = "at91sam9260",
+   [AT91_T_SAM9261] = "at91sam9261",
+   [AT91_T_SAM9263] = "at91sam9263",
+   [AT91_T_SAM9G10] = "at91sam9g10",
+   [AT91_T_SAM9G20] = "at91sam9g20",
+   [AT91_T_SAM9G45] = "at91sam9g45",
+   [AT91_T_SAM9N12] = "at91sam9n12",
+   [AT91_T_SAM9RL] = "at91sam9rl",
+   [AT91_T_SAM9X5] = "at91sam9x5",
+   [AT91_T_NONE] = "UNKNOWN"
+};
+   
+const char *soc_subtype_name[] = {
+   [AT91_ST_NONE] = "UNKNOWN",
+   [AT91_ST_RM9200_BGA] = "at91rm9200_bga",
+   [AT91_ST_RM9200_PQFP] = "at91rm9200_pqfp",
+   [AT91_ST_SAM9XE] = "at91sam9xe",
+   [AT91_ST_SAM9G45] = "at91sam9g45",
+   [AT91_ST_SAM9M10] = "at91sam9m10",
+   [AT91_ST_SAM9G46] = "at91sam9g46",
+   [AT91_ST_SAM9M11] = "at91sam9m11",
+   [AT91_ST_SAM9G15] = "at91sam9g15",
+   [AT91_ST_SAM9G25] = "at91sam9g25",
+   [AT91_ST_SAM9G35] = "at91sam9g35",
+   [AT91_ST_SAM9X25] = "at91sam9x25",
+   [AT91_ST_SAM9X35] = "at91sam9x35",
+};
+
+#define AT91_DBGU0 0x0200  /* Most */
+#define AT91_DBGU1 0x0fffee00  /* SAM9263, CAP9, and SAM9G45 */
+
+struct at91_soc_info soc_data;
+
+/*
+ * Read the SoC ID from the CIDR register and try to match it against the
+ * values we know.  If we find a good one, we return true.  If not, we
+ * return false.  When we find a good one, we also find the subtype
+ * and CPU family.
+ */
+static int
+at91_try_id(uint32_t dbgu_base)
+{
+   uint32_t socid;
+
+   soc_data.cidr = *(volatile uint32_t *)(AT91_BASE + dbgu_base + 
DBGU_C1R);
+   socid = soc_data.cidr & ~AT91_CPU_VERSION_MASK;
+
+   soc_data.type = AT91_T_NONE;
+   soc_data.subtype = AT91_ST_NONE;
+   soc_data.family = (soc_data.cidr & AT91_CPU_FAMILY_MASK) >> 20;
+   soc_data.exid = *(volatile uint32_t *)(AT91_BASE + dbgu_base + 
DBGU_C2R);
+
+   switch (socid) {
+   case AT91_CPU_CAP9:
+   soc_data.type = AT91_T_CAP9;
+   break;
+   case AT91_CPU_RM9200:
+   soc_data.type = AT91_T_RM9200;
+   break;
+   case AT91_CPU_SAM9XE128:
+   case AT91_CPU_SAM9XE256:
+   case AT91_CPU_SAM9XE512:
+   case AT91_CPU_SAM9260:
+   soc_data.type = AT91_T_SAM9260;
+   if (soc_data.family == AT91_FAMILY_SAM9XE)
+   soc_data.subtype = AT91_ST_SAM9XE;
+   break;
+   case AT91_CPU_SAM9261:
+   soc_data.type = AT91_T_SAM9261;
+   break;
+   case AT91_CPU_SAM9263:
+   soc_data.type = AT91_T_SAM9263;
+   break;
+   case AT91_CPU_SAM9G10:
+   soc_data.type = AT91_T_SAM9G10;
+   break;