* [2.6 patch] drivers/ieee1394/csr1212.c: remove dead code
@ 2005-11-20 23:10 Adrian Bunk
2005-11-21 19:45 ` Stefan Richter
0 siblings, 1 reply; 7+ messages in thread
From: Adrian Bunk @ 2005-11-20 23:10 UTC (permalink / raw)
To: bcollins, scjody; +Cc: linux1394-devel, linux-kernel
The Coverity checker spotted that the same check was already done above.
Signed-off-by: Adrian Bunk <bunk@stusta.de>
--- linux-2.6.15-rc1-mm2-full/drivers/ieee1394/csr1212.c.old 2005-11-20 22:50:14.000000000 +0100
+++ linux-2.6.15-rc1-mm2-full/drivers/ieee1394/csr1212.c 2005-11-20 22:50:36.000000000 +0100
@@ -1616,12 +1616,8 @@
* and make cache regions for them */
for (dentry = csr->root_kv->value.directory.dentries_head;
dentry; dentry = dentry->next) {
- if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) {
+ if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM)
csr1212_get_keyval(csr, dentry->kv);
-
- if (ret != CSR1212_SUCCESS)
- return ret;
- }
}
return CSR1212_SUCCESS;
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [2.6 patch] drivers/ieee1394/csr1212.c: remove dead code
2005-11-20 23:10 [2.6 patch] drivers/ieee1394/csr1212.c: remove dead code Adrian Bunk
@ 2005-11-21 19:45 ` Stefan Richter
2005-11-21 21:41 ` Jody McIntyre
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Richter @ 2005-11-21 19:45 UTC (permalink / raw)
To: Adrian Bunk; +Cc: bcollins, scjody, linux1394-devel, linux-kernel
Adrian Bunk wrote:
> The Coverity checker spotted that the same check was already done above.
>
>
> Signed-off-by: Adrian Bunk <bunk@stusta.de>
>
> --- linux-2.6.15-rc1-mm2-full/drivers/ieee1394/csr1212.c.old 2005-11-20 22:50:14.000000000 +0100
> +++ linux-2.6.15-rc1-mm2-full/drivers/ieee1394/csr1212.c 2005-11-20 22:50:36.000000000 +0100
> @@ -1616,12 +1616,8 @@
> * and make cache regions for them */
> for (dentry = csr->root_kv->value.directory.dentries_head;
> dentry; dentry = dentry->next) {
> - if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) {
> + if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM)
> csr1212_get_keyval(csr, dentry->kv);
> -
> - if (ret != CSR1212_SUCCESS)
> - return ret;
> - }
> }
>
> return CSR1212_SUCCESS;
Yes, this is dead code. But when I looked through csr1212_parse_csr()
which you are patching here, I wondered why the return code of
csr1212_get_keyval() is never checked there. csr1212_get_keyval()
performs memory allocations and bus reads. Shouldn't both calls of
csr1212_get_keyval() be enclosed in something like this?
if(!csr1212_get_keyval(...))
return ~ CSR1212_SUCCESS;
Or for better yet, we should use _csr1212_read_keyval() instead so that
we get more sensible error codes.
--
Stefan Richter
-=====-=-=-= =-== =-=-=
http://arcgraph.de/sr/
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [2.6 patch] drivers/ieee1394/csr1212.c: remove dead code
2005-11-21 19:45 ` Stefan Richter
@ 2005-11-21 21:41 ` Jody McIntyre
2005-11-21 22:02 ` Stefan Richter
0 siblings, 1 reply; 7+ messages in thread
From: Jody McIntyre @ 2005-11-21 21:41 UTC (permalink / raw)
To: Stefan Richter; +Cc: Adrian Bunk, bcollins, linux1394-devel, linux-kernel
On Mon, Nov 21, 2005 at 08:45:29PM +0100, Stefan Richter wrote:
> Or for better yet, we should use _csr1212_read_keyval() instead so that
> we get more sensible error codes.
Good idea. How about:
csr1212: check results of keyval reads
csr1212_parse_csr() did not properly check return values when reading
keyvals. Fix this by using _csr1212_read_keyval() instead of
csr1212_get_keyval() and checking the return code.
Signed-off-by: Jody McIntyre <scjody@steamballoon.com>
Index: linux/drivers/ieee1394/csr1212.c
===================================================================
--- linux.orig/drivers/ieee1394/csr1212.c
+++ linux/drivers/ieee1394/csr1212.c
@@ -1610,16 +1610,16 @@ int csr1212_parse_csr(struct csr1212_csr
csr->root_kv->valid = 0;
csr->root_kv->next = csr->root_kv;
csr->root_kv->prev = csr->root_kv;
- csr1212_get_keyval(csr, csr->root_kv);
+ if (_csr1212_read_keyval(csr, csr->root_kv) != CSR1212_SUCCESS)
+ return ret;
/* Scan through the Root directory finding all extended ROM regions
* and make cache regions for them */
for (dentry = csr->root_kv->value.directory.dentries_head;
dentry; dentry = dentry->next) {
if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) {
- csr1212_get_keyval(csr, dentry->kv);
-
- if (ret != CSR1212_SUCCESS)
+ if (_csr1212_read_keyval(csr, dentry->kv) !=
+ CSR1212_SUCCESS)
return ret;
}
}
> --
> Stefan Richter
> -=====-=-=-= =-== =-=-=
> http://arcgraph.de/sr/
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
> Register for a JBoss Training Course. Free Certification Exam
> for All Training Attendees Through End of 2005. For more info visit:
> http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
> _______________________________________________
> mailing list linux1394-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux1394-devel
--
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [2.6 patch] drivers/ieee1394/csr1212.c: remove dead code
2005-11-21 21:41 ` Jody McIntyre
@ 2005-11-21 22:02 ` Stefan Richter
2005-11-21 22:23 ` Jody McIntyre
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Stefan Richter @ 2005-11-21 22:02 UTC (permalink / raw)
To: Jody McIntyre; +Cc: Adrian Bunk, bcollins, linux1394-devel, linux-kernel
Jody McIntyre wrote:
> --- linux.orig/drivers/ieee1394/csr1212.c
> +++ linux/drivers/ieee1394/csr1212.c
> @@ -1610,16 +1610,16 @@ int csr1212_parse_csr(struct csr1212_csr
> csr->root_kv->valid = 0;
> csr->root_kv->next = csr->root_kv;
> csr->root_kv->prev = csr->root_kv;
> - csr1212_get_keyval(csr, csr->root_kv);
> + if (_csr1212_read_keyval(csr, csr->root_kv) != CSR1212_SUCCESS)
> + return ret;
- csr1212_get_keyval(csr, csr->root_kv);
+ ret = _csr1212_read_keyval(csr, csr->root_kv);
+ if (ret != CSR1212_SUCCESS)
+ return ret;
>
> /* Scan through the Root directory finding all extended ROM regions
> * and make cache regions for them */
> for (dentry = csr->root_kv->value.directory.dentries_head;
> dentry; dentry = dentry->next) {
> if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) {
> - csr1212_get_keyval(csr, dentry->kv);
> -
> - if (ret != CSR1212_SUCCESS)
> + if (_csr1212_read_keyval(csr, dentry->kv) !=
> + CSR1212_SUCCESS)
> return ret;
> }
> }
>
- if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) {
- csr1212_get_keyval(csr, dentry->kv);
-
+ if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM &&
+ !dentry->kv->valid) {
+ ret = _csr1212_read_keyval(csr, dentry->kv);
if (ret != CSR1212_SUCCESS)
return ret;
}
Although I am not quite sure if the check for !valid is really required.
It certainly cannot hurt.
--
Stefan Richter
-=====-=-=-= =-== =-=-=
http://arcgraph.de/sr/
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [2.6 patch] drivers/ieee1394/csr1212.c: remove dead code
2005-11-21 22:02 ` Stefan Richter
@ 2005-11-21 22:23 ` Jody McIntyre
2005-11-21 22:24 ` [PATCH 1/2] csr1212: check results of keyval reads Jody McIntyre
2005-11-21 22:28 ` [PATCH 2/2] csr1212: add check for !valid Jody McIntyre
2 siblings, 0 replies; 7+ messages in thread
From: Jody McIntyre @ 2005-11-21 22:23 UTC (permalink / raw)
To: Stefan Richter; +Cc: Adrian Bunk, bcollins, linux1394-devel, linux-kernel
On Mon, Nov 21, 2005 at 11:02:10PM +0100, Stefan Richter wrote:
> - if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) {
> - csr1212_get_keyval(csr, dentry->kv);
> -
> + if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM &&
> + !dentry->kv->valid) {
> + ret = _csr1212_read_keyval(csr, dentry->kv);
> if (ret != CSR1212_SUCCESS)
> return ret;
> }
Duh :/
> Although I am not quite sure if the check for !valid is really required.
> It certainly cannot hurt.
That's a separate issue so it should be a separate patch. I'll do it
though.
Cheers,
Jody
> --
> Stefan Richter
> -=====-=-=-= =-== =-=-=
> http://arcgraph.de/sr/
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] csr1212: check results of keyval reads
2005-11-21 22:02 ` Stefan Richter
2005-11-21 22:23 ` Jody McIntyre
@ 2005-11-21 22:24 ` Jody McIntyre
2005-11-21 22:28 ` [PATCH 2/2] csr1212: add check for !valid Jody McIntyre
2 siblings, 0 replies; 7+ messages in thread
From: Jody McIntyre @ 2005-11-21 22:24 UTC (permalink / raw)
To: Stefan Richter; +Cc: Adrian Bunk, bcollins, linux1394-devel, linux-kernel
csr1212_parse_csr() did not properly check return values when reading
keyvals. Fix this by using _csr1212_read_keyval() instead of
csr1212_get_keyval() and checking the return code.
Signed-off-by: Jody McIntyre <scjody@steamballoon.com>
Index: linux/drivers/ieee1394/csr1212.c
===================================================================
--- linux.orig/drivers/ieee1394/csr1212.c
+++ linux/drivers/ieee1394/csr1212.c
@@ -1610,15 +1610,16 @@ int csr1212_parse_csr(struct csr1212_csr
csr->root_kv->valid = 0;
csr->root_kv->next = csr->root_kv;
csr->root_kv->prev = csr->root_kv;
- csr1212_get_keyval(csr, csr->root_kv);
+ ret = _csr1212_read_keyval(csr, csr->root_kv);
+ if (ret != CSR1212_SUCCESS)
+ return ret;
/* Scan through the Root directory finding all extended ROM regions
* and make cache regions for them */
for (dentry = csr->root_kv->value.directory.dentries_head;
dentry; dentry = dentry->next) {
if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) {
- csr1212_get_keyval(csr, dentry->kv);
-
+ ret = _csr1212_read_keyval(csr, dentry->kv);
if (ret != CSR1212_SUCCESS)
return ret;
}
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 2/2] csr1212: add check for !valid
2005-11-21 22:02 ` Stefan Richter
2005-11-21 22:23 ` Jody McIntyre
2005-11-21 22:24 ` [PATCH 1/2] csr1212: check results of keyval reads Jody McIntyre
@ 2005-11-21 22:28 ` Jody McIntyre
2 siblings, 0 replies; 7+ messages in thread
From: Jody McIntyre @ 2005-11-21 22:28 UTC (permalink / raw)
To: Stefan Richter; +Cc: Adrian Bunk, bcollins, linux1394-devel, linux-kernel
Don't read the keyval if there's already a valid one in place. May not be
necessary but shouldn't hurt.
Signed-off-by: Jody McIntyre <scjdy@steamballoon.com>
Index: linux/drivers/ieee1394/csr1212.c
===================================================================
--- linux.orig/drivers/ieee1394/csr1212.c
+++ linux/drivers/ieee1394/csr1212.c
@@ -1618,7 +1618,8 @@ int csr1212_parse_csr(struct csr1212_csr
* and make cache regions for them */
for (dentry = csr->root_kv->value.directory.dentries_head;
dentry; dentry = dentry->next) {
- if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) {
+ if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM &&
+ !dentry->kv->valid) {
ret = _csr1212_read_keyval(csr, dentry->kv);
if (ret != CSR1212_SUCCESS)
return ret;
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-11-21 22:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-20 23:10 [2.6 patch] drivers/ieee1394/csr1212.c: remove dead code Adrian Bunk
2005-11-21 19:45 ` Stefan Richter
2005-11-21 21:41 ` Jody McIntyre
2005-11-21 22:02 ` Stefan Richter
2005-11-21 22:23 ` Jody McIntyre
2005-11-21 22:24 ` [PATCH 1/2] csr1212: check results of keyval reads Jody McIntyre
2005-11-21 22:28 ` [PATCH 2/2] csr1212: add check for !valid Jody McIntyre
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.