*
* @APPLE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
* and increments the current iovec base address and offset value.
* If the current iovec length is 0 then advance to the next
* iovec (if any).
+ * If the a_count passed in is 0, than only do the advancement
+ * over any 0 length iovec's.
*/
void uio_update( uio_t a_uio, user_size_t a_count )
{
}
if (UIO_IS_64_BIT_SPACE(a_uio)) {
- if (a_count > a_uio->uio_iovs.uiovp->iov_len) {
- a_uio->uio_iovs.uiovp->iov_base += a_uio->uio_iovs.uiovp->iov_len;
- a_uio->uio_iovs.uiovp->iov_len = 0;
- }
- else {
- a_uio->uio_iovs.uiovp->iov_base += a_count;
- a_uio->uio_iovs.uiovp->iov_len -= a_count;
- }
+ /*
+ * if a_count == 0, then we are asking to skip over
+ * any empty iovs
+ */
+ if (a_count) {
+ if (a_count > a_uio->uio_iovs.uiovp->iov_len) {
+ a_uio->uio_iovs.uiovp->iov_base += a_uio->uio_iovs.uiovp->iov_len;
+ a_uio->uio_iovs.uiovp->iov_len = 0;
+ }
+ else {
+ a_uio->uio_iovs.uiovp->iov_base += a_count;
+ a_uio->uio_iovs.uiovp->iov_len -= a_count;
+ }
#if 1 // LP64todo - remove this temp workaround once we go live with uio KPI
- if (a_uio->uio_resid < 0) {
- a_uio->uio_resid = 0;
- }
- if (a_count > (user_size_t)a_uio->uio_resid) {
- a_uio->uio_offset += a_uio->uio_resid;
- a_uio->uio_resid = 0;
- }
- else {
- a_uio->uio_offset += a_count;
- a_uio->uio_resid -= a_count;
- }
+ if (a_uio->uio_resid < 0) {
+ a_uio->uio_resid = 0;
+ }
+ if (a_count > (user_size_t)a_uio->uio_resid) {
+ a_uio->uio_offset += a_uio->uio_resid;
+ a_uio->uio_resid = 0;
+ }
+ else {
+ a_uio->uio_offset += a_count;
+ a_uio->uio_resid -= a_count;
+ }
#else
- if (a_uio->uio_resid_64 < 0) {
- a_uio->uio_resid_64 = 0;
- }
- if (a_count > (user_size_t)a_uio->uio_resid_64) {
- a_uio->uio_offset += a_uio->uio_resid_64;
- a_uio->uio_resid_64 = 0;
- }
- else {
- a_uio->uio_offset += a_count;
- a_uio->uio_resid_64 -= a_count;
- }
+ if (a_uio->uio_resid_64 < 0) {
+ a_uio->uio_resid_64 = 0;
+ }
+ if (a_count > (user_size_t)a_uio->uio_resid_64) {
+ a_uio->uio_offset += a_uio->uio_resid_64;
+ a_uio->uio_resid_64 = 0;
+ }
+ else {
+ a_uio->uio_offset += a_count;
+ a_uio->uio_resid_64 -= a_count;
+ }
#endif // LP64todo
-
- /* advance to next iovec if current one is totally consumed */
- while (a_uio->uio_iovcnt > 0 && a_uio->uio_iovs.uiovp->iov_len == 0) {
+ }
+ /*
+ * advance to next iovec if current one is totally consumed
+ */
+ while (a_uio->uio_iovcnt > 0 && a_uio->uio_iovs.uiovp->iov_len == 0) {
a_uio->uio_iovcnt--;
if (a_uio->uio_iovcnt > 0) {
a_uio->uio_iovs.uiovp++;
}
}
else {
- if (a_count > a_uio->uio_iovs.kiovp->iov_len) {
- a_uio->uio_iovs.kiovp->iov_base += a_uio->uio_iovs.kiovp->iov_len;
- a_uio->uio_iovs.kiovp->iov_len = 0;
- }
- else {
- a_uio->uio_iovs.kiovp->iov_base += a_count;
- a_uio->uio_iovs.kiovp->iov_len -= a_count;
- }
- if (a_uio->uio_resid < 0) {
- a_uio->uio_resid = 0;
- }
- if (a_count > (user_size_t)a_uio->uio_resid) {
- a_uio->uio_offset += a_uio->uio_resid;
- a_uio->uio_resid = 0;
- }
- else {
- a_uio->uio_offset += a_count;
- a_uio->uio_resid -= a_count;
+ /*
+ * if a_count == 0, then we are asking to skip over
+ * any empty iovs
+ */
+ if (a_count) {
+ if (a_count > a_uio->uio_iovs.kiovp->iov_len) {
+ a_uio->uio_iovs.kiovp->iov_base += a_uio->uio_iovs.kiovp->iov_len;
+ a_uio->uio_iovs.kiovp->iov_len = 0;
+ }
+ else {
+ a_uio->uio_iovs.kiovp->iov_base += a_count;
+ a_uio->uio_iovs.kiovp->iov_len -= a_count;
+ }
+ if (a_uio->uio_resid < 0) {
+ a_uio->uio_resid = 0;
+ }
+ if (a_count > (user_size_t)a_uio->uio_resid) {
+ a_uio->uio_offset += a_uio->uio_resid;
+ a_uio->uio_resid = 0;
+ }
+ else {
+ a_uio->uio_offset += a_count;
+ a_uio->uio_resid -= a_count;
+ }
}
-
- /* advance to next iovec if current one is totally consumed */
- while (a_uio->uio_iovcnt > 0 && a_uio->uio_iovs.kiovp->iov_len == 0) {
+ /*
+ * advance to next iovec if current one is totally consumed
+ */
+ while (a_uio->uio_iovcnt > 0 && a_uio->uio_iovs.kiovp->iov_len == 0) {
a_uio->uio_iovcnt--;
if (a_uio->uio_iovcnt > 0) {
a_uio->uio_iovs.kiovp++;