mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nigel Croxon <ncroxon@redhat.com>
To: song@kernel.org, yukuai1@huaweicloud.com,
	Zhang Shurong <zhang_shurong@foxmail.com>
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	yukuai3@huawei.com
Subject: [PATCH] raid1: fix error: ISO C90 forbids mixed declarations
Date: Sat, 9 Sep 2023 07:53:10 -0400	[thread overview]
Message-ID: <46d929d0-2aab-4cf2-b2bf-338963e8ba5a@redhat.com> (raw)

There is a compile error when this commit is added:
md: raid1: fix potential OOB in raid1_remove_disk()

drivers/md/raid1.c: In function 'raid1_remove_disk':
drivers/md/raid1.c:1844:9: error: ISO C90 forbids mixed declarations
and code [-Werror=declaration-after-statement]
1844 |         struct raid1_info *p = conf->mirrors + number;
      |         ^~~~~~

That's because the new code was inserted before the struct.
The change is move the struct command above this commit.

Fixes: md: raid1: fix potential OOB in raid1_remove_disk()
commit 8b0472b50bcf

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
---
  drivers/md/raid1.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index a5453b126aab..4f1483bb708b 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1846,11 +1846,11 @@ static int raid1_remove_disk(struct mddev 
*mddev, struct md_rdev *rdev)
      int err = 0;
      int number = rdev->raid_disk;

+    struct raid1_info *p = conf->mirrors + number;
+
      if (unlikely(number >= conf->raid_disks))
          goto abort;

-    struct raid1_info *p = conf->mirrors + number;
-
      if (rdev != p->rdev)
          p = conf->mirrors + conf->raid_disks + number;

-- 
2.31.1


             reply	other threads:[~2023-09-09 11:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-09 11:53 Nigel Croxon [this message]
2023-09-11 21:42 ` Song Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46d929d0-2aab-4cf2-b2bf-338963e8ba5a@redhat.com \
    --to=ncroxon@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yukuai1@huaweicloud.com \
    --cc=yukuai3@huawei.com \
    --cc=zhang_shurong@foxmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®