2014-12-21 22:05:17

by Rickard Strandqvist

[permalink] [raw]
Subject: [PATCH] staging: lustre: lustre: llite: llite_lib.c: Removes unnecessary NULL check

Removes same unnecessary NULL check.

Signed-off-by: Rickard Strandqvist <[email protected]>
---
drivers/staging/lustre/lustre/llite/llite_lib.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 7b6b9e2..435e1ad 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -591,10 +591,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid);
}

- if (data != NULL)
- OBD_FREE_PTR(data);
- if (osfs != NULL)
- OBD_FREE_PTR(osfs);
+ OBD_FREE_PTR(data);
+ OBD_FREE_PTR(osfs);

return err;
out_root:
@@ -612,10 +610,8 @@ out_md:
obd_disconnect(sbi->ll_md_exp);
sbi->ll_md_exp = NULL;
out:
- if (data != NULL)
- OBD_FREE_PTR(data);
- if (osfs != NULL)
- OBD_FREE_PTR(osfs);
+ OBD_FREE_PTR(data);
+ OBD_FREE_PTR(osfs);
lprocfs_unregister_mountpoint(sbi);
return err;
}
--
1.7.10.4


2014-12-21 23:30:24

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] staging: lustre: lustre: llite: llite_lib.c: Removes unnecessary NULL check

On Sun, 2014-12-21 at 23:08 +0100, Rickard Strandqvist wrote:
> Removes same unnecessary NULL check.

Depending on settings, these checks are necessary:

drivers/staging/lustre/lustre/include/obd_support.h:#define POISON(ptr, c, s) memset(ptr, c, s)
[]
drivers/staging/lustre/lustre/include/obd_support.h:#define OBD_FREE_PRE(ptr, size, name) \
drivers/staging/lustre/lustre/include/obd_support.h- LASSERT(ptr); \
drivers/staging/lustre/lustre/include/obd_support.h- obd_memory_sub(size); \
drivers/staging/lustre/lustre/include/obd_support.h- CDEBUG(D_MALLOC, name " '" #ptr "': %d at %p.\n", \
drivers/staging/lustre/lustre/include/obd_support.h- (int)(size), ptr); \
drivers/staging/lustre/lustre/include/obd_support.h- POISON(ptr, 0x5a, size)
[]
drivers/staging/lustre/lustre/include/obd_support.h:#define OBD_FREE(ptr, size) \
drivers/staging/lustre/lustre/include/obd_support.h-do { \
drivers/staging/lustre/lustre/include/obd_support.h- OBD_FREE_PRE(ptr, size, "kfreed"); \
drivers/staging/lustre/lustre/include/obd_support.h- kfree(ptr); \
drivers/staging/lustre/lustre/include/obd_support.h- POISON_PTR(ptr); \
drivers/staging/lustre/lustre/include/obd_support.h-} while (0)

> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
[]
> @@ -591,10 +591,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
> get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid);
> }
>
> - if (data != NULL)
> - OBD_FREE_PTR(data);
> - if (osfs != NULL)
> - OBD_FREE_PTR(osfs);
> + OBD_FREE_PTR(data);
> + OBD_FREE_PTR(osfs);