diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2013-01-04 18:35:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-01-04 19:11:46 -0500 |
commit | 51eeacaa07d1372a7bc9612548ffe6cd846f4f2f (patch) | |
tree | d92e69517b9973d5c2dd4697e3b38be6539bc2ca /ipc | |
parent | b30efe2775ee0a1d911514292579770b214d31c3 (diff) |
ipc: simplify message copying
Remove the redundant and confusing fill_copy(). Also add 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.
Also define copy_msg() for the case when CONFIG_CHECKPOINT_RESTORE is
disabled.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: James Morris <jmorris@namei.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/msg.c | 25 | ||||
-rw-r--r-- | ipc/msgutil.c | 5 |
2 files changed, 14 insertions, 16 deletions
@@ -770,16 +770,6 @@ static long do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz) | |||
770 | } | 770 | } |
771 | 771 | ||
772 | #ifdef CONFIG_CHECKPOINT_RESTORE | 772 | #ifdef CONFIG_CHECKPOINT_RESTORE |
773 | static inline struct msg_msg *fill_copy(unsigned long copy_nr, | ||
774 | unsigned long msg_nr, | ||
775 | struct msg_msg *msg, | ||
776 | struct msg_msg *copy) | ||
777 | { | ||
778 | if (copy_nr == msg_nr) | ||
779 | return copy_msg(msg, copy); | ||
780 | return NULL; | ||
781 | } | ||
782 | |||
783 | static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz, | 773 | static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz, |
784 | int msgflg, long *msgtyp, | 774 | int msgflg, long *msgtyp, |
785 | unsigned long *copy_number) | 775 | unsigned long *copy_number) |
@@ -803,8 +793,6 @@ static inline void free_copy(struct msg_msg *copy) | |||
803 | free_msg(copy); | 793 | free_msg(copy); |
804 | } | 794 | } |
805 | #else | 795 | #else |
806 | #define fill_copy(copy_nr, msg_nr, msg, copy) NULL | ||
807 | |||
808 | static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz, | 796 | static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz, |
809 | int msgflg, long *msgtyp, | 797 | int msgflg, long *msgtyp, |
810 | unsigned long *copy_number) | 798 | unsigned long *copy_number) |
@@ -868,11 +856,16 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, | |||
868 | walk_msg->m_type != 1) { | 856 | walk_msg->m_type != 1) { |
869 | msgtyp = walk_msg->m_type - 1; | 857 | msgtyp = walk_msg->m_type - 1; |
870 | } else if (msgflg & MSG_COPY) { | 858 | } else if (msgflg & MSG_COPY) { |
871 | msg = fill_copy(copy_number, | 859 | if (copy_number == msg_counter) { |
872 | msg_counter, | 860 | /* |
873 | walk_msg, copy); | 861 | * Found requested message. |
874 | if (msg) | 862 | * Copy it. |
863 | */ | ||
864 | msg = copy_msg(msg, copy); | ||
865 | if (IS_ERR(msg)) | ||
866 | goto out_unlock; | ||
875 | break; | 867 | break; |
868 | } | ||
876 | } else | 869 | } else |
877 | break; | 870 | break; |
878 | msg_counter++; | 871 | msg_counter++; |
diff --git a/ipc/msgutil.c b/ipc/msgutil.c index 7eecdad40efc..ebfcbfa8b7f2 100644 --- a/ipc/msgutil.c +++ b/ipc/msgutil.c | |||
@@ -140,6 +140,11 @@ struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst) | |||
140 | 140 | ||
141 | return dst; | 141 | return dst; |
142 | } | 142 | } |
143 | #else | ||
144 | struct msg_msg *copy_msg(struct msg_msg *src, struct msg_msg *dst) | ||
145 | { | ||
146 | return ERR_PTR(-ENOSYS); | ||
147 | } | ||
143 | #endif | 148 | #endif |
144 | int store_msg(void __user *dest, struct msg_msg *msg, int len) | 149 | int store_msg(void __user *dest, struct msg_msg *msg, int len) |
145 | { | 150 | { |