* [PATCH] Make --update=homehost work again.
@ 2013-01-30 2:26 Justin Maggard
2013-01-30 10:46 ` Paul Menzel
0 siblings, 1 reply; 3+ messages in thread
From: Justin Maggard @ 2013-01-30 2:26 UTC (permalink / raw)
To: linux-raid; +Cc: Justin Maggard
Commit 1e2b276535cea41c348292a019bdda8a58cb1679 broke homehost updating
functionality because it depended on each string comparison being done
even after we already found a match. Fix this by using a goto instead.
---
super0.c | 3 ++-
super1.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/super0.c b/super0.c
index ecb6b38..f15f1e0 100644
--- a/super0.c
+++ b/super0.c
@@ -554,10 +554,11 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
} else if (strcmp(update, "homehost") == 0 &&
homehost) {
uuid_set = 0;
- update = "uuid";
info->uuid[0] = sb->set_uuid0;
info->uuid[1] = sb->set_uuid1;
+ goto update_uuid;
} else if (strcmp(update, "uuid") == 0) {
+ update_uuid:
if (!uuid_set && homehost) {
char buf[20];
char *hash = sha1_buffer(homehost,
diff --git a/super1.c b/super1.c
index 5bb1f01..fc31948 100644
--- a/super1.c
+++ b/super1.c
@@ -987,14 +987,15 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
} else if (strcmp(update, "homehost") == 0 &&
homehost) {
char *c;
- update = "name";
c = strchr(sb->set_name, ':');
if (c)
strncpy(info->name, c+1, 31 - (c-sb->set_name));
else
strncpy(info->name, sb->set_name, 32);
info->name[32] = 0;
+ goto update_name;
} else if (strcmp(update, "name") == 0) {
+ update_name:
if (info->name[0] == 0)
sprintf(info->name, "%d", info->array.md_minor);
memset(sb->set_name, 0, sizeof(sb->set_name));
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Make --update=homehost work again.
2013-01-30 2:26 [PATCH] Make --update=homehost work again Justin Maggard
@ 2013-01-30 10:46 ` Paul Menzel
[not found] ` <CAKgsxVQQYmP_AvoJb8dkNhZEZV-A8z1-twCUx7u3+SbwUHb4ew@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Paul Menzel @ 2013-01-30 10:46 UTC (permalink / raw)
To: Justin Maggard; +Cc: linux-raid
[-- Attachment #1: Type: text/plain, Size: 2102 bytes --]
Dear Justin,
thank you for your patch.
Am Dienstag, den 29.01.2013, 18:26 -0800 schrieb Justin Maggard:
> Commit 1e2b276535cea41c348292a019bdda8a58cb1679
Please not only add the hash, but also the summary, so people not having
the Linus’ master checked out know what the original commit was about.
Also CC the original commit author so s/he can comment.
> broke homehost updating
> functionality because it depended on each string comparison being done
> even after we already found a match. Fix this by using a goto instead.
>
> ---
> super0.c | 3 ++-
> super1.c | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/super0.c b/super0.c
> index ecb6b38..f15f1e0 100644
> --- a/super0.c
> +++ b/super0.c
> @@ -554,10 +554,11 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
> } else if (strcmp(update, "homehost") == 0 &&
> homehost) {
> uuid_set = 0;
> - update = "uuid";
> info->uuid[0] = sb->set_uuid0;
> info->uuid[1] = sb->set_uuid1;
> + goto update_uuid;
> } else if (strcmp(update, "uuid") == 0) {
Would changing this from »else if …« to only »if« also solve this and
make it subjectively more clear?
> + update_uuid:
> if (!uuid_set && homehost) {
> char buf[20];
> char *hash = sha1_buffer(homehost,
> diff --git a/super1.c b/super1.c
> index 5bb1f01..fc31948 100644
> --- a/super1.c
> +++ b/super1.c
> @@ -987,14 +987,15 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
> } else if (strcmp(update, "homehost") == 0 &&
> homehost) {
> char *c;
> - update = "name";
> c = strchr(sb->set_name, ':');
> if (c)
> strncpy(info->name, c+1, 31 - (c-sb->set_name));
> else
> strncpy(info->name, sb->set_name, 32);
> info->name[32] = 0;
> + goto update_name;
> } else if (strcmp(update, "name") == 0) {
> + update_name:
> if (info->name[0] == 0)
> sprintf(info->name, "%d", info->array.md_minor);
> memset(sb->set_name, 0, sizeof(sb->set_name));
Thanks,
Paul
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Make --update=homehost work again.
[not found] ` <CAKgsxVQQYmP_AvoJb8dkNhZEZV-A8z1-twCUx7u3+SbwUHb4ew@mail.gmail.com>
@ 2013-02-06 20:16 ` Justin Maggard
0 siblings, 0 replies; 3+ messages in thread
From: Justin Maggard @ 2013-02-06 20:16 UTC (permalink / raw)
To: linux-raid
On Wed, Jan 30, 2013 at 2:46 AM, Paul Menzel <pm.debian@googlemail.com> wrote:
>
> Dear Justin,
>
>
> thank you for your patch.
>
>
> Am Dienstag, den 29.01.2013, 18:26 -0800 schrieb Justin Maggard:
> > Commit 1e2b276535cea41c348292a019bdda8a58cb1679
>
> Please not only add the hash, but also the summary, so people not having
> the Linus’ master checked out know what the original commit was about.
> Also CC the original commit author so s/he can comment.
>
Done, and resent with an updated summary.
>
> > broke homehost updating
> > functionality because it depended on each string comparison being done
> > even after we already found a match. Fix this by using a goto instead.
> >
> > ---
> > super0.c | 3 ++-
> > super1.c | 3 ++-
> > 2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/super0.c b/super0.c
> > index ecb6b38..f15f1e0 100644
> > --- a/super0.c
> > +++ b/super0.c
> > @@ -554,10 +554,11 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
> > } else if (strcmp(update, "homehost") == 0 &&
> > homehost) {
> > uuid_set = 0;
> > - update = "uuid";
> > info->uuid[0] = sb->set_uuid0;
> > info->uuid[1] = sb->set_uuid1;
> > + goto update_uuid;
> > } else if (strcmp(update, "uuid") == 0) {
>
> Would changing this from »else if …« to only »if« also solve this and
> make it subjectively more clear?
>
That would reverse what the breaking commit was trying to fix. The
only other option I can think of would be to call update_super*()
again from within itself. But I'm not sure if that would be more or
less clear that using a goto.
Thanks,
-Justin
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-06 20:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-30 2:26 [PATCH] Make --update=homehost work again Justin Maggard
2013-01-30 10:46 ` Paul Menzel
[not found] ` <CAKgsxVQQYmP_AvoJb8dkNhZEZV-A8z1-twCUx7u3+SbwUHb4ew@mail.gmail.com>
2013-02-06 20:16 ` Justin Maggard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).