File 0187-super-intel-Remove-excessive-NULL-0-variable-initial.patch of Package mdadm.5365
From 594dc1b8f0ced7536d74c48436972762dd8b8f12 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Date: Wed, 9 Mar 2016 14:06:29 -0500
Subject: [PATCH 252/359] super-intel: Remove excessive NULL/0 variable
initialization
References: bsc#1081910
This removes a pile of unnecessary NULL/0 initialization of variables.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
super-intel.c | 63 +++++++++++++++++++++++++++++++----------------------------
1 file changed, 33 insertions(+), 30 deletions(-)
Index: mdadm-3.3.1/super-intel.c
===================================================================
--- mdadm-3.3.1.orig/super-intel.c
+++ mdadm-3.3.1/super-intel.c
@@ -536,7 +536,8 @@ static struct intel_hba * alloc_intel_hb
static struct intel_hba * find_intel_hba(struct intel_hba *hba, struct sys_dev *device)
{
- struct intel_hba *result=NULL;
+ struct intel_hba *result;
+
for (result = hba; result; result = result->next) {
if (result->type == device->type && strcmp(result->path, device->path) == 0)
break;
@@ -2368,12 +2369,12 @@ static struct imsm_dev *imsm_get_device_
static int load_imsm_migr_rec(struct intel_super *super, struct mdinfo *info)
{
struct mdinfo *sd;
- struct dl *dl = NULL;
+ struct dl *dl;
char nm[30];
int retval = -1;
int fd = -1;
struct imsm_dev *dev;
- struct imsm_map *map = NULL;
+ struct imsm_map *map;
int slot = -1;
/* find map under migration */
@@ -2494,7 +2495,7 @@ static int write_imsm_migr_rec(struct su
int len;
struct imsm_update_general_migration_checkpoint *u;
struct imsm_dev *dev;
- struct imsm_map *map = NULL;
+ struct imsm_map *map;
/* find map under migration */
dev = imsm_get_device_during_migration(super);
@@ -2966,7 +2967,7 @@ static void getinfo_super_imsm(struct su
* for each disk in array */
struct mdinfo *getinfo_super_disks_imsm(struct supertype *st)
{
- struct mdinfo *mddev = NULL;
+ struct mdinfo *mddev;
struct intel_super *super = st->sb;
struct imsm_disk *disk;
int count = 0;
@@ -4377,7 +4378,7 @@ get_devlist_super_block(struct md_list *
static int get_super_block(struct intel_super **super_list, char *devnm, char *devname,
int major, int minor, int keep_fd)
{
- struct intel_super*s = NULL;
+ struct intel_super *s;
char nm[32];
int dfd = -1;
int err = 0;
@@ -5355,7 +5356,7 @@ static int validate_geometry_imsm_contai
{
int fd;
unsigned long long ldsize;
- struct intel_super *super=NULL;
+ struct intel_super *super;
int rv = 0;
if (level != LEVEL_CONTAINER)
@@ -5548,10 +5549,10 @@ active_arrays_by_format(char *name, char
int dpa, int verbose)
{
struct mdstat_ent *mdstat = mdstat_read(0, 0);
- struct mdstat_ent *memb = NULL;
+ struct mdstat_ent *memb;
int count = 0;
int num = 0;
- struct md_list *dv = NULL;
+ struct md_list *dv;
int found;
for (memb = mdstat ; memb ; memb = memb->next) {
@@ -5609,7 +5610,7 @@ get_loop_devices(void)
{
int i;
struct md_list *devlist = NULL;
- struct md_list *dv = NULL;
+ struct md_list *dv;
for(i = 0; i < 12; i++) {
dv = xcalloc(1, sizeof(*dv));
@@ -5626,7 +5627,7 @@ static struct md_list*
get_devices(const char *hba_path)
{
struct md_list *devlist = NULL;
- struct md_list *dv = NULL;
+ struct md_list *dv;
struct dirent *ent;
DIR *dir;
int err = 0;
@@ -5689,7 +5690,7 @@ count_volumes_list(struct md_list *devli
{
struct md_list *tmpdev;
int count = 0;
- struct supertype *st = NULL;
+ struct supertype *st;
/* first walk the list of devices to find a consistent set
* that match the criterea, if that is possible.
@@ -5874,7 +5875,7 @@ count_volumes(struct intel_hba *hba, int
devid_list = entry->devid_list;
for (dv = devid_list; dv; dv = dv->next) {
- struct md_list *devlist = NULL;
+ struct md_list *devlist;
struct sys_dev *device = device_by_id(dv->devid);
char *hba_path;
int found = 0;
@@ -7800,7 +7801,8 @@ static int disks_overlap(struct intel_su
static struct dl *get_disk_super(struct intel_super *super, int major, int minor)
{
- struct dl *dl = NULL;
+ struct dl *dl;
+
for (dl = super->disks; dl; dl = dl->next)
if ((dl->major == major) && (dl->minor == minor))
return dl;
@@ -7809,7 +7811,7 @@ static struct dl *get_disk_super(struct
static int remove_disk_super(struct intel_super *super, int major, int minor)
{
- struct dl *prev = NULL;
+ struct dl *prev;
struct dl *dl;
prev = NULL;
@@ -7835,7 +7837,8 @@ static void imsm_delete(struct intel_sup
static int add_remove_disk_update(struct intel_super *super)
{
int check_degraded = 0;
- struct dl *disk = NULL;
+ struct dl *disk;
+
/* add/remove some spares to/from the metadata/contrainer */
while (super->disk_mgmt_list) {
struct dl *disk_cfg;
@@ -9257,8 +9260,8 @@ int save_backup_imsm(struct supertype *s
{
int rv = -1;
struct intel_super *super = st->sb;
- unsigned long long *target_offsets = NULL;
- int *targets = NULL;
+ unsigned long long *target_offsets;
+ int *targets;
int i;
struct imsm_map *map_dest = get_imsm_map(dev, MAP_0);
int new_disks = map_dest->num_members;
@@ -9385,7 +9388,7 @@ int recover_backup_imsm(struct supertype
{
struct intel_super *super = st->sb;
struct migr_record *migr_rec = super->migr_rec;
- struct imsm_map *map_dest = NULL;
+ struct imsm_map *map_dest;
struct intel_dev *id = NULL;
unsigned long long read_offset;
unsigned long long write_offset;
@@ -9508,7 +9511,7 @@ static const char *imsm_get_disk_control
strncat(disk_path, path, PATH_MAX - strlen(disk_path) - 1);
if (stat(disk_path, &st) == 0) {
struct sys_dev* hba;
- char *path=NULL;
+ char *path;
path = devt_to_devpath(st.st_rdev);
if (path == NULL)
@@ -9673,11 +9676,11 @@ static int imsm_create_metadata_update_f
{
struct intel_super *super = st->sb;
struct imsm_super *mpb = super->anchor;
- int update_memory_size = 0;
- struct imsm_update_reshape *u = NULL;
- struct mdinfo *spares = NULL;
+ int update_memory_size;
+ struct imsm_update_reshape *u;
+ struct mdinfo *spares;
int i;
- int delta_disks = 0;
+ int delta_disks;
struct mdinfo *dev;
dprintf("(enter) raid_disks = %i\n", geo->raid_disks);
@@ -9754,8 +9757,8 @@ static int imsm_create_metadata_update_f
struct imsm_update_size_change **updatep)
{
struct intel_super *super = st->sb;
- int update_memory_size = 0;
- struct imsm_update_size_change *u = NULL;
+ int update_memory_size;
+ struct imsm_update_size_change *u;
dprintf("(enter) New size = %llu\n", geo->size);
@@ -9784,8 +9787,8 @@ static int imsm_create_metadata_update_f
struct imsm_update_reshape_migration **updatep)
{
struct intel_super *super = st->sb;
- int update_memory_size = 0;
- struct imsm_update_reshape_migration *u = NULL;
+ int update_memory_size;
+ struct imsm_update_reshape_migration *u;
struct imsm_dev *dev;
int previous_level = -1;
@@ -10385,7 +10388,7 @@ static int imsm_manage_reshape(
{
int ret_val = 0;
struct intel_super *super = st->sb;
- struct intel_dev *dv = NULL;
+ struct intel_dev *dv;
struct imsm_dev *dev = NULL;
struct imsm_map *map_src;
int migr_vol_qan = 0;
@@ -10505,7 +10508,7 @@ static int imsm_manage_reshape(
* to backup alligned to source array
* [bytes]
*/
- unsigned long long next_step_filler = 0;
+ unsigned long long next_step_filler;
unsigned long long copy_length = next_step * 512;
/* allign copy area length to stripe in old geometry */