md-cluster: Fix warnings when build with CF=-D__CHECK_ENDIAN__
authorGuoqing Jiang <gqjiang@suse.com>
Fri, 16 Oct 2015 07:40:22 +0000 (15:40 +0800)
committerNeilBrown <neilb@suse.com>
Sat, 24 Oct 2015 06:16:18 +0000 (17:16 +1100)
This patches fixes sparse warnings like incorrect type in assignment
(different base types), cast to restricted __le64.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>
drivers/md/md-cluster.c

index aad5e7cda523e1cd925d77e8c6f08df32517ce23..f42162c49e3bdc0a6bde8c4d36456294e6b77e3d 100644 (file)
@@ -81,13 +81,13 @@ enum msg_type {
 };
 
 struct cluster_msg {
-       int type;
-       int slot;
+       __le32 type;
+       __le32 slot;
        /* TODO: Unionize this for smaller footprint */
-       sector_t low;
-       sector_t high;
+       __le64 low;
+       __le64 high;
        char uuid[16];
-       int raid_slot;
+       __le32 raid_slot;
 };
 
 static void sync_ast(void *arg)
@@ -215,7 +215,7 @@ static struct suspend_info *read_resync_info(struct mddev *mddev, struct dlm_loc
        dlm_lock_sync(lockres, DLM_LOCK_CR);
        memcpy(&ri, lockres->lksb.sb_lvbptr, sizeof(struct resync_info));
        hi = le64_to_cpu(ri.hi);
-       if (ri.hi > 0) {
+       if (hi > 0) {
                s = kzalloc(sizeof(struct suspend_info), GFP_KERNEL);
                if (!s)
                        goto out;
@@ -465,13 +465,14 @@ static void process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
        if (WARN(mddev->cluster_info->slot_number - 1 == le32_to_cpu(msg->slot),
                "node %d received it's own msg\n", le32_to_cpu(msg->slot)))
                return;
-       switch (msg->type) {
+       switch (le32_to_cpu(msg->type)) {
        case METADATA_UPDATED:
                process_metadata_update(mddev, msg);
                break;
        case RESYNCING:
-               process_suspend_info(mddev, msg->slot,
-                               msg->low, msg->high);
+               process_suspend_info(mddev, le32_to_cpu(msg->slot),
+                                    le64_to_cpu(msg->low),
+                                    le64_to_cpu(msg->high));
                break;
        case NEWDISK:
                process_add_new_disk(mddev, msg);
@@ -483,7 +484,7 @@ static void process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
                process_readd_disk(mddev, msg);
                break;
        case BITMAP_NEEDS_SYNC:
-               __recover_slot(mddev, msg->slot);
+               __recover_slot(mddev, le32_to_cpu(msg->slot));
                break;
        default:
                pr_warn("%s:%d Received unknown message from %d\n",