Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src Pull up following revision(s) (requested by skrll in tick...
details: https://anonhg.NetBSD.org/src/rev/f69007117e30
branches: netbsd-6
changeset: 776406:f69007117e30
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Tue Jul 30 04:00:20 2013 +0000
description:
Pull up following revision(s) (requested by skrll in ticket #922):
tests/lib/libc/sys/t_msgrcv.c 1.3
lib/libc/sys/msgrcv.2 1.21-1.22
lib/libc/sys/msgsnd.2 1.19-1.20
Fix msgsz confusion.
diffstat:
lib/libc/sys/msgrcv.2 | 8 ++++--
lib/libc/sys/msgsnd.2 | 8 ++++--
tests/lib/libc/sys/t_msgrcv.c | 47 +++++++++++++++++++++---------------------
3 files changed, 34 insertions(+), 29 deletions(-)
diffs (219 lines):
diff -r e30520c43d94 -r f69007117e30 lib/libc/sys/msgrcv.2
--- a/lib/libc/sys/msgrcv.2 Tue Jul 30 03:05:39 2013 +0000
+++ b/lib/libc/sys/msgrcv.2 Tue Jul 30 04:00:20 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: msgrcv.2,v 1.19 2009/01/28 08:57:02 wiz Exp $
+.\" $NetBSD: msgrcv.2,v 1.19.10.1 2013/07/30 04:00:20 msaitoh Exp $
.\"
.\" Copyright (c) 1995 Frank van der Linden
.\" All rights reserved.
@@ -29,7 +29,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 26, 2009
+.Dd July 24, 2013
.Dt MSGRCV 2
.Os
.Sh NAME
@@ -90,8 +90,10 @@
will be received.
.El
.Pp
+The argument
.Fa msgsz
-specifies the maximum length of the requested message.
+specifies the size in bytes of
+.Va mtext .
If the received message has a length greater than
.Fa msgsz
it will be silently truncated if the
diff -r e30520c43d94 -r f69007117e30 lib/libc/sys/msgsnd.2
--- a/lib/libc/sys/msgsnd.2 Tue Jul 30 03:05:39 2013 +0000
+++ b/lib/libc/sys/msgsnd.2 Tue Jul 30 04:00:20 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: msgsnd.2,v 1.18 2010/04/30 04:06:20 jruoho Exp $
+.\" $NetBSD: msgsnd.2,v 1.18.8.1 2013/07/30 04:00:20 msaitoh Exp $
.\"
.\" Copyright (c) 1995 Frank van der Linden
.\" All rights reserved.
@@ -29,7 +29,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 30, 2010
+.Dd July 24, 2013
.Dt MSGSND 2
.Os
.Sh NAME
@@ -69,7 +69,9 @@
.Xr msgrcv 2 ) .
The
.Va mtext
-field is an array of bytes, with size up to the system limit
+field is an array of bytes of length
+.Fa msgsz ,
+with size up to the system limit
.Dv MSGMAX .
.Pp
If the number of bytes already on the message queue plus
diff -r e30520c43d94 -r f69007117e30 tests/lib/libc/sys/t_msgrcv.c
--- a/tests/lib/libc/sys/t_msgrcv.c Tue Jul 30 03:05:39 2013 +0000
+++ b/tests/lib/libc/sys/t_msgrcv.c Tue Jul 30 04:00:20 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_msgrcv.c,v 1.2 2011/11/11 05:06:01 jruoho Exp $ */
+/* $NetBSD: t_msgrcv.c,v 1.2.2.1 2013/07/30 04:00:20 msaitoh Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_msgrcv.c,v 1.2 2011/11/11 05:06:01 jruoho Exp $");
+__RCSID("$NetBSD: t_msgrcv.c,v 1.2.2.1 2013/07/30 04:00:20 msaitoh Exp $");
#include <sys/msg.h>
#include <sys/stat.h>
@@ -51,10 +51,11 @@
#define MSG_MTYPE_1 0x41
#define MSG_MTYPE_2 0x42
#define MSG_MTYPE_3 0x43
+#define MSG_LEN 3
struct msg {
long mtype;
- char buf[3];
+ char buf[MSG_LEN];
};
static void clean(void);
@@ -83,8 +84,8 @@
id = msgget(MSG_KEY, IPC_CREAT | 0600);
ATF_REQUIRE(id != -1);
- (void)msgsnd(id, &msg1, sizeof(struct msg), IPC_NOWAIT);
- (void)msgrcv(id, &msg2, sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT);
+ (void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT);
+ (void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT);
ATF_CHECK(msg1.buf[0] == msg2.buf[0]);
ATF_CHECK(msg1.buf[1] == msg2.buf[1]);
@@ -118,7 +119,7 @@
if (pid == 0) {
- if (msgrcv(id, &msg, sizeof(struct msg), MSG_MTYPE_1, 0) < 0)
+ if (msgrcv(id, &msg, MSG_LEN, MSG_MTYPE_1, 0) < 0)
_exit(EXIT_FAILURE);
_exit(EXIT_SUCCESS);
@@ -129,7 +130,7 @@
* and hence kill(2) should fail with ESRCH.
*/
(void)sleep(1);
- (void)msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT);
+ (void)msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT);
(void)sleep(1);
(void)kill(pid, SIGKILL);
(void)wait(&sta);
@@ -162,31 +163,31 @@
errno = 0;
ATF_REQUIRE_ERRNO(ENOMSG, msgrcv(id, &msg,
- sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT) == -1);
+ MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1);
- ATF_REQUIRE(msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT) == 0);
+ ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0);
errno = 0;
ATF_REQUIRE_ERRNO(EFAULT, msgrcv(id, (void *)-1,
- sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT) == -1);
+ MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1);
errno = 0;
ATF_REQUIRE_ERRNO(EINVAL, msgrcv(-1, &msg,
- sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT) == -1);
+ MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1);
errno = 0;
ATF_REQUIRE_ERRNO(EINVAL, msgrcv(-1, &msg,
SSIZE_MAX, MSG_MTYPE_1, IPC_NOWAIT) == -1);
- ATF_REQUIRE(msgsnd(id, &msg, sizeof(struct msg), IPC_NOWAIT) == 0);
+ ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0);
errno = 0;
ATF_REQUIRE_ERRNO(E2BIG, msgrcv(id, &r,
- sizeof(int), MSG_MTYPE_1, IPC_NOWAIT) == -1);
+ MSG_LEN - 1, MSG_MTYPE_1, IPC_NOWAIT) == -1);
ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
}
@@ -212,14 +213,14 @@
id = msgget(MSG_KEY, IPC_CREAT | 0600);
ATF_REQUIRE(id != -1);
- (void)msgsnd(id, &msg1, sizeof(struct msg), IPC_NOWAIT);
- (void)msgrcv(id, &msg2, sizeof(struct msg), MSG_MTYPE_2, IPC_NOWAIT);
+ (void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT);
+ (void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_2, IPC_NOWAIT);
ATF_CHECK(msg1.buf[0] != msg2.buf[0]); /* Different mtype. */
ATF_CHECK(msg1.buf[1] != msg2.buf[1]);
ATF_CHECK(msg1.buf[2] != msg2.buf[2]);
- (void)msgrcv(id, &msg2, sizeof(struct msg), MSG_MTYPE_1, IPC_NOWAIT);
+ (void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT);
ATF_CHECK(msg1.buf[0] == msg2.buf[0]); /* Same mtype. */
ATF_CHECK(msg1.buf[1] == msg2.buf[1]);
@@ -253,8 +254,7 @@
for (i = 0; i < n; i++) {
- ATF_REQUIRE(msgsnd(id, &msg,
- sizeof(struct msg), IPC_NOWAIT) == 0);
+ ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0);
}
pid = fork();
@@ -264,8 +264,8 @@
while (i != 0) {
- if (msgrcv(id, &msg, sizeof(struct msg),
- MSG_MTYPE_1, IPC_NOWAIT) == -1)
+ if (msgrcv(id, &msg, MSG_LEN, MSG_MTYPE_1,
+ IPC_NOWAIT) == -1)
_exit(EXIT_FAILURE);
i--;
@@ -300,9 +300,10 @@
ATF_TC_BODY(msgrcv_truncate, tc)
{
+#define MSG_SMALLLEN 2
struct msgsmall {
long mtype;
- char buf[2];
+ char buf[MSG_SMALLLEN];
};
struct msg msg1 = { MSG_MTYPE_1, { 'a', 'b', 'c' } };
@@ -312,8 +313,8 @@
id = msgget(MSG_KEY, IPC_CREAT | 0600);
ATF_REQUIRE(id != -1);
- (void)msgsnd(id, &msg1, sizeof(struct msg), IPC_NOWAIT);
- (void)msgrcv(id, &msg2, sizeof(struct msgsmall),
+ (void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT);
+ (void)msgrcv(id, &msg2, MSG_SMALLLEN,
MSG_MTYPE_1, IPC_NOWAIT | MSG_NOERROR);
ATF_CHECK(msg1.buf[0] == msg2.buf[0]);
Home |
Main Index |
Thread Index |
Old Index