]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
Add parens to sizeof operator to clarify usage
authorSean Hefty <sean.hefty@intel.com>
Mon, 31 Aug 2015 18:24:46 +0000 (11:24 -0700)
committerSean Hefty <sean.hefty@intel.com>
Mon, 31 Aug 2015 18:24:46 +0000 (11:24 -0700)
Convert sizeof *ptr -> sizeof(*ptr) to avoid confusion.  This
is in response to the (false) bug report 2568.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/acm.c
src/addrinfo.c
src/cma.c
src/preload.c
src/rsocket.c

index fa06d319cd500985241786fd8881677e737168fa..f0da01e6d28610008ed08dec09659373761e2596 100644 (file)
--- a/src/acm.c
+++ b/src/acm.c
@@ -176,11 +176,11 @@ static int ucma_ib_set_addr(struct rdma_addrinfo *ib_rai,
        struct sockaddr_ib *src, *dst;
        struct ibv_path_record *path;
 
-       src = calloc(1, sizeof *src);
+       src = calloc(1, sizeof(*src));
        if (!src)
                return ERR(ENOMEM);
 
-       dst = calloc(1, sizeof *dst);
+       dst = calloc(1, sizeof(*dst));
        if (!dst) {
                free(src);
                return ERR(ENOMEM);
@@ -217,7 +217,7 @@ static int ucma_ib_set_connect(struct rdma_addrinfo *ib_rai,
        if (rai->ai_family == AF_IB)
                return 0;
 
-       hdr = calloc(1, sizeof *hdr);
+       hdr = calloc(1, sizeof(*hdr));
        if (!hdr)
                return ERR(ENOMEM);
 
index cdeb66381206df6c1ab258ad89568413ed995f75..046b8be11be1b81b80146b86d19973453bc1be9a 100644 (file)
@@ -49,7 +49,7 @@ struct rdma_addrinfo nohints;
 
 static void ucma_convert_to_ai(struct addrinfo *ai, struct rdma_addrinfo *rai)
 {
-       memset(ai, 0, sizeof *ai);
+       memset(ai, 0, sizeof(*ai));
        if (rai->ai_flags & RAI_PASSIVE)
                ai->ai_flags = AI_PASSIVE;
        if (rai->ai_flags & RAI_NUMERICHOST)
index 3e6262c1077df7e1f8f936bd1136ecb363daea30..a89e663bcaaba9637fb863495b428bda36d35460 100644 (file)
--- a/src/cma.c
+++ b/src/cma.c
@@ -241,7 +241,7 @@ int ucma_init(void)
                goto err2;
        }
 
-       cma_dev_array = calloc(dev_cnt, sizeof *cma_dev_array);
+       cma_dev_array = calloc(dev_cnt, sizeof(*cma_dev_array));
        if (!cma_dev_array) {
                ret = ERR(ENOMEM);
                goto err2;
@@ -305,7 +305,7 @@ static int ucma_init_device(struct cma_device *cma_dev)
                goto err;
        }
 
-       cma_dev->port = malloc(sizeof *cma_dev->port * attr.phys_port_cnt);
+       cma_dev->port = malloc(sizeof(*cma_dev->port) * attr.phys_port_cnt);
        if (!cma_dev->port) {
                ret = ERR(ENOMEM);
                goto err;
@@ -362,7 +362,7 @@ struct ibv_context **rdma_get_devices(int *num_devices)
        if (ucma_init_all())
                goto out;
 
-       devs = malloc(sizeof *devs * (cma_dev_cnt + 1));
+       devs = malloc(sizeof(*devs) * (cma_dev_cnt + 1));
        if (!devs)
                goto out;
 
@@ -392,7 +392,7 @@ struct rdma_event_channel *rdma_create_event_channel(void)
        if (ucma_init())
                return NULL;
 
-       channel = malloc(sizeof *channel);
+       channel = malloc(sizeof(*channel));
        if (!channel)
                return NULL;
 
@@ -514,7 +514,7 @@ static struct cma_id_private *ucma_alloc_id(struct rdma_event_channel *channel,
 {
        struct cma_id_private *id_priv;
 
-       id_priv = calloc(1, sizeof *id_priv);
+       id_priv = calloc(1, sizeof(*id_priv));
        if (!id_priv)
                return NULL;
 
@@ -791,7 +791,7 @@ static int ucma_query_route(struct rdma_cm_id *id)
        VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
 
        if (resp.num_paths) {
-               id->route.path_rec = malloc(sizeof *id->route.path_rec *
+               id->route.path_rec = malloc(sizeof(*id->route.path_rec) *
                                            resp.num_paths);
                if (!id->route.path_rec)
                        return ERR(ENOMEM);
@@ -1333,7 +1333,7 @@ int rdma_create_srq(struct rdma_cm_id *id, struct ibv_pd *pd,
        struct ibv_srq_init_attr_ex attr_ex;
        int ret;
 
-       memcpy(&attr_ex, attr, sizeof *attr);
+       memcpy(&attr_ex, attr, sizeof(*attr));
        attr_ex.comp_mask = IBV_SRQ_INIT_ATTR_TYPE | IBV_SRQ_INIT_ATTR_PD;
        if (id->qp_type == IBV_QPT_XRC_RECV) {
                attr_ex.srq_type = IBV_SRQT_XRC;
@@ -1342,7 +1342,7 @@ int rdma_create_srq(struct rdma_cm_id *id, struct ibv_pd *pd,
        }
        attr_ex.pd = pd;
        ret = rdma_create_srq_ex(id, &attr_ex);
-       memcpy(attr, &attr_ex, sizeof *attr);
+       memcpy(attr, &attr_ex, sizeof(*attr));
        return ret;
 }
 
@@ -1423,11 +1423,11 @@ int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
        struct ibv_qp_init_attr_ex attr_ex;
        int ret;
 
-       memcpy(&attr_ex, qp_init_attr, sizeof *qp_init_attr);
+       memcpy(&attr_ex, qp_init_attr, sizeof(*qp_init_attr));
        attr_ex.comp_mask = IBV_QP_INIT_ATTR_PD;
        attr_ex.pd = pd ? pd : id->pd;
        ret = rdma_create_qp_ex(id, &attr_ex);
-       memcpy(qp_init_attr, &attr_ex, sizeof *qp_init_attr);
+       memcpy(qp_init_attr, &attr_ex, sizeof(*qp_init_attr));
        return ret;
 }
 
@@ -1751,7 +1751,7 @@ static int rdma_join_multicast2(struct rdma_cm_id *id, struct sockaddr *addr,
        int ret;
        
        id_priv = container_of(id, struct cma_id_private, id);
-       mc = calloc(1, sizeof *mc);
+       mc = calloc(1, sizeof(*mc));
        if (!mc)
                return ERR(ENOMEM);
 
@@ -2096,12 +2096,12 @@ int rdma_get_cm_event(struct rdma_event_channel *channel,
        if (!event)
                return ERR(EINVAL);
 
-       evt = malloc(sizeof *evt);
+       evt = malloc(sizeof(*evt));
        if (!evt)
                return ERR(ENOMEM);
 
 retry:
-       memset(evt, 0, sizeof *evt);
+       memset(evt, 0, sizeof(*evt));
        CMA_INIT_CMD_RESP(&cmd, sizeof cmd, GET_EVENT, &resp, sizeof resp);
        ret = write(channel->fd, &cmd, sizeof cmd);
        if (ret != sizeof cmd) {
@@ -2354,7 +2354,7 @@ static int ucma_passive_ep(struct rdma_cm_id *id, struct rdma_addrinfo *res,
                id->pd = pd;
 
        if (qp_init_attr) {
-               id_priv->qp_init_attr = malloc(sizeof *qp_init_attr);
+               id_priv->qp_init_attr = malloc(sizeof(*qp_init_attr));
                if (!id_priv->qp_init_attr)
                        return ERR(ENOMEM);
 
index e7822aeb8c52f634ad471a3f3eb4059556225014..3a0bc4c8c71db430a1fc84a19c4cb5e0bf0ff497 100644 (file)
@@ -260,7 +260,7 @@ static int fd_open(void)
        struct fd_info *fdi;
        int ret, index;
 
-       fdi = calloc(1, sizeof *fdi);
+       fdi = calloc(1, sizeof(*fdi));
        if (!fdi)
                return ERR(ENOMEM);
 
@@ -876,7 +876,7 @@ static struct pollfd *fds_alloc(nfds_t nfds)
                if (rfds)
                        free(rfds);
 
-               rfds = malloc(sizeof *rfds * nfds);
+               rfds = malloc(sizeof(*rfds) * nfds);
                rnfds = rfds ? nfds : 0;
        }
 
@@ -1132,7 +1132,7 @@ int dup2(int oldfd, int newfd)
        if (!oldfdi || ret != newfd)
                return ret;
 
-       newfdi = calloc(1, sizeof *newfdi);
+       newfdi = calloc(1, sizeof(*newfdi));
        if (!newfdi) {
                close(newfd);
                return ERR(ENOMEM);
index 95d791c6a64742787faa88c855ab7e248cdf6621..c4f1b57dbb9a0b56d43d4e7e9249874bd81345e0 100644 (file)
@@ -568,7 +568,7 @@ static struct rsocket *rs_alloc(struct rsocket *inherited_rs, int type)
 {
        struct rsocket *rs;
 
-       rs = calloc(1, sizeof *rs);
+       rs = calloc(1, sizeof(*rs));
        if (!rs)
                return NULL;
 
@@ -1396,7 +1396,7 @@ static int ds_get_src_addr(struct rsocket *rs,
        int sock, ret;
        uint16_t port;
 
-       *src_len = sizeof *src_addr;
+       *src_len = sizeof(*src_addr);
        ret = getsockname(rs->udp_sock, &src_addr->sa, src_len);
        if (ret || !rs_any_addr(src_addr))
                return ret;
@@ -1410,7 +1410,7 @@ static int ds_get_src_addr(struct rsocket *rs,
        if (ret)
                goto out;
 
-       *src_len = sizeof *src_addr;
+       *src_len = sizeof(*src_addr);
        ret = getsockname(sock, &src_addr->sa, src_len);
        src_addr->sin.sin_port = port;
 out:
@@ -2600,7 +2600,7 @@ static ssize_t ds_sendv_udp(struct rsocket *rs, const struct iovec *iov,
        miov[0].iov_base = &hdr;
        miov[0].iov_len = hdr.length;
        if (iov && iovcnt)
-               memcpy(&miov[1], iov, sizeof *iov * iovcnt);
+               memcpy(&miov[1], iov, sizeof(*iov) * iovcnt);
 
        memset(&msg, 0, sizeof msg);
        msg.msg_name = &rs->conn_dest->addr;
@@ -2910,7 +2910,7 @@ static struct pollfd *rs_fds_alloc(nfds_t nfds)
                if (rfds)
                        free(rfds);
 
-               rfds = malloc(sizeof *rfds * nfds);
+               rfds = malloc(sizeof(*rfds) * nfds);
                rnfds = rfds ? nfds : 0;
        }
 
@@ -3110,7 +3110,7 @@ rs_select_to_poll(int *nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfd
        struct pollfd *fds;
        int fd, i = 0;
 
-       fds = calloc(*nfds, sizeof *fds);
+       fds = calloc(*nfds, sizeof(*fds));
        if (!fds)
                return NULL;
 
@@ -3754,7 +3754,7 @@ off_t riomap(int socket, void *buf, size_t len, int prot, int flags, off_t offse
                iomr = rs_get_iomap_mr(rs);
                access |= IBV_ACCESS_REMOTE_WRITE;
        } else {
-               iomr = calloc(1, sizeof *iomr);
+               iomr = calloc(1, sizeof(*iomr));
                iomr->index = -1;
        }
        if (!iomr) {