Skip to content

Commit

Permalink
mqueue: apply mathematics distributivity on mq_bytes calculation
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
andre-rosa authored and Al Viro committed Mar 3, 2010
1 parent c8308b1 commit 8834cf7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ static void mqueue_delete_inode(struct inode *inode)

clear_inode(inode);

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

0 comments on commit 8834cf7

Please sign in to comment.