Whamcloud - gitweb
LU-9679 all: prefer sizeof(*var) for ALLOC/FREE 61/36661/3
authorMr NeilBrown <neilb@suse.de>
Mon, 4 Nov 2019 05:38:24 +0000 (16:38 +1100)
committerOleg Drokin <green@whamcloud.com>
Fri, 20 Dec 2019 03:25:49 +0000 (03:25 +0000)
commit11f2c86650fda8f1df606686799752223339b9e9
treedd9b5f960013a9785522b1789597254534093a1c
parent04dda288a415312747ea783ef59a4a92103a3452
LU-9679 all: prefer sizeof(*var) for ALLOC/FREE

The construct
   LIBCFS_ALLOC(var, sizeof(*var));
is more obviously correct than
   LIBCFS_ALLOC(var, sizeof(struct something));
and is preferred upstream (where it is actually kzalloc
or similar of course).

When it is that simple, and there is no multiplier for
the size,
   CFS_ALLOC_PTR(var);
is even better.

The same logic applies to OBD_ALLOC(), LIBCFS_FREE(),
and OBD_FREE().

So convert allocations and frees that use sizeof(struct..)
to use one of the simpler constructs.

In mgs_write_log_mdt0, uuid is better declared as a
"struct obd_uuid *" which is a struct that contain a 'char'
array.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I8cd97c75241bbb87d15cc6b7c9ac2a7d6184d700
Reviewed-on: https://review.whamcloud.com/36661
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
14 files changed:
lnet/klnds/o2iblnd/o2iblnd.c
lnet/lnet/lib-eq.c
lnet/lnet/nidstrings.c
lnet/selftest/console.c
lustre/lfsck/lfsck_striped_dir.c
lustre/llite/pcc.c
lustre/lod/lod_object.c
lustre/mgs/mgs_llog.c
lustre/obdecho/echo_client.c
lustre/ofd/ofd_objects.c
lustre/osd-zfs/osd_oi.c
lustre/ptlrpc/client.c
lustre/ptlrpc/nrs_tbf.c
lustre/target/out_handler.c