Skip to contentSkip to conversation

scsi: Remove SCSI_BUS macro

PATCH In review Lei Li 2 participants 2 messages Nov 27, 2012

lore
Share & tools
lore

Lei Li

author
#0 lore raw

PATCH 1/1 scsi: Remove SCSI_BUS macro

As step behind Paolo's fix for RHBZ#879657 and according to the current fix in Commit b5007bc (hmp: do not crash on invalid SCSI hotplug), the macro SCSI_BUS has already been replaced to object_dynamic_cast which has been improved when try to cast to NULL value and it is also what DO_UPCAST macro does. And due to the potential Segmentation risk of SCSI_BUS, remove this macro.

---
 hw/scsi.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
hw/scsi.h +0 -1
index b8f7357..ad063e5 100644
@@ -142,7 +142,6 @@ struct SCSIBusInfo {
 };
 
 #define TYPE_SCSI_BUS "SCSI"
-#define SCSI_BUS(obj) OBJECT_CHECK(SCSIBus, (obj), TYPE_SCSI_BUS)
 
 struct SCSIBus {
     BusState qbus;
Signature · 1 line
1.7.7.6
#1 lore raw

Il 27/11/2012 06:37, Lei Li ha scritto:

Quoted 6 lines

As step behind Paolo's fix for RHBZ#879657 and according to the current fix in Commit b5007bc (hmp: do not crash on invalid SCSI hotplug), the macro SCSI_BUS has already been replaced to object_dynamic_cast which has been improved when try to cast to NULL value and it is also what DO_UPCAST macro does. And due to the potential Segmentation risk of SCSI_BUS, remove this macro.

The SCSI_BUS macro has a different purpose than object_dynamic_cast. The NULL pointer change will also work with SCSI_BUS; the assertion causes the bug in this particular case, but it is still useful in general. Whenever the assertion is fine, SCSI_BUS should be used instead of DO_UPCAST.

Paolo