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>
This commit is contained in:
André Goddard Rosa 2010-02-23 04:04:24 -03:00 committed by Al Viro
parent c8308b1c91
commit 8834cf796a
1 changed files with 5 additions and 4 deletions

View File

@ -261,8 +261,9 @@ static void mqueue_delete_inode(struct inode *inode)
clear_inode(inode); clear_inode(inode);
mq_bytes = (info->attr.mq_maxmsg * sizeof(struct msg_msg *) + /* Total amount of bytes accounted for the mqueue */
(info->attr.mq_maxmsg * info->attr.mq_msgsize)); mq_bytes = info->attr.mq_maxmsg * (sizeof(struct msg_msg *)
+ info->attr.mq_msgsize);
user = info->user; user = info->user;
if (user) { if (user) {
spin_lock(&mq_lock); spin_lock(&mq_lock);
@ -601,8 +602,8 @@ static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr)
/* check for overflow */ /* check for overflow */
if (attr->mq_msgsize > ULONG_MAX/attr->mq_maxmsg) if (attr->mq_msgsize > ULONG_MAX/attr->mq_maxmsg)
return 0; return 0;
if ((unsigned long)(attr->mq_maxmsg * attr->mq_msgsize) + if ((unsigned long)(attr->mq_maxmsg * (attr->mq_msgsize
(attr->mq_maxmsg * sizeof (struct msg_msg *)) < + sizeof (struct msg_msg *))) <
(unsigned long)(attr->mq_maxmsg * attr->mq_msgsize)) (unsigned long)(attr->mq_maxmsg * attr->mq_msgsize))
return 0; return 0;
return 1; return 1;