aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorAndré Goddard Rosa <andre.goddard@gmail.com>2010-02-23 02:04:24 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2010-03-03 14:48:00 -0500
commit8834cf796a4320be2d3a70b1e4f9aba732a0f4ee (patch)
treeb8bde5dde82715a3e69cf5fc0e01430c848588f5 /ipc
parentc8308b1c91056b09e96d40dbde4880ea685c377e (diff)
mqueue: apply mathematics distributivity on mq_bytes calculation
Code size reduction: text data bss dec hex filename 9941 72 16 10029 272d ipc/mqueue-BEFORE.o 9925 72 16 10013 271d ipc/mqueue-AFTER.o Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/mqueue.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 3660c334ee6b..15eabf9d51fd 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -261,8 +261,9 @@ static void mqueue_delete_inode(struct inode *inode)
261 261
262 clear_inode(inode); 262 clear_inode(inode);
263 263
264 mq_bytes = (info->attr.mq_maxmsg * sizeof(struct msg_msg *) + 264 /* Total amount of bytes accounted for the mqueue */
265 (info->attr.mq_maxmsg * info->attr.mq_msgsize)); 265 mq_bytes = info->attr.mq_maxmsg * (sizeof(struct msg_msg *)
266 + info->attr.mq_msgsize);
266 user = info->user; 267 user = info->user;
267 if (user) { 268 if (user) {
268 spin_lock(&mq_lock); 269 spin_lock(&mq_lock);
@@ -601,8 +602,8 @@ static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr)
601 /* check for overflow */ 602 /* check for overflow */
602 if (attr->mq_msgsize > ULONG_MAX/attr->mq_maxmsg) 603 if (attr->mq_msgsize > ULONG_MAX/attr->mq_maxmsg)
603 return 0; 604 return 0;
604 if ((unsigned long)(attr->mq_maxmsg * attr->mq_msgsize) + 605 if ((unsigned long)(attr->mq_maxmsg * (attr->mq_msgsize
605 (attr->mq_maxmsg * sizeof (struct msg_msg *)) < 606 + sizeof (struct msg_msg *))) <
606 (unsigned long)(attr->mq_maxmsg * attr->mq_msgsize)) 607 (unsigned long)(attr->mq_maxmsg * attr->mq_msgsize))
607 return 0; 608 return 0;
608 return 1; 609 return 1;