cio: Make ccw_dev_id_is_equal() more robust.
From: Cornelia Huck <[email protected]>
[S390] cio: Make ccw_dev_id_is_equal() more robust.
Using memcmp to compare ccw_dev_id implies that the whole structure (incl. padding) has always been completely initialized to sane values. Comparing the structures field by field doesn't make such assumptions.
---
include/asm-s390/cio.h | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-)
include/asm-s390/cio.h +4 -1
@@ -278,7 +278,10 @@ struct ccw_dev_id {static inline int ccw_dev_id_is_equal (struct ccw_dev_id *dev_id1,struct ccw_dev_id *dev_id2) { -return !memcmp (dev_id1, dev_id2,sizeof (struct ccw_dev_id )); +if ((dev_id1->ssid == dev_id2->ssid) && + (dev_id1->devno == dev_id2->devno)) +return 1 ; +return 0 ; }extern int diag210 (struct diag210 *addr);
On Mon, Dec 04, 2006 at 03:56:24PM +0100, Martin Schwidefsky wrote:
...
include/asm-s390/cio.h struct ccw_dev_id { · line 285
Quoted 13 lines
diff -urpN
linux-2.6/include/asm-s390/cio.hlinux-2.6-patched/include/asm-s390/cio.hinclude/asm-s390/cio.h +4
-1@@ -278,7 +278,10 @@ struct ccw_dev_id {static inline int ccw_dev_id_is_equal (struct ccw_dev_id *dev_id1,struct ccw_dev_id *dev_id2) { -return !memcmp (dev_id1, dev_id2,sizeof (struct ccw_dev_id )); +if ((dev_id1->ssid == dev_id2->ssid) && + (dev_id1->devno == dev_id2->devno)) +return 1 ; +return 0 ; }
Why not just:
return ((dev_id1->ssid == ......) && (...));
?
Josef "Jeff" Sipek.
Signature · 1 line
UNIX is user-friendly ... it's just selective about who it's friends are
Quoted 16 lines · Josef Sipek
include/asm-s390/cio.h struct ccw_dev_id { · line 285
Quoted 13 lines
diff -urpN
linux-2.6/include/asm-s390/cio.hlinux-2.6-patched/include/asm-s390/cio.hinclude/asm-s390/cio.h +4
-1@@ -278,7 +278,10 @@ struct ccw_dev_id {static inline int ccw_dev_id_is_equal (struct ccw_dev_id *dev_id1,struct ccw_dev_id *dev_id2) { -return !memcmp (dev_id1, dev_id2,sizeof (struct ccw_dev_id )); +if ((dev_id1->ssid == dev_id2->ssid) && + (dev_id1->devno == dev_id2->devno)) +return 1 ; +return 0 ; }Why not just:
Quoted 1 line
return ((
dev_id1->ssid== ......) && (...));
Yes, why not. It would be a little bit shorter. The compiler probably won't care and generate the same code..
Signature · 8 lines
blue skies, Martin. Martin Schwidefsky Linux for zSeries Development & Services IBM Deutschland Entwicklung GmbH "Reality continues to ruin my life." - Calvin.