Commit 8834cf796a4320be2d3a70b1e4f9aba732a0f4ee

Authored by André Goddard Rosa
Committed by Al Viro
1 parent c8308b1c91

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>

Showing 1 changed file with 5 additions and 4 deletions Side-by-side Diff

... ... @@ -261,8 +261,9 @@
261 261  
262 262 clear_inode(inode);
263 263  
264   - mq_bytes = (info->attr.mq_maxmsg * sizeof(struct msg_msg *) +
265   - (info->attr.mq_maxmsg * info->attr.mq_msgsize));
  264 + /* Total amount of bytes accounted for the mqueue */
  265 + mq_bytes = info->attr.mq_maxmsg * (sizeof(struct msg_msg *)
  266 + + info->attr.mq_msgsize);
266 267 user = info->user;
267 268 if (user) {
268 269 spin_lock(&mq_lock);
... ... @@ -601,8 +602,8 @@
601 602 /* check for overflow */
602 603 if (attr->mq_msgsize > ULONG_MAX/attr->mq_maxmsg)
603 604 return 0;
604   - if ((unsigned long)(attr->mq_maxmsg * attr->mq_msgsize) +
605   - (attr->mq_maxmsg * sizeof (struct msg_msg *)) <
  605 + if ((unsigned long)(attr->mq_maxmsg * (attr->mq_msgsize
  606 + + sizeof (struct msg_msg *))) <
606 607 (unsigned long)(attr->mq_maxmsg * attr->mq_msgsize))
607 608 return 0;
608 609 return 1;