]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
staging: unisys: visorbus: clean up initializations
authorDavid Kershner <david.kershner@unisys.com>
Wed, 27 Sep 2017 17:14:19 +0000 (13:14 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Sep 2017 09:17:13 +0000 (11:17 +0200)
Don't compute value of offset during initialization. Assigning a value to
offset should happen after we have verified all of its components.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Reviewed-by: Tim Sell <timothy.sell@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/visorbus/visorbus_main.c

index 589dff3afe618adeaa91f4da20c0ae515db1be23..ea124991cbdd954166b0317b3c386f4adc04d944 100644 (file)
@@ -743,11 +743,12 @@ static void write_vbus_chp_info(struct visorchannel *chan,
                                struct visor_vbus_headerinfo *hdr_info,
                                struct visor_vbus_deviceinfo *info)
 {
-       int off = sizeof(struct channel_header) + hdr_info->chp_info_offset;
+       int off;
 
        if (hdr_info->chp_info_offset == 0)
                return;
 
+       off = sizeof(struct channel_header) + hdr_info->chp_info_offset;
        visorchannel_write(chan, off, info, sizeof(*info));
 }
 
@@ -768,11 +769,11 @@ static void write_vbus_bus_info(struct visorchannel *chan,
                                struct visor_vbus_headerinfo *hdr_info,
                                struct visor_vbus_deviceinfo *info)
 {
-       int off = sizeof(struct channel_header) + hdr_info->bus_info_offset;
+       int off;
 
        if (hdr_info->bus_info_offset == 0)
                return;
-
+       off = sizeof(struct channel_header) + hdr_info->bus_info_offset;
        visorchannel_write(chan, off, info, sizeof(*info));
 }
 
@@ -795,13 +796,12 @@ static void write_vbus_dev_info(struct visorchannel *chan,
                                struct visor_vbus_deviceinfo *info,
                                unsigned int devix)
 {
-       int off =
-           (sizeof(struct channel_header) + hdr_info->dev_info_offset) +
-           (hdr_info->device_info_struct_bytes * devix);
+       int off;
 
        if (hdr_info->dev_info_offset == 0)
                return;
-
+       off = (sizeof(struct channel_header) + hdr_info->dev_info_offset) +
+             (hdr_info->device_info_struct_bytes * devix);
        visorchannel_write(chan, off, info, sizeof(*info));
 }