rc = policy(parent_res, res_id, new_id, mode, NULL);
if (rc == ELDLM_RES_CHANGED) {
*flags |= LDLM_FL_RES_CHANGED;
- memcpy(res_id, new_id, sizeof(__u64) * RES_NAME_SIZE);
+ memcpy(res_id, new_id, sizeof(*new_id));
}
}
if (ns->ns_hash != NULL)
return;
- OBD_ALLOC(res_hash, sizeof(struct list_head) * RES_HASH_SIZE);
+ /* FIXME: this memory appears to be leaked */
+ OBD_ALLOC(res_hash, sizeof(*res_hash) * RES_HASH_SIZE);
if (!res_hash)
LBUG();
if (!res)
LBUG();
- memcpy(res->lr_name, name, RES_NAME_SIZE * sizeof(__u32));
+ memcpy(res->lr_name, name, sizeof(res->lr_name));
res->lr_namespace = ns;
if (type < 0 || type > LDLM_MAX_TYPE)
LBUG();
struct ldlm_resource *chk;
chk = list_entry(tmp, struct ldlm_resource, lr_hash);
- if (memcmp(chk->lr_name, name,
- RES_NAME_SIZE * sizeof(__u32)) == 0) {
+ if (memcmp(chk->lr_name, name, sizeof(chk->lr_name)) == 0) {
res = chk;
atomic_inc(&res->lr_refcount);
break;
struct ll_sb_info *sbi = sb->u.generic_sbp;
ENTRY;
obd_disconnect(&sbi->ll_conn);
- OBD_FREE(sb->u.generic_sbp, sizeof(struct ll_sb_info));
+ OBD_FREE(sb->u.generic_sbp, sizeof(*sbi));
MOD_DEC_USE_COUNT;
EXIT;
} /* ll_put_super */
CDEBUG(D_INODE, "BRW %s with %dx%d pages\n",
rw == OBD_BRW_READ ? "read" : "write",
num, oa_bufs[0]);
- bufs = kmalloc(pages * sizeof(struct page *), GFP_KERNEL);
- counts = kmalloc(pages * sizeof(obd_size), GFP_KERNEL);
- offsets = kmalloc(pages * sizeof(obd_off), GFP_KERNEL);
- flags = kmalloc(pages * sizeof(obd_flag), GFP_KERNEL);
+ bufs = kmalloc(pages * sizeof(*bufs), GFP_KERNEL);
+ counts = kmalloc(pages * sizeof(*counts), GFP_KERNEL);
+ offsets = kmalloc(pages * sizeof(*offsets), GFP_KERNEL);
+ flags = kmalloc(pages * sizeof(*flags), GFP_KERNEL);
if (!bufs || !counts || !offsets || !flags) {
CERROR("no memory for %d BRW per-page data\n", pages);
err = -ENOMEM;
int i;
printk(KERN_INFO "OBD class driver v0.01, braam@stelias.com\n");
-
+
INIT_LIST_HEAD(&obd_types);
-
- if ( (err = misc_register(&obd_psdev)) ) {
+
+ if ((err = misc_register(&obd_psdev))) {
CERROR("cannot register %d err %d\n", OBD_MINOR, err);
- return -EIO;
+ return err;
}
for (i = 0; i < MAX_OBD_DEVICES; i++) {
{
struct obd_client * cli;
- OBD_ALLOC(cli, sizeof(struct obd_client));
+ OBD_ALLOC(cli, sizeof(*cli));
if ( !cli ) {
CERROR("no memory! (minor %d)\n", conn->oc_dev->obd_minor);
return -ENOMEM;
list_del(&(cli->cli_chain));
- OBD_FREE(cli, sizeof(struct obd_client));
+ OBD_FREE(cli, sizeof(*cli));
CDEBUG(D_INFO, "disconnect: ID %u\n", conn->oc_id);
}
request->rq_req.ost->cmd = OBD_BRW_READ;
- OBD_ALLOC(bulk, pages * sizeof(struct ptlrpc_bulk_desc *));
+ OBD_ALLOC(bulk, pages * sizeof(*bulk));
if (bulk == NULL) {
CERROR("cannot alloc bulk desc vector\n");
return -ENOMEM;
}
- memset(bulk, 0, pages * sizeof(struct ptlrpc_bulk_desc *));
+ memset(bulk, 0, pages * sizeof(*bulk));
n = 0;
ptr1 = ost_req_buf1(request->rq_req.ost);
if (bulk[n] == NULL)
continue;
kunmap(buf[n]);
- OBD_FREE(bulk[n], sizeof(struct ptlrpc_bulk_desc));
+ OBD_FREE(bulk[n], sizeof(**bulk));
n++;
}
}
- OBD_FREE(bulk, pages * sizeof(struct ptlrpc_bulk_desc *));
+ OBD_FREE(bulk, pages * sizeof(*bulk));
ptlrpc_free_req(request);
return rc;
}
int i, j;
int objcount, niocount;
char *tmp1, *tmp2, *end2;
- char *res = NULL;
int cmd;
- struct niobuf *nb, *src, *dst;
+ struct niobuf *nb, *dst, *res = NULL;
struct obd_ioobj *ioo;
struct ost_req *r = req->rq_req.ost;
CERROR("cannot pack reply\n");
RETURN(rc);
}
- OBD_ALLOC(res, sizeof(struct niobuf) * niocount);
+ OBD_ALLOC(res, sizeof(*res) * niocount);
if (res == NULL)
RETURN(-ENOMEM);
tmp2 = ost_req_buf2(r);
req->rq_rep.ost->result = obd_preprw
(cmd, &conn, objcount, (struct obd_ioobj *)tmp1,
- niocount, (struct niobuf *)tmp2, (struct niobuf *)res);
+ niocount, (struct niobuf *)tmp2, res);
if (req->rq_rep.ost->result)
GOTO(out, 0);
GOTO(out, rc);
}
- src = &((struct niobuf *)res)[i];
dst = &((struct niobuf *)tmp2)[i];
bulk->b_xid = dst->xid;
- bulk->b_buf = (void *)(unsigned long)src->addr;
+ bulk->b_buf = (void *)(unsigned long)res[i].addr;
bulk->b_buflen = PAGE_SIZE;
rc = ptlrpc_send_bulk(bulk, OST_BULK_PORTAL);
if (rc)
tmp2 = ost_req_buf2(r);
req->rq_rep.ost->result = obd_commitrw
(cmd, &conn, objcount, (struct obd_ioobj *)tmp1,
- niocount, (struct niobuf *)res);
+ niocount, res);
EXIT;
out:
if (res != NULL)
- OBD_FREE(res, sizeof(struct niobuf) * niocount);
+ OBD_FREE(res, sizeof(*res) * niocount);
if (bulk != NULL)
OBD_FREE(bulk, sizeof(*bulk));
if (bulk_vec != NULL) {
if (bulk_vec[i] != NULL)
OBD_FREE(bulk_vec[i], sizeof(*bulk));
}
- OBD_FREE(bulk_vec,
- niocount * sizeof(struct ptlrpc_bulk_desc *));
+ OBD_FREE(bulk_vec, niocount * sizeof(*bulk_vec));
}
return 0;