From: Stanislav Kinsbursky <skinsbursky@parallels.com>
To: akpm@linux-foundation.org
Cc: ebiederm@xmission.com, devel@openvz.org,
linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk,
jmorris@namei.org
Subject: [PATCH 3/4] ipc: simplify message copying
Date: Wed, 07 Nov 2012 13:05:05 +0300 [thread overview]
Message-ID: <20121107100505.22846.27342.stgit@localhost.localdomain> (raw)
In-Reply-To: <20121107100317.22846.94715.stgit@localhost.localdomain>
This patch removed redundant and confusing fill_copy(). It also adds
copy_msg() check for error. In this case exit from the function have to be
done instead of break, because further code interprets any error as EAGAIN.
It also defines copy_msg() for the case when CONFIG_CHECKPOINT_RESTORE is
disabled.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
---
ipc/msg.c | 24 +++++++++---------------
ipc/msgutil.c | 5 +++++
2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/ipc/msg.c b/ipc/msg.c
index ad194f8..5e317fe 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -770,16 +770,6 @@ static long do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz)
}
#ifdef CONFIG_CHECKPOINT_RESTORE
-static inline struct msg_msg *fill_copy(unsigned long copy_nr,
- unsigned long msg_nr,
- struct msg_msg *msg,
- struct msg_msg *copy)
-{
- if (copy_nr == msg_nr)
- return copy_msg(msg, copy);
- return NULL;
-}
-
static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz,
int msgflg, long *msgtyp,
unsigned long *copy_number)
@@ -803,8 +793,6 @@ static inline void free_copy(struct msg_msg *copy)
free_msg(copy);
}
#else
-#define fill_copy(copy_nr, msg_nr, msg, copy) NULL
-
static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz,
int msgflg, long *msgtyp,
unsigned long *copy_number)
@@ -868,10 +856,16 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
walk_msg->m_type != 1) {
msgtyp = walk_msg->m_type - 1;
} else if (msgflg & MSG_COPY) {
- msg = fill_copy(copy_number, msg_counter,
- walk_msg, copy);
- if (msg)
+ if (copy_number == msg_counter) {
+ /*
+ * Found requested message.
+ * Copy it.
+ */
+ msg = copy_msg(msg, copy);
+ if (IS_ERR(msg))
+ goto out_unlock;
break;
+ }
} else
break;
msg_counter++;
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index b281f5c..4168bb8 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -138,6 +138,11 @@ struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
return dst;
}
+#else
+struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst)
+{
+ return ERR_PTR(-ENOSYS);
+}
#endif
int store_msg(void __user *dest, struct msg_msg *msg, int len)
{
next prev parent reply other threads:[~2012-11-07 10:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-07 10:04 [PATCH 0/4] IPC: CRIU enhancements fixes and cleanup Stanislav Kinsbursky
2012-11-07 10:04 ` [PATCH 1/4] ipc: simplify free_copy() call Stanislav Kinsbursky
2012-11-07 10:05 ` [PATCH 2/4] ipc: convert prepare_copy() from macro to function Stanislav Kinsbursky
2012-11-07 19:20 ` Andrew Morton
2012-11-07 10:05 ` Stanislav Kinsbursky [this message]
2012-11-07 10:05 ` [PATCH 4/4] ipc: add more comments to message copying related code Stanislav Kinsbursky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121107100505.22846.27342.stgit@localhost.localdomain \
--to=skinsbursky@parallels.com \
--cc=akpm@linux-foundation.org \
--cc=devel@openvz.org \
--cc=ebiederm@xmission.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox