[S390] dasd: check_characteristics cleanup
Sebastian Ott [Fri, 12 Jun 2009 08:26:37 +0000 (10:26 +0200)]
Fix a broken memset (sizeof pointer vs sizeof the underlying
structure) by cleaning up the involved functions.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

drivers/s390/block/dasd.c
drivers/s390/block/dasd_eckd.c
drivers/s390/block/dasd_fba.c
drivers/s390/block/dasd_int.h

index 27a1be0..35f43be 100644 (file)
@@ -2427,12 +2427,12 @@ static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device,
 
 
 int dasd_generic_read_dev_chars(struct dasd_device *device, char *magic,
-                               void **rdc_buffer, int rdc_buffer_size)
+                               void *rdc_buffer, int rdc_buffer_size)
 {
        int ret;
        struct dasd_ccw_req *cqr;
 
-       cqr = dasd_generic_build_rdc(device, *rdc_buffer, rdc_buffer_size,
+       cqr = dasd_generic_build_rdc(device, rdc_buffer, rdc_buffer_size,
                                     magic);
        if (IS_ERR(cqr))
                return PTR_ERR(cqr);
index 81f8819..c4e8181 100644 (file)
@@ -1097,20 +1097,20 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
 {
        struct dasd_eckd_private *private;
        struct dasd_block *block;
-       void *rdc_data;
        int is_known, rc;
 
        private = (struct dasd_eckd_private *) device->private;
-       if (private == NULL) {
-               private = kzalloc(sizeof(struct dasd_eckd_private),
-                                 GFP_KERNEL | GFP_DMA);
-               if (private == NULL) {
+       if (!private) {
+               private = kzalloc(sizeof(*private), GFP_KERNEL | GFP_DMA);
+               if (!private) {
                        dev_warn(&device->cdev->dev,
                                 "Allocating memory for private DASD data "
                                 "failed\n");
                        return -ENOMEM;
                }
                device->private = (void *) private;
+       } else {
+               memset(private, 0, sizeof(*private));
        }
        /* Invalidate status of initial analysis. */
        private->init_cqr_status = -1;
@@ -1161,9 +1161,8 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
                goto out_err3;
 
        /* Read Device Characteristics */
-       rdc_data = (void *) &(private->rdc_data);
-       memset(rdc_data, 0, sizeof(rdc_data));
-       rc = dasd_generic_read_dev_chars(device, "ECKD", &rdc_data, 64);
+       rc = dasd_generic_read_dev_chars(device, "ECKD", &private->rdc_data,
+                                        64);
        if (rc) {
                DBF_EVENT(DBF_WARNING,
                          "Read device characteristics failed, rc=%d for "
@@ -1183,7 +1182,7 @@ dasd_eckd_check_characteristics(struct dasd_device *device)
                 private->rdc_data.dev_model,
                 private->rdc_data.cu_type,
                 private->rdc_data.cu_model.model,
-                   private->real_cyl,
+                private->real_cyl,
                 private->rdc_data.trk_per_cyl,
                 private->rdc_data.sec_per_trk);
        return 0;
index 8912358..8c3c8ff 100644 (file)
@@ -122,20 +122,20 @@ dasd_fba_check_characteristics(struct dasd_device *device)
        struct dasd_block *block;
        struct dasd_fba_private *private;
        struct ccw_device *cdev = device->cdev;
-       void *rdc_data;
        int rc;
 
        private = (struct dasd_fba_private *) device->private;
-       if (private == NULL) {
-               private = kzalloc(sizeof(struct dasd_fba_private),
-                                 GFP_KERNEL | GFP_DMA);
-               if (private == NULL) {
+       if (!private) {
+               private = kzalloc(sizeof(*private), GFP_KERNEL | GFP_DMA);
+               if (!private) {
                        dev_warn(&device->cdev->dev,
                                 "Allocating memory for private DASD "
                                 "data failed\n");
                        return -ENOMEM;
                }
                device->private = (void *) private;
+       } else {
+               memset(private, 0, sizeof(*private));
        }
        block = dasd_alloc_block();
        if (IS_ERR(block)) {
@@ -150,8 +150,8 @@ dasd_fba_check_characteristics(struct dasd_device *device)
        block->base = device;
 
        /* Read Device Characteristics */
-       rdc_data = (void *) &(private->rdc_data);
-       rc = dasd_generic_read_dev_chars(device, "FBA ", &rdc_data, 32);
+       rc = dasd_generic_read_dev_chars(device, "FBA ", &private->rdc_data,
+                                        32);
        if (rc) {
                DBF_EVENT(DBF_WARNING, "Read device characteristics returned "
                          "error %d for device: %s",
index c1e487f..3ab69b5 100644 (file)
@@ -578,7 +578,7 @@ int dasd_generic_set_offline (struct ccw_device *cdev);
 int dasd_generic_notify(struct ccw_device *, int);
 void dasd_generic_handle_state_change(struct dasd_device *);
 
-int dasd_generic_read_dev_chars(struct dasd_device *, char *, void **, int);
+int dasd_generic_read_dev_chars(struct dasd_device *, char *, void *, int);
 char *dasd_get_sense(struct irb *);
 
 /* externals in dasd_devmap.c */