* [PATCH 0/3] Remove dead code
@ 2011-10-31 13:53 Jes.Sorensen
2011-10-31 13:53 ` [PATCH 1/3] conf_match(): " Jes.Sorensen
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jes.Sorensen @ 2011-10-31 13:53 UTC (permalink / raw)
To: neilb; +Cc: linux-raid, dledford
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Hi,
These three patches remove a couple of chunks of dead code. They were
pointed out by running Coverity.
The dead code isn't a big issue in itself, but removing it will remove
noise when looking through the audit logs.
Cheers,
Jes
Jes Sorensen (3):
conf_match(): Remove dead code
conf_watch(): More dead code removal
Kill(): Remove redundant check and dead code
Kill.c | 6 +-----
config.c | 35 -----------------------------------
2 files changed, 1 insertions(+), 40 deletions(-)
--
1.7.6.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] conf_match(): Remove dead code
2011-10-31 13:53 [PATCH 0/3] Remove dead code Jes.Sorensen
@ 2011-10-31 13:53 ` Jes.Sorensen
2011-11-01 2:33 ` NeilBrown
2011-10-31 13:53 ` [PATCH 2/3] conf_watch(): More dead code removal Jes.Sorensen
2011-10-31 13:53 ` [PATCH 3/3] Kill(): Remove redundant check and dead code Jes.Sorensen
2 siblings, 1 reply; 6+ messages in thread
From: Jes.Sorensen @ 2011-10-31 13:53 UTC (permalink / raw)
To: neilb; +Cc: linux-raid, dledford
From: Jes Sorensen <Jes.Sorensen@redhat.com>
devname is always NULL, hence if () statement will always fail.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
config.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
diff --git a/config.c b/config.c
index c0a6baa..b57ba50 100644
--- a/config.c
+++ b/config.c
@@ -1023,7 +1023,6 @@ struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st)
{
struct mddev_ident *array_list, *match;
int verbose = 0;
- char *devname = NULL;
array_list = conf_get_ident(NULL);
match = NULL;
for (; array_list; array_list = array_list->next) {
@@ -1044,14 +1043,6 @@ struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st)
array_list->devname);
continue;
}
- if (array_list->devices && devname &&
- !match_oneof(array_list->devices, devname)) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": Not a listed device for %s.\n",
- array_list->devname);
- continue;
- }
if (array_list->super_minor != UnSet &&
array_list->super_minor != info->array.md_minor) {
if (verbose >= 2 && array_list->devname)
--
1.7.6.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] conf_watch(): More dead code removal
2011-10-31 13:53 [PATCH 0/3] Remove dead code Jes.Sorensen
2011-10-31 13:53 ` [PATCH 1/3] conf_match(): " Jes.Sorensen
@ 2011-10-31 13:53 ` Jes.Sorensen
2011-10-31 13:53 ` [PATCH 3/3] Kill(): Remove redundant check and dead code Jes.Sorensen
2 siblings, 0 replies; 6+ messages in thread
From: Jes.Sorensen @ 2011-10-31 13:53 UTC (permalink / raw)
To: neilb; +Cc: linux-raid, dledford
From: Jes Sorensen <Jes.Sorensen@redhat.com>
verbose is always zero, hence anything checking for verbose > 0 will
always fail.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
config.c | 26 --------------------------
1 files changed, 0 insertions(+), 26 deletions(-)
diff --git a/config.c b/config.c
index b57ba50..4e6165e 100644
--- a/config.c
+++ b/config.c
@@ -1022,57 +1022,31 @@ int conf_name_is_free(char *name)
struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st)
{
struct mddev_ident *array_list, *match;
- int verbose = 0;
array_list = conf_get_ident(NULL);
match = NULL;
for (; array_list; array_list = array_list->next) {
if (array_list->uuid_set &&
same_uuid(array_list->uuid, info->uuid, st->ss->swapuuid)
== 0) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": UUID differs from %s.\n",
- array_list->devname);
continue;
}
if (array_list->name[0] &&
strcasecmp(array_list->name, info->name) != 0) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": Name differs from %s.\n",
- array_list->devname);
continue;
}
if (array_list->super_minor != UnSet &&
array_list->super_minor != info->array.md_minor) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": Different super-minor to %s.\n",
- array_list->devname);
continue;
}
if (!array_list->uuid_set &&
!array_list->name[0] &&
!array_list->devices &&
array_list->super_minor == UnSet) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": %s doesn't have any identifying information.\n",
- array_list->devname);
continue;
}
/* FIXME, should I check raid_disks and level too?? */
if (match) {
- if (verbose >= 0) {
- if (match->devname && array_list->devname)
- fprintf(stderr, Name
- ": we match both %s and %s - cannot decide which to use.\n",
- match->devname, array_list->devname);
- else
- fprintf(stderr, Name
- ": multiple lines in mdadm.conf match\n");
- }
return NULL;
}
match = array_list;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] Kill(): Remove redundant check and dead code
2011-10-31 13:53 [PATCH 0/3] Remove dead code Jes.Sorensen
2011-10-31 13:53 ` [PATCH 1/3] conf_match(): " Jes.Sorensen
2011-10-31 13:53 ` [PATCH 2/3] conf_watch(): More dead code removal Jes.Sorensen
@ 2011-10-31 13:53 ` Jes.Sorensen
2 siblings, 0 replies; 6+ messages in thread
From: Jes.Sorensen @ 2011-10-31 13:53 UTC (permalink / raw)
To: neilb; +Cc: linux-raid, dledford
From: Jes Sorensen <Jes.Sorensen@redhat.com>
No need to check for (force && rv >=2) since we just set rv = 0 in
that case.
In addition remove dead code path that checks rv != 0 inside code that
is only run for rv == 0.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
Kill.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/Kill.c b/Kill.c
index b841a5b..01d884f 100644
--- a/Kill.c
+++ b/Kill.c
@@ -63,7 +63,7 @@ int Kill(char *dev, struct supertype *st, int force, int quiet, int noexcl)
rv = st->ss->load_super(st, fd, dev);
if (force && rv >= 2)
rv = 0; /* ignore bad data in superblock */
- if (rv== 0 || (force && rv >= 2)) {
+ if (rv == 0) {
st->ss->free_super(st);
st->ss->init_super(st, NULL, 0, "", NULL, NULL);
if (st->ss->store_super(st, fd)) {
@@ -71,10 +71,6 @@ int Kill(char *dev, struct supertype *st, int force, int quiet, int noexcl)
fprintf(stderr, Name ": Could not zero superblock on %s\n",
dev);
rv = 1;
- } else if (rv) {
- if (!quiet)
- fprintf(stderr, Name ": superblock zeroed anyway\n");
- rv = 0;
}
}
close(fd);
--
1.7.6.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] conf_match(): Remove dead code
2011-10-31 13:53 ` [PATCH 1/3] conf_match(): " Jes.Sorensen
@ 2011-11-01 2:33 ` NeilBrown
2011-11-01 6:22 ` Jes Sorensen
0 siblings, 1 reply; 6+ messages in thread
From: NeilBrown @ 2011-11-01 2:33 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: linux-raid, dledford
[-- Attachment #1: Type: text/plain, Size: 1724 bytes --]
On Mon, 31 Oct 2011 14:53:52 +0100 Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> devname is always NULL, hence if () statement will always fail.
>
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> ---
> config.c | 9 ---------
> 1 files changed, 0 insertions(+), 9 deletions(-)
>
> diff --git a/config.c b/config.c
> index c0a6baa..b57ba50 100644
> --- a/config.c
> +++ b/config.c
> @@ -1023,7 +1023,6 @@ struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st)
> {
> struct mddev_ident *array_list, *match;
> int verbose = 0;
> - char *devname = NULL;
> array_list = conf_get_ident(NULL);
> match = NULL;
> for (; array_list; array_list = array_list->next) {
> @@ -1044,14 +1043,6 @@ struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st)
> array_list->devname);
> continue;
> }
> - if (array_list->devices && devname &&
> - !match_oneof(array_list->devices, devname)) {
> - if (verbose >= 2 && array_list->devname)
> - fprintf(stderr, Name
> - ": Not a listed device for %s.\n",
> - array_list->devname);
> - continue;
> - }
> if (array_list->super_minor != UnSet &&
> array_list->super_minor != info->array.md_minor) {
> if (verbose >= 2 && array_list->devname)
Hi Jes,
thanks for these 3 patches.
In each case I chose to remove different code :-)
In this case search_mdstat was nearly identical to conf_match, but uses the
bits you removed. So I unified the two.
For the 'Kill' fix, I removed a different test on 'force' so that the printf
that you removed could not actually be reached.
Thanks,
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] conf_match(): Remove dead code
2011-11-01 2:33 ` NeilBrown
@ 2011-11-01 6:22 ` Jes Sorensen
0 siblings, 0 replies; 6+ messages in thread
From: Jes Sorensen @ 2011-11-01 6:22 UTC (permalink / raw)
To: NeilBrown; +Cc: linux-raid, dledford
On 11/01/11 03:33, NeilBrown wrote:
> Hi Jes,
> thanks for these 3 patches.
> In each case I chose to remove different code :-)
>
> In this case search_mdstat was nearly identical to conf_match, but uses the
> bits you removed. So I unified the two.
>
> For the 'Kill' fix, I removed a different test on 'force' so that the printf
> that you removed could not actually be reached.
That is great! There are times where I am not quite sure what the
original intention of the code was, so I am just glad the patches is
proving to be of use :)
Cheers,
Jes
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-11-01 6:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-31 13:53 [PATCH 0/3] Remove dead code Jes.Sorensen
2011-10-31 13:53 ` [PATCH 1/3] conf_match(): " Jes.Sorensen
2011-11-01 2:33 ` NeilBrown
2011-11-01 6:22 ` Jes Sorensen
2011-10-31 13:53 ` [PATCH 2/3] conf_watch(): More dead code removal Jes.Sorensen
2011-10-31 13:53 ` [PATCH 3/3] Kill(): Remove redundant check and dead code Jes.Sorensen
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).