]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
ath10k: sdio: remove redundant check in for loop
authorAlex Dewar <alex.dewar90@gmail.com>
Wed, 28 Oct 2020 13:54:30 +0000 (15:54 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 6 Nov 2020 06:35:41 +0000 (08:35 +0200)
The for loop checks whether cur_section is NULL on every iteration, but
we know it can never be NULL as there is another check towards the
bottom of the loop body. Refactor to avoid this unnecessary check.

Also, increment the variable i inline for clarity

Addresses-Coverity: 1496984 ("Null pointer dereferences)
Suggested-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200916165748.20927-1-alex.dewar90@gmail.com
drivers/net/wireless/ath/ath10k/sdio.c

index 59043ec44ca372b3275df15a87fd6e3daccf89ba..3e09802cfb6e60a53d1eda011dc1cb97856340fe 100644 (file)
@@ -2307,8 +2307,8 @@ static int ath10k_sdio_dump_memory_section(struct ath10k *ar,
        }
 
        count = 0;
-
-       for (i = 0; cur_section; i++) {
+       i = 0;
+       for (; cur_section; cur_section = next_section) {
                section_size = cur_section->end - cur_section->start;
 
                if (section_size <= 0) {
@@ -2318,7 +2318,7 @@ static int ath10k_sdio_dump_memory_section(struct ath10k *ar,
                        break;
                }
 
-               if ((i + 1) == mem_region->section_table.size) {
+               if (++i == mem_region->section_table.size) {
                        /* last section */
                        next_section = NULL;
                        skip_size = 0;
@@ -2361,12 +2361,6 @@ static int ath10k_sdio_dump_memory_section(struct ath10k *ar,
                }
 
                count += skip_size;
-
-               if (!next_section)
-                       /* this was the last section */
-                       break;
-
-               cur_section = next_section;
        }
 
        return count;