code:
From a311701ea7eebff003e88694a391d810485f36e0 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 20 Jul 2019 21:18:11 +0200
Subject: [PATCH libaio 13/28] man: Fix markup

- Remove unnecessary macro argument quoting.
- Variables, pathnames in italics.
- Keywords in bold.
- Man page references in bold, followed by the man page number.
- Fix TP/TQ macro usage.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 man/io.3               | 38 ++++++++++++++-------------
 man/io_cancel.3        | 23 ++++++++++------
 man/io_fsync.3         |  9 ++++---
 man/io_getevents.3     | 33 ++++++++++++++++-------
 man/io_prep_fsync.3    | 59 ++++++++++++++++++++++++++++++------------
 man/io_prep_pread.3    | 19 +++++---------
 man/io_prep_pwrite.3   | 14 ++++------
 man/io_queue_init.3    | 34 +++++++++++++++---------
 man/io_queue_release.3 | 16 +++++++-----
 man/io_queue_run.3     | 18 ++++++++-----
 man/io_queue_wait.3    | 25 +++++++++++-------
 man/io_set_callback.3  |  5 ++--
 man/io_submit.3        | 26 +++++++++++--------
 13 files changed, 195 insertions(+), 124 deletions(-)

diff --git a/man/io.3 b/man/io.3
index 922fbca..f40da41 100644
--- a/man/io.3
+++ b/man/io.3
@@ -10,16 +10,18 @@ io \- Asynchronous IO
 .sp
 .fi
 .SH DESCRIPTION
-The libaio library defines a new set of I/O operations which can
+The
+.B libaio
+library defines a new set of I/O operations which can
 significantly reduce the time an application spends waiting at I/O.  The
 new functions allow a program to initiate one or more I/O operations and
 then immediately resume normal work while the I/O operations are
 executed in parallel.

 These functions are part of the library with realtime functions named
-.IR libaio .
+.BR libaio .
 They are not actually part of the
-.IR "libc"
+.B libc
 binary.
 The implementation of these functions can be done using support in the
 kernel.
@@ -27,9 +29,9 @@ kernel.
 All IO operations operate on files which were opened previously.  There
 might be arbitrarily many operations running for one file.  The
 asynchronous I/O operations are controlled using a data structure named
-.IR "struct iocb"
+.B struct iocb
 It is defined in
-.IR "libaio.h"
+.I libaio.h
 as follows.

 .nf
@@ -74,7 +76,7 @@ struct iocb {

 .fi
 .TP
-.IR "int aio_fildes"
+.BI int " aio_fildes"
 This element specifies the file descriptor to be used for the
 operation.  It must be a legal descriptor, otherwise the operation will
 fail.
@@ -82,55 +84,55 @@ fail.
 The device on which the file is opened must allow the seek operation.
 I.e., it is not possible to use any of the IO operations on devices
 like terminals where an
-.IR "lseek"
+.BR lseek (2)
 call would lead to an error.
 .TP
-.IR "long u.c.offset"
+.BI long " u.c.offset"
 This element specifies the offset in the file at which the operation (input
 or output) is performed.  Since the operations are carried out in arbitrary
 order and more than one operation for one file descriptor can be
 started, one cannot expect a current read/write position of the file
 descriptor.
 .TP
-.IR "void *buf"
+.BI "void *" buf
 This is a pointer to the buffer with the data to be written or the place
 where the read data is stored.
 .TP
-.IR "long u.c.nbytes"
+.BI long " u.c.nbytes"
 This element specifies the length of the buffer pointed to by
 .IR io_buf .
 .TP
-.IR "int aio_reqprio"
+.BI int " aio_reqprio"
 Is not currently used.
 .TP
 .B "IO_CMD_PREAD"
 Start a read operation.  Read from the file at position
-.IR "u.c.offset"
+.I u.c.offset
 and store the next
-.IR "u.c.nbytes"
+.I u.c.nbytes
 bytes in the
 buffer pointed to by
 .IR buf .
 .TP
 .B "IO_CMD_PWRITE"
 Start a write operation.  Write
-.IR "u.c.nbytes"
+.I u.c.nbytes
 bytes starting at
-.IR "buf"
+.I buf
 into the file starting at position
 .IR u.c.offset .
 .TP
 .B "IO_CMD_NOP"
 Do nothing for this control block.  This value is useful sometimes when
 an array of
-.IR "struct iocb"
+.B struct iocb
 values contains holes, i.e., some of the
 values must not be handled although the whole array is presented to the
-.IR "io_submit"
+.BR io_submit (3)
 function.
 .TP
 .B "IO_CMD_FSYNC"
-.TP
+.TQ
 .B "IO_CMD_POLL"
 This is experimental.
 .SH EXAMPLE
diff --git a/man/io_cancel.3 b/man/io_cancel.3
index a4683be..3ca629b 100644
--- a/man/io_cancel.3
+++ b/man/io_cancel.3
@@ -9,7 +9,7 @@ io_cancel \- Cancel io requests
 .B #include <libaio.h>
 .sp
 .br
-.BI "int io_cancel(io_context_t ctx, struct iocb *iocb)"
+.BI "int io_cancel(io_context_t " ctx ", struct iocb *" iocb ");"
 .br
 .sp
 struct iocb {
@@ -21,8 +21,11 @@ struct iocb {
 };
 .fi
 .SH DESCRIPTION
-Attempts to cancel an iocb previously passed to io_submit.  If
-the operation is successfully cancelled, the resulting event is
+Attempts to cancel an
+.I iocb
+previously passed to
+.BR io_submit (3).
+If the operation is successfully cancelled, the resulting event is
 copied into the memory pointed to by result without being placed
 into the completion queue.
 .PP
@@ -33,19 +36,23 @@ have to be overwritten soon.  As an example, assume an application, which
 writes data in files in a situation where new incoming data would have
 to be written in a file which will be updated by an enqueued request.
 .SH "RETURN VALUES"
-0 is returned on success, otherwise returns errno.
+\fI0\fP is returned on success, otherwise returns \fIerrno\fP.
 .SH ERRORS
 .TP
 .B EFAULT
 If any of the data structures pointed to are invalid.
 .TP
 .B EINVAL
-If aio_context specified by ctx_id is
-invalid.
+If
+.I aio_context
+specified by
+.I ctx_id
+is invalid.
 .TP
 .B EAGAIN
-If the iocb specified was not
-cancelled.
+If the
+.I iocb
+specified was not cancelled.
 .TP
 .B ENOSYS
 If not implemented.
diff --git a/man/io_fsync.3 b/man/io_fsync.3
index bc6778a..06538c4 100644
--- a/man/io_fsync.3
+++ b/man/io_fsync.3
@@ -15,7 +15,7 @@ io_fsync \- Synchronize a file's complete in-core state with that on disk
 .B #include <libaio.h>
 .sp
 .br
-.BI "int io_fsync(io_context_t ctx, struct iocb *iocb, io_callback_t cb, int fd)"
+.BI "int io_fsync(io_context_t " ctx ", struct iocb *" iocb ", io_callback_t " cb ", int " fd ");"
 .sp
 struct iocb {
 	void		*data;
@@ -40,7 +40,7 @@ Calling this function forces all I/O operations operating queued at the
 time of the function call operating on the file descriptor
 .IR "iocb->io_fildes"
 into the synchronized I/O completion state.  The
-.IR "io_fsync"
+.BR io_fsync ()
 function returns
 immediately but the notification through the method described in
 .IR "io_callback"
@@ -49,7 +49,10 @@ file descriptor have terminated and the file is synchronized.  This also
 means that requests for this very same file descriptor which are queued
 after the synchronization request are not affected.
 .SH "RETURN VALUES"
-Returns 0, otherwise returns errno.
+Returns
+.BR 0 ,
+otherwise returns
+.IR errno .
 .SH ERRORS
 .TP
 .B EFAULT
diff --git a/man/io_getevents.3 b/man/io_getevents.3
index 05b2507..6fbcc24 100644
--- a/man/io_getevents.3
+++ b/man/io_getevents.3
@@ -42,19 +42,25 @@ struct io_event {
         unsigned        PADDED(res2, __pad4);
 };
 .sp
-.BI "int io_getevents(io_context_t " ctx ",  long " nr ", struct io_event *" events "[], struct timespec *" timeout ");"
-.BI "int io_pgetevents(io_context_t " ctx ",  long " nr ", struct io_event *" events "[], struct timespec *" timeout ", sigset_t *" sigmask ");"
+.BI "int io_getevents(io_context_t " ctx ", long " nr ", struct io_event *" events "[], struct timespec *" timeout ");"
+.BI "int io_pgetevents(io_context_t " ctx ", long " nr ", struct io_event *" events "[], struct timespec *" timeout ", sigset_t *" sigmask ");"
 .fi
 .SH DESCRIPTION
-Attempts to read  up to nr events from
-the completion queue for the aio_context specified by ctx.
+Attempts to read up to
+.I nr
+events from the completion queue for the aio_context specified by
+.IR ctx .
 .SH "RETURN VALUES"
 May return
-0 if no events are available and the timeout specified
-by when has elapsed, where when == NULL specifies an infinite
+.B 0
+if no events are available and the timeout specified
+by when has elapsed, where
+.I when
+== NULL specifies an infinite
 timeout.  Note that the timeout pointed to by when is relative and
-will be updated if not NULL and the operation blocks.  Will fail
-with ENOSYS if not implemented.
+will be updated if not NULL and the operation blocks.  Will fail with
+.B ENOSYS
+if not implemented.
 .SS io_pgetevents()
 The relationship between
 .BR io_getevents ()
@@ -110,8 +116,15 @@ behaves the same as
 .SH ERRORS
 .TP
 .B EINVAL
-If ctx_id is invalid, if min_nr is out of range,
-if nr is out of range, if when is out of range.
+If
+.I ctx_id
+is invalid, if
+.I min_nr
+is out of range, if
+.I nr
+is out of range, if
+.I when
+is out of range.
 .TP
 .B EFAULT
 If any of the memory specified to is invalid.
diff --git a/man/io_prep_fsync.3 b/man/io_prep_fsync.3
index bc0c43b..d332709 100644
--- a/man/io_prep_fsync.3
+++ b/man/io_prep_fsync.3
@@ -16,7 +16,7 @@ io_prep_fsync \- Synchronize a file's complete in-core state with that on disk
 .B #include <libaio.h>
 .br
 .sp
-.BI "static inline void io_prep_fsync(struct iocb *iocb, int fd)"
+.BI "static inline void io_prep_fsync(struct iocb *" iocb ", int " fd ");"
 .sp
 struct iocb {
 	void		*data;
@@ -28,47 +28,72 @@ struct iocb {
 .sp
 .fi
 .SH DESCRIPTION
-This is an inline convenience function for setting up an iocbv for a FSYNC request.
-.br
+This is an inline convenience function for setting up an
+.I iocbv
+for a
+.B FSYNC
+request.
+.
+.PP
 The file for which
-.TP
+.nf
 .IR "iocb->aio_fildes = fd"
+.fi
 is a descriptor is set up with
 the command
-.TP
-.IR "iocb->aio_lio_opcode = IO_CMD_FSYNC:
+.nf
+.IR "iocb->aio_lio_opcode = IO_CMD_FSYNC"
+.fi
 .
 .PP
-The io_prep_fsync() function shall set up an IO_CMD_FSYNC operation
-to asynchronously force all I/O
+The
+.BR io_prep_fsync ()
+function shall set up an
+.B IO_CMD_FSYNC
+operation to asynchronously force all I/O
 operations associated with the file indicated by the file
-descriptor aio_fildes member of the iocb structure referenced by
+descriptor
+.I aio_fildes
+member of the
+.I iocb
+structure referenced by
 the iocb argument and queued at the time of the call to
-io_submit() to the synchronized I/O completion state. The function
+.BR io_submit ()
+to the synchronized I/O completion state. The function
 call shall return when the synchronization request has been
 initiated or queued to the file or device (even when the data
 cannot be synchronized immediately).

 All currently queued I/O operations shall be completed as if by a call
-to fsync(); that is, as defined for synchronized I/O file
+to
+.BR fsync (2);
+that is, as defined for synchronized I/O file
 integrity completion. If the
-operation queued by io_prep_fsync() fails, then, as for fsync(),
+operation queued by
+.BR io_prep_fsync ()
+fails, then, as for
+.BR fsync (2),
 outstanding I/O operations are not guaranteed to have
 been completed.

-If io_prep_fsync() succeeds, then it is only the I/O that was queued
-at the time of the call to io_submit() that is guaranteed to be
+If
+.BR io_prep_fsync ()
+succeeds, then it is only the I/O that was queued
+at the time of the call to
+.BR io_submit (3)
+that is guaranteed to be
 forced to the relevant completion state. The completion of
 subsequent I/O on the file descriptor is not guaranteed to be
 completed in a synchronized fashion.
 .PP
 This function returns immediately. To schedule the operation, the
 function
-.IR io_submit
+.BR io_submit (3)
 must be called.
 .PP
-Simultaneous asynchronous operations using the same iocb produce
-undefined results.
+Simultaneous asynchronous operations using the same
+.I iocb
+produce undefined results.
 .SH "RETURN VALUES"
 None.
 .SH ERRORS
diff --git a/man/io_prep_pread.3 b/man/io_prep_pread.3
index e981e41..e0756a7 100644
--- a/man/io_prep_pread.3
+++ b/man/io_prep_pread.3
@@ -19,7 +19,7 @@ io_prep_pread \- Set up asynchronous read
 .B #include <libaio.h>
 .br
 .sp
-.BI "inline void io_prep_pread(struct iocb *iocb, int fd, void *buf, size_t count, long long offset)
+.BI "inline void io_prep_pread(struct iocb *" iocb ", int " fd ", void *" buf ", size_t " count ", long long " offset ");"
 .
 .sp
 struct iocb {
@@ -31,32 +31,27 @@ struct iocb {
 };
 .fi
 .SH DESCRIPTION
-.IR io_prep_pread
+.BR io_prep_pread ()
 is an inline convenience function designed to facilitate the initialization of
 the iocb for an asynchronous read operation.

 The first
-.TP
-.IR "iocb->u.c.nbytes = count"
+.I iocb->u.c.nbytes = count
 bytes of the file for which
-.TP
-.IR "iocb->aio_fildes = fd"
+.I iocb->aio_fildes = fd
 is a descriptor are written to the buffer
 starting at
-.TP
 .IR "iocb->u.c.buf = buf" .
-.br
 Reading starts at the absolute position
-.TP
-.IR "ioc->u.c.offset = offset"
+.I ioc->u.c.offset = offset
 in the file.
 .PP
 This function returns immediately. To schedule the operation, the
 function
-.IR io_submit
+.BR io_submit (3)
 must be called.
 .PP
-Simultaneous asynchronous operations using the same iocb produce
+Simultaneous asynchronous operations using the same \fIiocb\fP produce
 undefined results.
 .SH "RETURN VALUES"
 None.
diff --git a/man/io_prep_pwrite.3 b/man/io_prep_pwrite.3
index f2837b6..b3770b4 100644
--- a/man/io_prep_pwrite.3
+++ b/man/io_prep_pwrite.3
@@ -19,8 +19,8 @@ io_prep_pwrite \- Set up iocb for asynchronous writes
 .B #include <libaio.h>
 .br
 .sp
-.BI "inline void io_prep_pwrite(struct iocb *iocb, int fd, void *buf, size_t count, long long offset)
-"
+.BI "inline void io_prep_pwrite(struct iocb *" iocb ", int " fd ", void *" buf ", size_t " count ", long long " offset ");"
+.
 .sp
 struct iocb {
 	void		*data;
@@ -31,27 +31,23 @@ struct iocb {
 };
 .fi
 .SH DESCRIPTION
-io_prep_write is a convenience function for setting up parallel writes.
+.BR io_prep_write ()
+is a convenience function for setting up parallel writes.

 The first
-.TP
 .IR "iocb->u.c.nbytes = count"
 bytes of the file for which
-.TP
 .IR "iocb->aio_fildes = fd"
 is a descriptor are written from the buffer
 starting at
-.TP
 .IR "iocb->u.c.buf = buf" .
-.br
 Writing starts at the absolute position
-.TP
 .IR "ioc->u.c.offset = offset"
 in the file.
 .PP
 This function returns immediately. To schedule the operation, the
 function
-.IR io_submit
+.BR io_submit (3)
 must be called.
 .PP
 Simultaneous asynchronous operations using the same iocb produce
diff --git a/man/io_queue_init.3 b/man/io_queue_init.3
index d8753a7..661f377 100644
--- a/man/io_queue_init.3
+++ b/man/io_queue_init.3
@@ -10,25 +10,31 @@ io_queue_init \- Initialize asynchronous io state machine
 .B #include <libaio.h>
 .br
 .sp
-.BI "int io_queue_init(int maxevents, io_context_t  *ctx );"
+.BI "int io_queue_init(int " maxevents ", io_context_t *" ctx ");"
 .sp
 .fi
 .SH DESCRIPTION
-.B io_queue_init
-Attempts to create an aio context capable of receiving at least
-.IR maxevents
+.BR io_queue_init ()
+attempts to create an aio context capable of receiving at least
+.I maxevents
 events.
-.IR ctx
+.I ctx
 must point to an aio context that already exists and must be initialized
 to
-.IR 0
+.B 0
 before the call.
-If the operation is successful, *cxtp is filled with the resulting handle.
+If the operation is successful,
+.I *cxtp
+is filled with the resulting handle.
 .SH "RETURN VALUES"
 On success,
-.B io_queue_init
-returns 0.  Otherwise, -error is return, where
-error is one of the Exxx values defined in the Errors section.
+.BR io_queue_init ()
+returns
+.BR 0 .
+Otherwise, -error is return, where
+error is one of the Exxx values defined in the
+.B ERRORS
+section.
 .SH ERRORS
 .TP
 .B EFAULT
@@ -37,7 +43,9 @@ referenced data outside of the program's accessible address space.
 .TP
 .B EINVAL
 .I maxevents
-is <= 0 or
+is <=
+.B 0
+or
 .IR ctx
 is an invalid memory location.
 .TP
@@ -46,7 +54,9 @@ Not implemented.
 .TP
 .B EAGAIN
 .IR "maxevents > max_aio_reqs"
-where max_aio_reqs is a tunable value.
+where
+.I max_aio_reqs
+is a tunable value.
 .SH "SEE ALSO"
 .BR io (3),
 .BR io_cancel (3),
diff --git a/man/io_queue_release.3 b/man/io_queue_release.3
index 392a478..7a67141 100644
--- a/man/io_queue_release.3
+++ b/man/io_queue_release.3
@@ -8,7 +8,7 @@ io_queue_release \- Release the context associated with the userspace handle
 .B #include <libaio.h>
 .br
 .sp
-.BI "int io_queue_release(io_context_t ctx)"
+.BI "int io_queue_release(io_context_t " ctx ");"
 .sp
 .SH DESCRIPTION
 .B io_queue_release
@@ -17,16 +17,21 @@ AIOs and block on completion.
 .
 .SH "RETURN VALUES"
 On success,
-.B io_queue_release
-returns 0.  Otherwise, -error is return, where
+.BR io_queue_release ()
+returns
+.BR 0 .
+Otherwise, -error is return, where
 error is one of the Exxx values defined in the Errors section.
 .SH ERRORS
 .TP
 .B EINVAL
 .I ctx
-refers to an uninitialized aio context, the iocb pointed to by
+refers to an uninitialized aio context, the
+.I iocb
+pointed to by
 .I iocbs
-contains an improperly initialized iocb,
+contains an improperly initialized
+.IR iocb .
 .TP
 .B ENOSYS
 Not implemented.
@@ -44,4 +49,3 @@ Not implemented.
 .BR io_set_callback (3),
 .BR io_submit (3),
 .BR errno (3).
-
diff --git a/man/io_queue_run.3 b/man/io_queue_run.3
index dc54acd..93e322b 100644
--- a/man/io_queue_run.3
+++ b/man/io_queue_run.3
@@ -9,17 +9,19 @@ io_queue_run \- Handle completed io requests
 .B #include <libaio.h>
 .br
 .sp
-.BI "int io_queue_run(io_context_t  ctx );"
+.BI "int io_queue_run(io_context_t " ctx ");"
 .sp
 .fi
 .SH DESCRIPTION
-.B io_queue_run
-Attempts to read all the events from
-the completion queue for the aio_context specified by ctx_id.
+.BR io_queue_run ()
+attempts to read all the events from
+the completion queue for the aio_context specified by
+.IR ctx_id .
 .SH "RETURN VALUES"
 May return
-0 if no events are available.
-Will fail with -ENOSYS if not implemented.
+.B 0
+if no events are available.
+Will fail with -\fBENOSYS\fP if not implemented.
 .SH ERRORS
 .TP
 .B EFAULT
@@ -28,7 +30,9 @@ referenced data outside of the program's accessible address space.
 .TP
 .B EINVAL
 .I ctx
-refers to an uninitialized aio context, the iocb pointed to by
+refers to an uninitialized aio context, the
+.I iocb
+pointed to by
 .I iocbs
 contains an improperly initialized iocb.
 .TP
diff --git a/man/io_queue_wait.3 b/man/io_queue_wait.3
index 356c3b2..ad5e7f4 100644
--- a/man/io_queue_wait.3
+++ b/man/io_queue_wait.3
@@ -9,22 +9,27 @@ io_queue_wait \- Wait for io requests to complete
 .B #include <libaio.h>
 .br
 .sp
-.BI "int io_queue_wait(io_context_t ctx, const struct timespec *timeout);"
+.BI "int io_queue_wait(io_context_t " ctx ", const struct timespec *" timeout ");"
 .fi
 .SH DESCRIPTION
-Attempts to read an event from
-the completion queue for the aio_context specified by ctx_id.
+.BR io_queue_wait ()
+attempts to read an event from
+the completion queue for the aio_context specified by
+.IR ctx_id .
 .SH "RETURN VALUES"
 May return
-0 if no events are available and the timeout specified
+.B 0
+if no events are available and the timeout specified
 by when has elapsed, where when == NULL specifies an infinite
-timeout.  Note that the timeout pointed to by when is relative and
+\fItimeout\fP.  Note that the \fItimeout\fP pointed to by when is relative and
 will be updated if not NULL and the operation blocks.  Will fail
-with -ENOSYS if not implemented.
+with -\fBENOSYS\fP if not implemented.
 .SH "RETURN VALUES"
 On success,
-.B io_queue_wait
-returns 0.  Otherwise, -error is return, where
+.BR io_queue_wait ()
+returns
+.BR 0 .
+Otherwise, -error is return, where
 error is one of the Exxx values defined in the Errors section.
 .SH ERRORS
 .TP
@@ -34,7 +39,9 @@ referenced data outside of the program's accessible address space.
 .TP
 .B EINVAL
 .I ctx
-refers to an uninitialized aio context, the iocb pointed to by
+refers to an uninitialized aio context, the
+.I iocb
+pointed to by
 .I iocbs
 contains an improperly initialized iocb.
 .TP
diff --git a/man/io_set_callback.3 b/man/io_set_callback.3
index 25b9a7f..855f4b9 100644
--- a/man/io_set_callback.3
+++ b/man/io_set_callback.3
@@ -10,7 +10,7 @@ io_set_callback \- Set up io completion callback function
 .B #include <libaio.h>
 .br
 .sp
-.BI "static inline void io_set_callback(struct iocb *iocb, io_callback_t cb)"
+.BI "static inline void io_set_callback(struct iocb *" iocb ", io_callback_t " cb ");"
 .sp
 struct iocb {
 	void		*data;
@@ -25,7 +25,8 @@ typedef void (*io_callback_t)(io_context_t ctx, struct iocb *iocb, long res, lon
 .fi
 .SH DESCRIPTION
 The callback is not done if the caller uses raw events from
-io_getevents, only with the library helpers.
+.BR io_getevents (3),
+only with the library helpers.
 .SH "RETURN VALUES"
 None.
 .SH ERRORS
diff --git a/man/io_submit.3 b/man/io_submit.3
index 01c25cd..a195653 100644
--- a/man/io_submit.3
+++ b/man/io_submit.3
@@ -32,21 +32,21 @@ struct iocb {
 };
 .fi
 .SH DESCRIPTION
-.B io_submit
+.BR io_submit ()
 submits
 .I nr
 iocbs for processing for a given io context ctx.

 The
-.IR "io_submit"
+.BR io_submit ()
 function can be used to enqueue an arbitrary
 number of read and write requests at one time.  The requests can all be
 meant for the same file, all for different files or every solution in
 between.

-.IR "io_submit"
+.BR io_submit ()
 gets the
-.IR "nr"
+.I nr
 requests from the array pointed to
 by
 .IR "iocbs" .
@@ -75,10 +75,10 @@ in which case this element of
 .IR "iocbs"
 is simply ignored.  This
 ``operation'' is useful in situations where one has a fixed array of
-.IR "struct iocb"
+.B struct iocb
 elements from which only a few need to be handled at
 a time.  Another situation is where the
-.IR "io_submit"
+.BR io_submit (3)
 call was
 canceled before all requests are processed  and the remaining requests have to be reissued.

@@ -86,15 +86,15 @@ The other members of each element of the array pointed to by
 .IR "iocbs"
 must have values suitable for the operation as described in
 the documentation for
-.IR "io_prep_pread"
+.BR io_prep_pread (3)
 and
-.IR "io_prep_pwrite"
+.BR io_prep_pwrite (3)
 above.

 The function returns immediately after
 having enqueued all the requests.
 On success,
-.B io_submit
+.BR io_submit ()
 returns the number of iocbs submitted successfully.  Otherwise, -error is return, where
 error is one of the Exxx values defined in the Errors section.
 .PP
@@ -115,10 +115,14 @@ refers to an uninitialized aio context, the iocb pointed to by
 contains an improperly initialized iocb,
 .TP
 .B EBADF
-The iocb contains a file descriptor that does not exist.
+The
+.I iocb
+contains a file descriptor that does not exist.
 .TP
 .B EINVAL
-The file specified in the iocb does not support the given io operation.
+The file specified in the
+.I iocb
+does not support the given io operation.
 .SH "SEE ALSO"
 .BR io (3),
 .BR io_cancel (3),
--
2.26.0.292.g33ef6b2f38


code:
From 96fe0e8a3efb8bb058852a46c0273125dd54ba49 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 20 Jul 2019 21:18:12 +0200
Subject: [PATCH libaio 14/28] man: Fold short lines

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 man/io_prep_fsync.3 | 3 +--
 man/io_submit.3     | 9 +++------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/man/io_prep_fsync.3 b/man/io_prep_fsync.3
index d332709..419dfeb 100644
--- a/man/io_prep_fsync.3
+++ b/man/io_prep_fsync.3
@@ -39,8 +39,7 @@ The file for which
 .nf
 .IR "iocb->aio_fildes = fd"
 .fi
-is a descriptor is set up with
-the command
+is a descriptor is set up with the command
 .nf
 .IR "iocb->aio_lio_opcode = IO_CMD_FSYNC"
 .fi
diff --git a/man/io_submit.3 b/man/io_submit.3
index a195653..c0791ed 100644
--- a/man/io_submit.3
+++ b/man/io_submit.3
@@ -47,18 +47,15 @@ between.
 .BR io_submit ()
 gets the
 .I nr
-requests from the array pointed to
-by
+requests from the array pointed to by
 .IR "iocbs" .
 The operation to be performed is determined by the
 .IR "aio_lio_opcode"
 member in each element of
 .IR "iocbs" .
-If this
-field is
+If this field is
 .B "IO_CMD_PREAD"
-a read operation is enqueued, similar to a call
-of
+a read operation is enqueued, similar to a call of
 .IR "io_prep_pread"
 for this element of the array (except that the way
 the termination is signalled is different, as we will see below).  If
--
2.26.0.292.g33ef6b2f38

repo_name: dustdfg/dragora

license: mit


code:
From 6f0b6fb5bb3ac118cb56848e52d40ff7e1ece3d1 Mon Sep 17 00:00:00 2001
From: Stephan Springl <springl-libaio@bfw-online.de>
Date: Sat, 20 Jul 2019 21:18:13 +0200
Subject: [PATCH libaio 15/28] man: Escape verbatim \n in order to make it
 through roff

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 man/io.3 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/man/io.3 b/man/io.3
index f40da41..bfa9836 100644
--- a/man/io.3
+++ b/man/io.3
@@ -174,11 +174,11 @@ static const char *srcname = NULL;
 static void io_error(const char *func, int rc)
 {
     if (rc == -ENOSYS)
-	fprintf(stderr, "AIO not in this kernel\n");
+	fprintf(stderr, "AIO not in this kernel\\n");
     else if (rc < 0 && -rc < sys_nerr)
-	fprintf(stderr, "%s: %s\n", func, sys_errlist[-rc]);
+	fprintf(stderr, "%s: %s\\n", func, sys_errlist[-rc]);
     else
-	fprintf(stderr, "%s: error %d\n", func, rc);
+	fprintf(stderr, "%s: error %d\\n", func, rc);

     if (dstfd > 0)
 	close(dstfd);
@@ -197,7 +197,7 @@ static void wr_done(io_context_t ctx, struct iocb *iocb, long res, long res2)
 	io_error("aio write", res2);
     }
     if (res != iocb->u.c.nbytes) {
-	fprintf(stderr, "write missed bytes expect %d got %d\n", iocb->u.c.nbytes, res2);
+	fprintf(stderr, "write missed bytes expect %d got %d\\n", iocb->u.c.nbytes, res2);
 	exit(1);
     }
     --tocopy;
@@ -223,7 +223,7 @@ static void rd_done(io_context_t ctx, struct iocb *iocb, long res, long res2)
     if (res2 != 0)
 	io_error("aio read", res2);
     if (res != iosize) {
-	fprintf(stderr, "read missing bytes expect %d got %d\n", iocb->u.c.nbytes, res);
+	fprintf(stderr, "read missing bytes expect %d got %d\\n", iocb->u.c.nbytes, res);
 	exit(1);
     }

@@ -283,7 +283,7 @@ int main(int argc, char *const *argv)
 		char *buf = (char *) malloc(iosize);

 		if (NULL == buf || NULL == io) {
-		    fprintf(stderr, "out of memory\n");
+		    fprintf(stderr, "out of memory\\n");
 		    exit(1);
 		}

--
2.26.0.292.g33ef6b2f38


code:
From e2175569737a2905d3c7a6e6ff664f0febcf5a28 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 20 Jul 2019 21:18:14 +0200
Subject: [PATCH libaio 16/28] Use ctx consistently for io_context_t instead of
 ctx_id

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 man/io_cancel.3     | 2 +-
 man/io_getevents.3  | 8 ++++----
 man/io_queue_run.3  | 2 +-
 man/io_queue_wait.3 | 2 +-
 man/io_submit.3     | 2 +-
 src/compat-0_1.c    | 4 ++--
 src/libaio.h        | 4 ++--
 src/vsys_def.h      | 2 +-
 8 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/man/io_cancel.3 b/man/io_cancel.3
index 3ca629b..8c6910e 100644
--- a/man/io_cancel.3
+++ b/man/io_cancel.3
@@ -46,7 +46,7 @@ If any of the data structures pointed to are invalid.
 If
 .I aio_context
 specified by
-.I ctx_id
+.I ctx
 is invalid.
 .TP
 .B EAGAIN
diff --git a/man/io_getevents.3 b/man/io_getevents.3
index 6fbcc24..6ff686d 100644
--- a/man/io_getevents.3
+++ b/man/io_getevents.3
@@ -1,7 +1,7 @@
 .\"/* io_getevents:
 .\" *      Attempts to read at least min_nr events and up to nr events from
-.\" *      the completion queue for the aio_context specified by ctx_id.  May
-.\" *      fail with -EINVAL if ctx_id is invalid, if min_nr is out of range,
+.\" *      the completion queue for the aio_context specified by ctx.  May
+.\" *      fail with -EINVAL if ctx is invalid, if min_nr is out of range,
 .\" *      if nr is out of range, if when is out of range.  May fail with
 .\" *      -EFAULT if any of the memory specified to is invalid.  May return
 .\" *      0 or < min_nr if no events are available and the timeout specified
@@ -10,7 +10,7 @@
 .\" *      will be updated if not NULL and the operation blocks.  Will fail
 .\" *      with -ENOSYS if not implemented.
 .\" */
-.\"asmlinkage long sys_io_getevents(io_context_t ctx_id,
+.\"asmlinkage long sys_io_getevents(io_context_t ctx,
 .\"                                 long min_nr,
 .\"                                 long nr,
 .\"                                 struct io_event *events,
@@ -117,7 +117,7 @@ behaves the same as
 .TP
 .B EINVAL
 If
-.I ctx_id
+.I ctx
 is invalid, if
 .I min_nr
 is out of range, if
diff --git a/man/io_queue_run.3 b/man/io_queue_run.3
index 93e322b..2bb9701 100644
--- a/man/io_queue_run.3
+++ b/man/io_queue_run.3
@@ -16,7 +16,7 @@ io_queue_run \- Handle completed io requests
 .BR io_queue_run ()
 attempts to read all the events from
 the completion queue for the aio_context specified by
-.IR ctx_id .
+.IR ctx .
 .SH "RETURN VALUES"
 May return
 .B 0
diff --git a/man/io_queue_wait.3 b/man/io_queue_wait.3
index ad5e7f4..1cf4f0b 100644
--- a/man/io_queue_wait.3
+++ b/man/io_queue_wait.3
@@ -15,7 +15,7 @@ io_queue_wait \- Wait for io requests to complete
 .BR io_queue_wait ()
 attempts to read an event from
 the completion queue for the aio_context specified by
-.IR ctx_id .
+.IR ctx .
 .SH "RETURN VALUES"
 May return
 .B 0
diff --git a/man/io_submit.3 b/man/io_submit.3
index c0791ed..c15134f 100644
--- a/man/io_submit.3
+++ b/man/io_submit.3
@@ -1,7 +1,7 @@
 .\"/* sys_io_submit:
 .\" *      Queue the nr iocbs pointed to by iocbpp for processing.  Returns
 .\" *      the number of iocbs queued.  May return -EINVAL if the aio_context
-.\" *      specified by ctx_id is invalid, if nr is < 0, if the iocb at
+.\" *      specified by ctx is invalid, if nr is < 0, if the iocb at
 .\" *      *iocbpp[0] is not properly initialized, if the operation specified
 .\" *      is invalid for the file descriptor in the iocb.  May fail with
 .\" *      -EFAULT if any of the data structures point to invalid data.  May
diff --git a/src/compat-0_1.c b/src/compat-0_1.c
index 136396f..722e107 100644
--- a/src/compat-0_1.c
+++ b/src/compat-0_1.c
@@ -49,14 +49,14 @@ int compat0_1_io_queue_wait(io_context_t ctx, struct timespec *when)

 /* ABI change.  Provide backwards compatibility for this one. */
 SYMVER(compat0_1_io_getevents, io_getevents, 0.1);
-int compat0_1_io_getevents(io_context_t ctx_id, long nr,
+int compat0_1_io_getevents(io_context_t ctx, long nr,
 		       struct io_event *events,
 		       const struct timespec *const_timeout)
 {
 	struct timespec timeout;
 	if (const_timeout)
 		timeout = *const_timeout;
-	return io_getevents(ctx_id, 1, nr, events,
+	return io_getevents(ctx, 1, nr, events,
 			const_timeout ? &timeout : NULL);
 }

diff --git a/src/libaio.h b/src/libaio.h
index 2bc24e0..8b33382 100644
--- a/src/libaio.h
+++ b/src/libaio.h
@@ -162,8 +162,8 @@ extern int io_setup(int maxevents, io_context_t *ctxp);
 extern int io_destroy(io_context_t ctx);
 extern int io_submit(io_context_t ctx, long nr, struct iocb *ios[]);
 extern int io_cancel(io_context_t ctx, struct iocb *iocb, struct io_event *evt);
-extern int io_getevents(io_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout);
-extern int io_pgetevents(io_context_t ctx_id, long min_nr, long nr,
+extern int io_getevents(io_context_t ctx, long min_nr, long nr, struct io_event *events, struct timespec *timeout);
+extern int io_pgetevents(io_context_t ctx, long min_nr, long nr,
 		struct io_event *events, struct timespec *timeout,
 		sigset_t *sigmask);

diff --git a/src/vsys_def.h b/src/vsys_def.h
index 13d032e..dd711dc 100644
--- a/src/vsys_def.h
+++ b/src/vsys_def.h
@@ -20,5 +20,5 @@ extern int vsys_io_destroy(io_context_t ctx);
 extern int vsys_io_submit(io_context_t ctx, long nr, struct iocb *iocbs[]);
 extern int vsys_io_cancel(io_context_t ctx, struct iocb *iocb);
 extern int vsys_io_wait(io_context_t ctx, struct iocb *iocb, const struct timespec *when);
-extern int vsys_io_getevents(io_context_t ctx_id, long nr, struct io_event *events, const struct timespec *timeout);
+extern int vsys_io_getevents(io_context_t ctx, long nr, struct io_event *events, const struct timespec *timeout);

--
2.26.0.292.g33ef6b2f38


code:
From b9e17f6afdc4d0e81b1598aecea7b80d0c54b13a Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 20 Jul 2019 21:20:58 +0200
Subject: [PATCH libaio 17/28] harness: Use destination strncpy() expression
 for sizeof() argument
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Even though this is the same size, as the sizeof() is derived from the
source expression, recent gcc versions will emit a warning, which is
turned into an error by -Werror:

  error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression
    as the source; did you mean to use the size of the destination?
    [-Werror=sizeof-pointer-memaccess]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/cases/19.t | 2 +-
 harness/cases/21.t | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/harness/cases/19.t b/harness/cases/19.t
index 4989510..5c3e0d6 100644
--- a/harness/cases/19.t
+++ b/harness/cases/19.t
@@ -41,7 +41,7 @@ open_temp_file(void)
 	int fd;
 	char template[sizeof(TEMPLATE)];

-	strncpy(template, TEMPLATE, sizeof(TEMPLATE));
+	strncpy(template, TEMPLATE, sizeof(template));
 	fd = mkostemp(template, O_DIRECT);
 	if (fd < 0) {
 		perror("mkstemp");
diff --git a/harness/cases/21.t b/harness/cases/21.t
index 441eaa8..fe33a9d 100644
--- a/harness/cases/21.t
+++ b/harness/cases/21.t
@@ -43,7 +43,7 @@ open_temp_file()
 	int fd;
 	char temp_file[sizeof(TEMPLATE)];

-	strncpy(temp_file, TEMPLATE, sizeof(TEMPLATE));
+	strncpy(temp_file, TEMPLATE, sizeof(temp_file));
 	fd = mkstemp(temp_file);
 	if (fd < 0) {
 		perror("mkstemp");
--
2.26.0.292.g33ef6b2f38


code:
From fca5217d524635bed70532aa68baff065d22d790 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 20 Jul 2019 21:20:59 +0200
Subject: [PATCH libaio 18/28] harness: Use run-time _SC_PAGE_SIZE instead of
 build-time PAGESIZE

The getconf(1) command is inherently not cross-compilation friendly.
In addition PAGESIZE depends on the specific system, even within a
specific arch, so using a hard-coded value is never safe.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/Makefile   |  2 +-
 harness/cases/18.t | 34 ++++++++++++++++++++++++----------
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/harness/Makefile b/harness/Makefile
index 87b33f6..5cc2b25 100644
--- a/harness/Makefile
+++ b/harness/Makefile
@@ -6,7 +6,7 @@ PROGS:=$(PARTPROGS) $(EXTRAPROGS)
 HARNESS_SRCS:=main.c
 # io_queue.c

-CFLAGS+=-Wall -Werror -I../src -g -O2 -DPAGE_SIZE=$(shell getconf PAGESIZE)
+CFLAGS+=-Wall -Werror -I../src -g -O2
 #-lpthread -lrt

 # Change this on the build line to run tests against the installed libraries:
diff --git a/harness/cases/18.t b/harness/cases/18.t
index 5587ceb..daa1d26 100644
--- a/harness/cases/18.t
+++ b/harness/cases/18.t
@@ -40,11 +40,17 @@

 #define THREADS_NUM 100

+static size_t page_size;
+
 void
 aio_worker(void *ptr)
 {
-	int i, j, fd;
-	char buffer[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
+	int i, j, fd, ret;
+	char *buffer = NULL;
+
+	ret = posix_memalign((void **)&buffer, page_size, page_size);
+	assert(ret == 0);
+	assert(buffer != NULL);

 	fd = open(FILENAME, O_DIRECT|O_RDONLY);
 	assert(fd >= 0);
@@ -55,19 +61,19 @@ aio_worker(void *ptr)
 		struct iocb *cbs[1];

 		assert(!io_queue_init(1, &ctx));
-		io_prep_pread(&cb, fd, buffer, PAGE_SIZE, 0);
+		io_prep_pread(&cb, fd, buffer, page_size, 0);
 		cbs[0] = &cb;

-		memset(buffer, '0', PAGE_SIZE);
+		memset(buffer, '0', page_size);
 		assert(io_submit(ctx, 1, &cbs[0]) == 1);
 		// wait random time (0-500ms) ?

 		io_destroy(ctx);
-		memset(buffer, DESTROY_PATTERN, PAGE_SIZE);
+		memset(buffer, DESTROY_PATTERN, page_size);
 		// wait random for (0-500ms) ?

 		// check it is still DESTROY_PATTERN
-		for (j = 0; j < PAGE_SIZE; j++) {
+		for (j = 0; j < page_size; j++) {
 			if (buffer[j] != DESTROY_PATTERN) {
 				fprintf(stderr,
 					"Buffer has unexpected character: %c\n",
@@ -77,6 +83,7 @@ aio_worker(void *ptr)
 		}
 	}

+	free(buffer);
 	close(fd);
 }

@@ -84,15 +91,22 @@ int
 test_main(void)
 {
 	int i, fd, ret;
-	char buffer[PAGE_SIZE];
+	char *buffer = NULL;
 	pthread_t threads[THREADS_NUM];

+	page_size = sysconf(_SC_PAGESIZE);
+	assert(page_size >= 1);
+
+	ret = posix_memalign((void **)&buffer, page_size, page_size);
+	assert(ret == 0);
+	assert(buffer != NULL);
+
 	fd = open(FILENAME, O_CREAT|O_TRUNC|O_APPEND|O_RDWR, S_IRUSR|S_IWUSR);
 	assert(fd != -1);

-	memset(buffer, FILEPATTERN, PAGE_SIZE);
-	ret = write(fd, buffer, PAGE_SIZE);
-	assert(ret == PAGE_SIZE);
+	memset(buffer, FILEPATTERN, page_size);
+	ret = write(fd, buffer, page_size);
+	assert(ret == page_size);
 	close(fd);

 	for (i = 0; i < THREADS_NUM; i++) {
--
2.26.0.292.g33ef6b2f38


code:
From f322f467c3cd2ac4d8d08a19bd281eabb65433b1 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 20 Jul 2019 21:21:00 +0200
Subject: [PATCH libaio 19/28] harness: Make RISC-V use SYS_eventfd2 instead of
 unavailable SYS_eventfd

This is a recent architecture and as such does not provide legacy
support for SYS_eventfd. Declare that we need to use the new syscall.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/cases/16.t | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/harness/cases/16.t b/harness/cases/16.t
index 5a546ff..b36bbd2 100644
--- a/harness/cases/16.t
+++ b/harness/cases/16.t
@@ -18,12 +18,12 @@
 #define SYS_eventfd 318
 #elif defined(__alpha__)
 #define SYS_eventfd 478
-#elif defined(__aarch64__)
-/* arm64 does not implement eventfd, only eventfd2 */
+#elif defined(__aarch64__) || defined(__riscv)
+/* arm64 and riscv do not implement eventfd, only eventfd2 */
 #define USE_EVENTFD2
 #ifndef SYS_eventfd2
 #define SYS_eventfd2 19
-#endif /* __aarch64__ */
+#endif /* __aarch64__ || __riscv */
 #else
 #error define SYS_eventfd for your arch!
 #endif
--
2.26.0.292.g33ef6b2f38


code:
From abcb9eeacc2f12c3d77b66c274ace9bffecf68e3 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Tue, 23 Jul 2019 02:48:43 +0200
Subject: [PATCH libaio 20/28] harness: Make the test exit with a code matching
 the pass/fail state

This way we can use the exit code to check whether the tests passed or
failed, and fail the package build.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/runtests.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/harness/runtests.sh b/harness/runtests.sh
index 717c72a..ef269a7 100755
--- a/harness/runtests.sh
+++ b/harness/runtests.sh
@@ -17,3 +17,5 @@ done

 echo "Pass: $passes  Fail: $fails"
 echo "Test run complete at" `date`
+
+exit $fails
--
2.26.0.292.g33ef6b2f38


code:
From 90ec55ab2675bc2b6b4d256f78a3db26adf75900 Mon Sep 17 00:00:00 2001
From: Jeff Moyer <jmoyer@redhat.com>
Date: Mon, 29 Jul 2019 13:16:18 -0400
Subject: [PATCH libaio 21/28] harness: add support for skipping tests

Skipped tests will not cause the test harness to return failure.  An
exit status of "3" was chosen for skipped tests.  This doesn't
conflict with any of the current tests.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/main.c      | 20 ++++++++++++++++----
 harness/runtests.sh | 14 ++++++++++++--
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/harness/main.c b/harness/main.c
index 9ecd5da..82e9c69 100644
--- a/harness/main.c
+++ b/harness/main.c
@@ -26,15 +26,27 @@ char test_name[] = TEST_NAME;
 int main(void)
 {
 	int res;
+	const char *test_result;

 #if defined(SETUP)
 	SETUP;
 #endif

 	res = test_main();
-	printf("test %s completed %s.\n", test_name,
-		res ? "FAILED" : "PASSED"
-		);
+	switch(res) {
+	case 0:
+		test_result = "PASSED";
+		break;
+	case 3:
+		test_result = "SKIPPED";
+		break;
+	default:
+		test_result = "FAILED";
+		res = 1;
+		break;
+	}
+
+	printf("test %s completed %s.\n", test_name, test_result);
 	fflush(stdout);
-	return res ? 1 : 0;
+	return res;
 }
diff --git a/harness/runtests.sh b/harness/runtests.sh
index ef269a7..e9ceec8 100755
--- a/harness/runtests.sh
+++ b/harness/runtests.sh
@@ -2,6 +2,7 @@

 passes=0
 fails=0
+skips=0

 echo "Test run starting at" `date`

@@ -11,11 +12,20 @@ while [ $# -ge 1 ] ; do
 	echo "Starting $this_test"
 	$this_test 2>&1
 	res=$?
-	if [ $res -eq 0 ] ; then str="" ; passes=$[passes + 1] ; else str=" -- FAILED" ; fails=$[fails + 1] ; fi
+	if [ $res -eq 0 ]; then
+		str="";
+		passes=$((passes + 1));
+	elif [ $res -eq 3 ]; then
+		str=" -- SKIPPED";
+		skips=$((skips + 1));
+	else
+		str=" -- FAILED"
+		fails=$((fails + 1));
+	fi
 	echo "Completed $this_test with $res$str".
 done

-echo "Pass: $passes  Fail: $fails"
+echo "Pass: $passes  Fail: $fails  Skip: $skips"
 echo "Test run complete at" `date`

 exit $fails
--
2.26.0.292.g33ef6b2f38


code:
From ac60a850d5ce22ae21e3746f72a9ebb2623d17f8 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 20 Jul 2019 21:21:01 +0200
Subject: [PATCH libaio 22/28] harness: Add fallback code for filesystems not
 supporting O_DIRECT

When running the harness on a filesystem such as a tmpfs, which do not
support O_DIRECT, fallback to calls without the flag.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
[JEM: change from duplicating the open call to using F_SETFL]
[JEM: 18 and 21 require O_DIRECT-skip if not present]
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/cases/17.t | 11 +++++++++--
 harness/cases/18.t |  2 ++
 harness/cases/19.t | 10 ++++++++--
 harness/cases/21.t |  5 ++++-
 4 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/harness/cases/17.t b/harness/cases/17.t
index 38ada4d..b4b6660 100644
--- a/harness/cases/17.t
+++ b/harness/cases/17.t
@@ -119,7 +119,7 @@ void prune(io_context_t io_ctx, int max_ios, int getevents_type)

 void run_test(int max_ios, int getevents_type)
 {
-	int fd, ret;
+	int fd, ret, flags;
 	long i, to_submit;
 	struct iocb **iocb_sub;
 	io_context_t io_ctx;
@@ -137,9 +137,16 @@ void run_test(int max_ios, int getevents_type)
 	events = calloc(max_ios, sizeof(*events));

 	unlink(filename);
-	fd = open(filename, O_CREAT | O_RDWR | O_DIRECT, 0644);
+	fd = open(filename, O_CREAT | O_RDWR, 0644);
 	assert(fd >= 0);

+	/*
+	 * Use O_DIRECT if it's available.  If it's not, the test code
+	 * will still operate correctly, just potentially slower.
+	 */
+	flags = fcntl(fd, F_GETFL, 0);
+	fcntl(fd, F_SETFL, flags | O_DIRECT);
+
 	ret = ftruncate(fd, max_ios * io_size);
 	assert(!ret);

diff --git a/harness/cases/18.t b/harness/cases/18.t
index daa1d26..e8dbcd1 100644
--- a/harness/cases/18.t
+++ b/harness/cases/18.t
@@ -53,6 +53,8 @@ aio_worker(void *ptr)
 	assert(buffer != NULL);

 	fd = open(FILENAME, O_DIRECT|O_RDONLY);
+	if (fd < 0 && errno == EINVAL)
+		exit(3); /* skip this test, O_DIRECT is unavailable */
 	assert(fd >= 0);

 	for (i = 0; i < 1000; i++) {
diff --git a/harness/cases/19.t b/harness/cases/19.t
index 5c3e0d6..ba1c620 100644
--- a/harness/cases/19.t
+++ b/harness/cases/19.t
@@ -38,15 +38,21 @@ struct aio_ring {
 int
 open_temp_file(void)
 {
-	int fd;
+	int fd, flags;
 	char template[sizeof(TEMPLATE)];

 	strncpy(template, TEMPLATE, sizeof(template));
-	fd = mkostemp(template, O_DIRECT);
+	fd = mkstemp(template);
 	if (fd < 0) {
 		perror("mkstemp");
 		exit(1);
 	}
+	/*
+	 * O_DIRECT is desirable, but not required for this test.
+	 */
+	flags = fcntl(F_GETFL, 0);
+	fcntl(F_SETFL, flags | O_DIRECT);
+
 	unlink(template);
 	return fd;
 }
diff --git a/harness/cases/21.t b/harness/cases/21.t
index fe33a9d..ba988ed 100644
--- a/harness/cases/21.t
+++ b/harness/cases/21.t
@@ -92,7 +92,10 @@ test_main()
 	 */
 	flags = fcntl(fd, F_GETFL);
 	ret = fcntl(fd, F_SETFL, flags | O_DIRECT);
-	if (ret != 0) {
+	if (ret < 0) {
+		/* SKIP this test if O_DIRECT is not available on this fs */
+		if (errno == EINVAL)
+			return 3;
 		perror("fcntl");
 		return 1;
 	}
--
2.26.0.292.g33ef6b2f38


code:
From b7e04d72bda89f22ce013030358e6743417f7fea Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 20 Jul 2019 21:21:02 +0200
Subject: [PATCH libaio 23/28] harness: Handle -ENOTSUP from io_submit() with
 RWF_NOWAIT

On filesystems such as tmpfs the syscall might return -ENOTSUP instead
of EINVAL when it does not support the RWF_NOWAIT flag.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
[JEM: skip the test instead of returning success]
[JEM: make the error message differentiate between kernel and fs support]
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/cases/21.t | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/harness/cases/21.t b/harness/cases/21.t
index ba988ed..4164c02 100644
--- a/harness/cases/21.t
+++ b/harness/cases/21.t
@@ -108,13 +108,15 @@ test_main()
 	ret = io_submit(ctx, 1, &iocbp);

 	/*
-	 * io_submit will return -EINVAL if RWF_NOWAIT is not supported.
+	 * io_submit will return -EINVAL if RWF_NOWAIT is not supported by
+	 * the kernel, and EOPNOTSUPP if it's not supported by the fs.
 	 */
 	if (ret != 1) {
-		if (ret == -EINVAL) {
-			fprintf(stderr, "RWF_NOWAIT not supported by kernel.\n");
-			/* just return success */
-			return 0;
+		if (ret == -EINVAL || ret == -ENOTSUP) {
+			fprintf(stderr, "RWF_NOWAIT not supported by %s.\n",
+				ret == -EINVAL ? "kernel" : "file system");
+			/* skip this test */
+			return 3;
 		}
 		errno = -ret;
 		perror("io_submit");
--
2.26.0.292.g33ef6b2f38


code:
From 79826d55b06a50ef1be2b723fe35a1e534cfbbaa Mon Sep 17 00:00:00 2001
From: Jeff Moyer <jmoyer@redhat.com>
Date: Mon, 29 Jul 2019 14:25:01 -0400
Subject: [PATCH libaio 24/28] harness: skip 22.p if async_poll isn't supported

Use the new skip error code instead of failing the test.  Also
add in a Local variables: section for emacs.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/cases/22.t | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/harness/cases/22.t b/harness/cases/22.t
index c7428a8..b13024e 100644
--- a/harness/cases/22.t
+++ b/harness/cases/22.t
@@ -83,6 +83,9 @@ int test_main(void)
 		io_prep_poll(&iocb, pipe1[0], POLLIN);
 		ret = io_submit(ctx, 1, iocbs);
 		if (ret != 1) {
+			/* if poll isn't supported, skip the test */
+			if (ret == -EINVAL)
+				return 3;
 			printf("child: io_submit failed\n");
 			return 1;
 		}
@@ -120,7 +123,10 @@ int test_main(void)

 		ret = io_submit(ctx, 1, iocbs);
 		if (ret != 1) {
-			printf("parent: io_submit failed\n");
+			/* if poll isn't supported, skip the test */
+			if (ret == -EINVAL)
+				return 3;
+			printf("parent: io_submit failed with %d\n", ret);
 			return 1;
 		}

@@ -147,3 +153,9 @@ int test_main(void)
 		return 0;
 	}
 }
+/*
+ * Local variables:
+ *  mode: c
+ *  c-basic-offset: 8
+ * End:
+ */
--
2.26.0.292.g33ef6b2f38


code:
From d7f5065448efb49b2a26e728ff735e12ea05b62e Mon Sep 17 00:00:00 2001
From: Jeff Moyer <jmoyer@redhat.com>
Date: Tue, 13 Aug 2019 15:30:05 -0400
Subject: [PATCH libaio 25/28] harness: fix read into PROT_WRITE mmap test

This test has been broken forever.  Fix it up to perform an
aio_read using the result of a regular read as the expected
return code.

Reported-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/cases/5.t | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/harness/cases/5.t b/harness/cases/5.t
index 2b4b4bb..7d67562 100644
--- a/harness/cases/5.t
+++ b/harness/cases/5.t
@@ -40,14 +40,14 @@ int test_main(void)
 	buf = mmap(0, page_size, PROT_WRITE, MAP_SHARED, rwfd, 0);
 	assert(buf != (char *)-1);

-	status |= attempt_rw(rwfd, buf, SIZE,  0,  READ, SIZE);
-
 	/* Whether PROT_WRITE is readable is arch-dependent.  So compare
 	 * against read result. */
 	res = read(rwfd, buf, SIZE);
 	if (res < 0)
 		res = -errno;
-	status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, res);
+	status |= attempt_rw(rwfd, buf, SIZE,  0,  READ, res);
+
+	status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, SIZE);

 	return status;
 }
--
2.26.0.292.g33ef6b2f38


code:
From 711c0381798c85f3e25ea0ab503b24857850a762 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Wed, 14 Aug 2019 04:42:42 +0200
Subject: [PATCH libaio 26/28] harness: Fix PROT_WRITE mmap check

This partially reverts commit d7f5065448efb49b2a26e728ff735e12ea05b62e.

The actual problem in the original code was that read() was being used
to assert whether the buffer was readable, but the kernel was instead
reading from the file descriptor and then writing into the buffer, so
no EFAULT was being generated (on architectures that do so).

We needed to use a write() so that the kernel would read from the
buffer.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/cases/5.t | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/harness/cases/5.t b/harness/cases/5.t
index 7d67562..b0a7c56 100644
--- a/harness/cases/5.t
+++ b/harness/cases/5.t
@@ -41,13 +41,12 @@ int test_main(void)
 	assert(buf != (char *)-1);

 	/* Whether PROT_WRITE is readable is arch-dependent.  So compare
-	 * against read result. */
-	res = read(rwfd, buf, SIZE);
+	 * against write() result (to make the kernel read from buf). */
+	res = write(rwfd, buf, SIZE);
 	if (res < 0)
 		res = -errno;
-	status |= attempt_rw(rwfd, buf, SIZE,  0,  READ, res);
-
-	status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, SIZE);
+	status |= attempt_rw(rwfd, buf, SIZE,  0,  READ, SIZE);
+	status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, res);

 	return status;
 }
--
2.26.0.292.g33ef6b2f38


code:
From 6cd92a8216afcd1d3f6ff90cc150ba150800b11d Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Wed, 21 Aug 2019 05:29:50 +0200
Subject: [PATCH libaio 27/28] harness: Print better error messages on error
 conditions in 22.t

These should help diagnose problems when dealing with error failures.
In particular this helped distinguish the problem with io_pgetevents()
not being implemented and it failing due to the sigset_t layout bug.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
[JEM: fix up 80 columns violations]
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/cases/22.t | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/harness/cases/22.t b/harness/cases/22.t
index b13024e..c47140d 100644
--- a/harness/cases/22.t
+++ b/harness/cases/22.t
@@ -76,7 +76,7 @@ int test_main(void)

 		ret = io_setup(1, &ctx);
 		if (ret) {
-			printf("child: io_setup failed\n");
+			printf("child: io_setup failed: %s\n", strerror(-ret));
 			return 1;
 		}

@@ -86,7 +86,7 @@ int test_main(void)
 			/* if poll isn't supported, skip the test */
 			if (ret == -EINVAL)
 				return 3;
-			printf("child: io_submit failed\n");
+			printf("child: io_submit failed: %s\n", strerror(-ret));
 			return 1;
 		}

@@ -99,7 +99,8 @@ int test_main(void)
 		} while (ret == 0);

 		if (ret != -EINTR) {
-			printf("child: io_pgetevents did not set errno to EINTR\n");
+			printf("child: io_pgetevents did not set errno to "
+			       "EINTR: %s\n", strerror(-ret));
 			return 1;
 		}

@@ -117,7 +118,7 @@ int test_main(void)

 		ret = io_setup(1, &ctx);
 		if (ret) {
-			printf("parent: io_setup failed\n");
+			printf("parent: io_setup failed: %s\n", strerror(-ret));
 			return 1;
 		}

@@ -126,7 +127,8 @@ int test_main(void)
 			/* if poll isn't supported, skip the test */
 			if (ret == -EINVAL)
 				return 3;
-			printf("parent: io_submit failed with %d\n", ret);
+			printf("parent: io_submit failed with %d: %s\n",
+			       ret, strerror(-ret));
 			return 1;
 		}

@@ -134,7 +136,8 @@ int test_main(void)

 		ret = io_pgetevents(ctx, 1, 1, &ev, NULL, &sigmask);
 		if (ret < 0) {
-			printf("parent: io_pgetevents failed\n");
+			printf("parent: io_pgetevents failed: %s\n",
+			       strerror(-ret));
 			return 1;
 		}
 		if (ret != 1) {
--
2.26.0.292.g33ef6b2f38


code:
From d2029c6693561b555723b228c9172fd2dc02646e Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Wed, 21 Aug 2019 05:29:52 +0200
Subject: [PATCH libaio 28/28] harness: Skip the test if io_pgetevents() is not
 implemented

Either the kernel or the syscall wrapper will return -ENOSYS when this
syscall is not implemented. So we should cope with this in the test
suite and SKIP the test case.

This is currently the case for alpha and ia64, even though they have
already been wired up very recently in the kernel mainline.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
 harness/cases/22.t | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/harness/cases/22.t b/harness/cases/22.t
index c47140d..d6a8986 100644
--- a/harness/cases/22.t
+++ b/harness/cases/22.t
@@ -98,6 +98,10 @@ int test_main(void)
 			ret = io_pgetevents(ctx, 1, 1, &ev, &to, &sigmask);
 		} while (ret == 0);

+		/* SKIP if the syscall has not been implemented. */
+		if (ret == -ENOSYS)
+			return 3;
+
 		if (ret != -EINTR) {
 			printf("child: io_pgetevents did not set errno to "
 			       "EINTR: %s\n", strerror(-ret));
@@ -135,6 +139,9 @@ int test_main(void)
 		kill(p, SIGUSR1);

 		ret = io_pgetevents(ctx, 1, 1, &ev, NULL, &sigmask);
+		/* SKIP if the syscall has not been implemented. */
+		if (ret == -ENOSYS)
+			return 3;
 		if (ret < 0) {
 			printf("parent: io_pgetevents failed: %s\n",
 			       strerror(-ret));
--
2.26.0.292.g33ef6b2f38


code:
Index: libid3tag-0.15.1b/frametype.h
===================================================================
--- libid3tag-0.15.1b.orig/frametype.h
+++ libid3tag-0.15.1b/frametype.h
@@ -37,6 +37,6 @@ extern struct id3_frametype const id3_fr
 extern struct id3_frametype const id3_frametype_obsolete;

 struct id3_frametype const *id3_frametype_lookup(register char const *,
-						 register unsigned int);
+						 register size_t);

 # endif
Index: libid3tag-0.15.1b/compat.h
===================================================================
--- libid3tag-0.15.1b.orig/compat.h
+++ libid3tag-0.15.1b/compat.h
@@ -34,7 +34,7 @@ struct id3_compat {
 };

 struct id3_compat const *id3_compat_lookup(register char const *,
-					   register unsigned int);
+					   register size_t);

 int id3_compat_fixup(struct id3_tag *);


code:
#! /bin/sh /usr/share/dpatch/dpatch-run
## 11_unknown_encoding.dpatch by Andreas Henriksson <andreas@fatal.se>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: In case of an unknown/invalid encoding, id3_parse_string() will
## DP: return NULL, but the return value wasn't checked resulting
## DP: in segfault in id3_ucs4_length().  This is the only place
## DP: the return value wasn't checked.

@DPATCH@
diff -urNad libid3tag-0.15.1b~/compat.gperf libid3tag-0.15.1b/compat.gperf
--- libid3tag-0.15.1b~/compat.gperf	2004-01-23 09:41:32.000000000 +0000
+++ libid3tag-0.15.1b/compat.gperf	2007-01-14 14:36:53.000000000 +0000
@@ -236,6 +236,10 @@

     encoding = id3_parse_uint(&data, 1);
     string   = id3_parse_string(&data, end - data, encoding, 0);
+    if (!string)
+    {
+	continue;
+    }

     if (id3_ucs4_length(string) < 4) {
       free(string);
diff -urNad libid3tag-0.15.1b~/parse.c libid3tag-0.15.1b/parse.c
--- libid3tag-0.15.1b~/parse.c	2004-01-23 09:41:32.000000000 +0000
+++ libid3tag-0.15.1b/parse.c	2007-01-14 14:37:34.000000000 +0000
@@ -165,6 +165,9 @@
   case ID3_FIELD_TEXTENCODING_UTF_8:
     ucs4 = id3_utf8_deserialize(ptr, length);
     break;
+  default:
+  	/* FIXME: Unknown encoding! Print warning? */
+	return NULL;
   }

   if (ucs4 && !full) {


code:
#! /bin/sh /usr/share/dpatch/dpatch-run
## 10_id3v1_zeropadding.dpatch by  <sm17hs@gmail.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Use zero padding instead of space padding for ID3V1 fields
## DP: (as requested by http://id3lib.sourceforge.net/id3/id3v1.html).

@DPATCH@
diff -urNad libid3tag-0.15.1b~/render.c libid3tag-0.15.1b/render.c
--- libid3tag-0.15.1b~/render.c	2004-01-23 10:41:32.000000000 +0100
+++ libid3tag-0.15.1b/render.c	2009-11-09 17:17:48.000000000 +0100
@@ -183,18 +183,16 @@
   end  = data + length;

   if (ucs4) {
-    while (*ucs4 && end - data > 0) {
+    while (*ucs4 && end - data > 0)
       *data++ = *ucs4++;
-
-      if (data[-1] == '\n')
-	data[-1] = ' ';
-    }
   }

-  while (end - data > 0)
-    *data++ = ' ';
-
   *data = 0;

-  return id3_latin1_serialize(ptr, padded, 0);
+  id3_latin1_serialize(ptr, padded, 0);
+
+  if (end - data > 0)
+    id3_render_padding(ptr, 0, end - data);
+
+  return length;
 }


code:
; You can calculate where the next frame will start depending on things
; like the bitrate. See mad_header_decode().  It seems that when decoding
; the frame you can go past that boundary.  This attempts to catch those cases,
; but might not catch all of them.
; For more info see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508133
Index: libmad-0.15.1b/layer12.c
===================================================================
--- a/layer12.c	2008-12-23 21:38:07.000000000 +0100
+++ b/layer12.c	2008-12-23 21:38:12.000000000 +0100
@@ -134,6 +134,12 @@
   for (sb = 0; sb < bound; ++sb) {
     for (ch = 0; ch < nch; ++ch) {
       nb = mad_bit_read(&stream->ptr, 4);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

       if (nb == 15) {
 	stream->error = MAD_ERROR_BADBITALLOC;
@@ -146,6 +152,12 @@

   for (sb = bound; sb < 32; ++sb) {
     nb = mad_bit_read(&stream->ptr, 4);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

     if (nb == 15) {
       stream->error = MAD_ERROR_BADBITALLOC;
@@ -162,6 +174,12 @@
     for (ch = 0; ch < nch; ++ch) {
       if (allocation[ch][sb]) {
 	scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

 # if defined(OPT_STRICT)
 	/*
@@ -187,6 +205,12 @@
 	frame->sbsample[ch][s][sb] = nb ?
 	  mad_f_mul(I_sample(&stream->ptr, nb),
 		    sf_table[scalefactor[ch][sb]]) : 0;
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}
       }
     }

@@ -195,6 +219,12 @@
 	mad_fixed_t sample;

 	sample = I_sample(&stream->ptr, nb);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

 	for (ch = 0; ch < nch; ++ch) {
 	  frame->sbsample[ch][s][sb] =
@@ -403,7 +433,15 @@
     nbal = bitalloc_table[offsets[sb]].nbal;

     for (ch = 0; ch < nch; ++ch)
+    {
       allocation[ch][sb] = mad_bit_read(&stream->ptr, nbal);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}
+    }
   }

   for (sb = bound; sb < sblimit; ++sb) {
@@ -411,6 +449,13 @@

     allocation[0][sb] =
     allocation[1][sb] = mad_bit_read(&stream->ptr, nbal);
+
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}
   }

   /* decode scalefactor selection info */
@@ -419,6 +464,12 @@
     for (ch = 0; ch < nch; ++ch) {
       if (allocation[ch][sb])
 	scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}
     }
   }

@@ -442,6 +493,12 @@
     for (ch = 0; ch < nch; ++ch) {
       if (allocation[ch][sb]) {
 	scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

 	switch (scfsi[ch][sb]) {
 	case 2:
@@ -452,11 +509,23 @@

 	case 0:
 	  scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6);
+		if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+		{
+			stream->error = MAD_ERROR_LOSTSYNC;
+			stream->sync = 0;
+			return -1;
+		}
 	  /* fall through */

 	case 1:
 	case 3:
 	  scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6);
+		if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+		{
+			stream->error = MAD_ERROR_LOSTSYNC;
+			stream->sync = 0;
+			return -1;
+		}
 	}

 	if (scfsi[ch][sb] & 1)
@@ -488,6 +557,12 @@
 	  index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1];

 	  II_samples(&stream->ptr, &qc_table[index], samples);
+		if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+		{
+			stream->error = MAD_ERROR_LOSTSYNC;
+			stream->sync = 0;
+			return -1;
+		}

 	  for (s = 0; s < 3; ++s) {
 	    frame->sbsample[ch][3 * gr + s][sb] =
@@ -506,6 +581,12 @@
 	index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1];

 	II_samples(&stream->ptr, &qc_table[index], samples);
+	if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
+	{
+		stream->error = MAD_ERROR_LOSTSYNC;
+		stream->sync = 0;
+		return -1;
+	}

 	for (ch = 0; ch < nch; ++ch) {
 	  for (s = 0; s < 3; ++s) {
Index: libmad-0.15.1b/layer3.c
===================================================================
--- a/layer3.c	2008-12-23 21:38:07.000000000 +0100
+++ b/layer3.c	2008-12-23 21:38:12.000000000 +0100
@@ -2608,6 +2608,12 @@
     next_md_begin = 0;

   md_len = si.main_data_begin + frame_space - next_md_begin;
+  if (md_len + MAD_BUFFER_GUARD > MAD_BUFFER_MDLEN)
+  {
+	stream->error = MAD_ERROR_LOSTSYNC;
+	stream->sync = 0;
+	return -1;
+  }

   frame_used = 0;


code:
diff -Naur libmad-0.15.1b-orig/configure.ac libmad-0.15.1b/configure.ac
--- libmad-0.15.1b-orig/configure.ac	2007-06-30 20:22:31.000000000 -0600
+++ libmad-0.15.1b/configure.ac	2007-06-30 20:25:31.000000000 -0600
@@ -122,74 +122,74 @@
     esac
 done

-if test "$GCC" = yes
-then
-    if test -z "$arch"
-    then
-	case "$host" in
-	    i386-*)           ;;
-	    i?86-*)           arch="-march=i486" ;;
-	    arm*-empeg-*)     arch="-march=armv4 -mtune=strongarm1100" ;;
-	    armv4*-*)         arch="-march=armv4 -mtune=strongarm" ;;
-	    powerpc-*)        ;;
-	    mips*-agenda-*)   arch="-mcpu=vr4100" ;;
-	    mips*-luxsonor-*) arch="-mips1 -mcpu=r3000 -Wa,-m4010" ;;
-	esac
-    fi
-
-    case "$optimize" in
-	-O|"-O "*)
-	    optimize="-O"
-	    optimize="$optimize -fforce-mem"
-	    optimize="$optimize -fforce-addr"
-	    : #x optimize="$optimize -finline-functions"
-	    : #- optimize="$optimize -fstrength-reduce"
-	    optimize="$optimize -fthread-jumps"
-	    optimize="$optimize -fcse-follow-jumps"
-	    optimize="$optimize -fcse-skip-blocks"
-	    : #x optimize="$optimize -frerun-cse-after-loop"
-	    : #x optimize="$optimize -frerun-loop-opt"
-	    : #x optimize="$optimize -fgcse"
-	    optimize="$optimize -fexpensive-optimizations"
-	    optimize="$optimize -fregmove"
-	    : #* optimize="$optimize -fdelayed-branch"
-	    : #x optimize="$optimize -fschedule-insns"
-	    optimize="$optimize -fschedule-insns2"
-	    : #? optimize="$optimize -ffunction-sections"
-	    : #? optimize="$optimize -fcaller-saves"
-	    : #> optimize="$optimize -funroll-loops"
-	    : #> optimize="$optimize -funroll-all-loops"
-	    : #x optimize="$optimize -fmove-all-movables"
-	    : #x optimize="$optimize -freduce-all-givs"
-	    : #? optimize="$optimize -fstrict-aliasing"
-	    : #* optimize="$optimize -fstructure-noalias"
-
-	    case "$host" in
-		arm*-*)
-		    optimize="$optimize -fstrength-reduce"
-		    ;;
-		mips*-*)
-		    optimize="$optimize -fstrength-reduce"
-		    optimize="$optimize -finline-functions"
-		    ;;
-		i?86-*)
-		    optimize="$optimize -fstrength-reduce"
-		    ;;
-		powerpc-apple-*)
-		    # this triggers an internal compiler error with gcc2
-		    : #optimize="$optimize -fstrength-reduce"
-
-		    # this is really only beneficial with gcc3
-		    : #optimize="$optimize -finline-functions"
-		    ;;
-		*)
-		    # this sometimes provokes bugs in gcc 2.95.2
-		    : #optimize="$optimize -fstrength-reduce"
-		    ;;
-	    esac
-	    ;;
-    esac
-fi
+#if test "$GCC" = yes
+#then
+#    if test -z "$arch"
+#    then
+#	case "$host" in
+#	    i386-*)           ;;
+#	    i?86-*)           arch="-march=i486" ;;
+#	    arm*-empeg-*)     arch="-march=armv4 -mtune=strongarm1100" ;;
+#	    armv4*-*)         arch="-march=armv4 -mtune=strongarm" ;;
+#	    powerpc-*)        ;;
+#	    mips*-agenda-*)   arch="-mcpu=vr4100" ;;
+#	    mips*-luxsonor-*) arch="-mips1 -mcpu=r3000 -Wa,-m4010" ;;
+#	esac
+#    fi
+#
+#    case "$optimize" in
+#	-O|"-O "*)
+#	    optimize="-O"
+#	    optimize="$optimize -fforce-mem"
+#	    optimize="$optimize -fforce-addr"
+#	    : #x optimize="$optimize -finline-functions"
+#	    : #- optimize="$optimize -fstrength-reduce"
+#	    optimize="$optimize -fthread-jumps"
+#	    optimize="$optimize -fcse-follow-jumps"
+#	    optimize="$optimize -fcse-skip-blocks"
+#	    : #x optimize="$optimize -frerun-cse-after-loop"
+#	    : #x optimize="$optimize -frerun-loop-opt"
+#	    : #x optimize="$optimize -fgcse"
+#	    optimize="$optimize -fexpensive-optimizations"
+#	    optimize="$optimize -fregmove"
+#	    : #* optimize="$optimize -fdelayed-branch"
+#	    : #x optimize="$optimize -fschedule-insns"
+#	    optimize="$optimize -fschedule-insns2"
+#	    : #? optimize="$optimize -ffunction-sections"
+#	    : #? optimize="$optimize -fcaller-saves"
+#	    : #> optimize="$optimize -funroll-loops"
+#	    : #> optimize="$optimize -funroll-all-loops"
+#	    : #x optimize="$optimize -fmove-all-movables"
+#	    : #x optimize="$optimize -freduce-all-givs"
+#	    : #? optimize="$optimize -fstrict-aliasing"
+#	    : #* optimize="$optimize -fstructure-noalias"
+#
+#	    case "$host" in
+#		arm*-*)
+#		    optimize="$optimize -fstrength-reduce"
+#		    ;;
+#		mips*-*)
+#		    optimize="$optimize -fstrength-reduce"
+#		    optimize="$optimize -finline-functions"
+#		    ;;
+#		i?86-*)
+#		    optimize="$optimize -fstrength-reduce"
+#		    ;;
+#		powerpc-apple-*)
+#		    # this triggers an internal compiler error with gcc2
+#		    : #optimize="$optimize -fstrength-reduce"
+#
+#		    # this is really only beneficial with gcc3
+#		    : #optimize="$optimize -finline-functions"
+#		    ;;
+#		*)
+#		    # this sometimes provokes bugs in gcc 2.95.2
+#		    : #optimize="$optimize -fstrength-reduce"
+#		    ;;
+#	    esac
+#	    ;;
+#    esac
+#fi

 case "$host" in
     mips*-agenda-*)


code:
libmad: MIPS GCC-4.4 build fixes

GCC-4.4 on MIPS removed the "h" asm constraint, fix this up.
Taken from OE.

http://patchwork.openembedded.org/patch/921/

diff -ur libmad-0.15.1b-orig/fixed.h libmad-0.15.1b/fixed.h
--- libmad-0.15.1b-orig/fixed.h	2004-02-17 12:32:03.000000000 +1030
+++ libmad-0.15.1b/fixed.h	2009-08-05 10:46:30.000000000 +0930
@@ -299,6 +299,23 @@

 # elif defined(FPM_MIPS)

+/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
+#if defined (__GNUC__) && defined (__GNUC_MINOR__)
+#define __GNUC_PREREQ(maj, min) \
+	((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+#define __GNUC_PREREQ(maj, min)  0
+#endif
+
+#if __GNUC_PREREQ(4,4)
+  typedef unsigned int u64_di_t __attribute__ ((mode (DI)));
+# define MAD_F_MLX(hi, lo, x, y) \
+   do { \
+      u64_di_t __ll = (u64_di_t) (x) * (y); \
+      hi = __ll >> 32; \
+      lo = __ll; \
+   } while (0)
+#else
 /*
  * This MIPS version is fast and accurate; the disposition of the least
  * significant bit depends on OPT_ACCURACY via mad_f_scale64().
@@ -328,6 +345,7 @@
 	 : "%r" ((x) >> 12), "r" ((y) >> 16))
 #  define MAD_F_MLZ(hi, lo)  ((mad_fixed_t) (lo))
 # endif
+#endif /* __GNU_PREREQ(4,4) */

 # if defined(OPT_SPEED)
 #  define mad_f_scale64(hi, lo)  \
diff -ur libmad-0.15.1b-orig/mad.h libmad-0.15.1b/mad.h
--- libmad-0.15.1b-orig/mad.h	2004-02-17 13:25:44.000000000 +1030
+++ libmad-0.15.1b/mad.h	2009-08-05 10:42:40.000000000 +0930
@@ -344,6 +344,23 @@

 # elif defined(FPM_MIPS)

+/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
+#if defined (__GNUC__) && defined (__GNUC_MINOR__)
+#define __GNUC_PREREQ(maj, min) \
+	((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+#define __GNUC_PREREQ(maj, min)  0
+#endif
+
+#if __GNUC_PREREQ(4,4)
+  typedef unsigned int u64_di_t __attribute__ ((mode (DI)));
+# define MAD_F_MLX(hi, lo, x, y) \
+   do { \
+      u64_di_t __ll = (u64_di_t) (x) * (y); \
+      hi = __ll >> 32; \
+      lo = __ll; \
+   } while (0)
+#else
 /*
  * This MIPS version is fast and accurate; the disposition of the least
  * significant bit depends on OPT_ACCURACY via mad_f_scale64().
@@ -373,6 +390,7 @@
 	 : "%r" ((x) >> 12), "r" ((y) >> 16))
 #  define MAD_F_MLZ(hi, lo)  ((mad_fixed_t) (lo))
 # endif
+#endif /* __GNU_PREREQ(4,4) */

 # if defined(OPT_SPEED)
 #  define mad_f_scale64(hi, lo)  \


code:
diff -urp libmetalink-0.1.3.orig/lib/metalink_pstate.c libmetalink-0.1.3/lib/metalink_pstate.c
--- libmetalink-0.1.3.orig/lib/metalink_pstate.c	2012-08-12 04:43:53.000000000 -0400
+++ libmetalink-0.1.3/lib/metalink_pstate.c	2020-07-22 17:03:21.205852103 -0400
@@ -100,7 +100,7 @@ void initial_state_start_fun(metalink_ps
 			     const char** attrs)
 {
   if(strcmp("metalink", name) == 0) {
-    if (strcmp(METALINK_V3_NS_URI, ns_uri) == 0) {
+    if (ns_uri && strcmp(METALINK_V3_NS_URI, ns_uri) == 0) {
       const char* type;
       const char* origin;
       metalink_pctrl_set_version(stm->ctrl, METALINK_VERSION_3);
@@ -116,7 +116,7 @@ void initial_state_start_fun(metalink_ps

       metalink_pstm_enter_metalink_state(stm);
     }
-    else if (strcmp(METALINK_V4_NS_URI, ns_uri) == 0) {
+    else if (ns_uri && strcmp(METALINK_V4_NS_URI, ns_uri) == 0) {
       metalink_pctrl_set_version(stm->ctrl, METALINK_VERSION_4);
       metalink_pstm_enter_metalink_state_v4(stm);
     } else {