lkml.org 
[lkml]   [2010]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 2/6] mqueue: apply mathematics distributivity on mq_bytes calculation
    Date
    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>
    ---
    ipc/mqueue.c | 9 +++++----
    1 files changed, 5 insertions(+), 4 deletions(-)

    diff --git a/ipc/mqueue.c b/ipc/mqueue.c
    index 2d76647..04403fd 100644
    --- a/ipc/mqueue.c
    +++ b/ipc/mqueue.c
    @@ -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);
    @@ -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;
    --
    1.7.0.87.g0901d
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2010-02-24 08:17    [W:0.023 / U:63.528 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site