[patch] Add some asserts
Rafael Espíndola
rafael.espindola at gmail.com
Tue Dec 22 19:58:19 PST 2009
I am debugging a crash at startup in a 27 inch imac (Mobility Radeon
HD 4850). The attached patch doesn't fix it, but it makes it a lot
more obvious what is going wrong (currently the driver just
segfaults).
Cheers,
Rafael
-------------- next part --------------
diff --git a/src/radeon_atombios.c b/src/radeon_atombios.c
index c272c9a..acd0458 100644
--- a/src/radeon_atombios.c
+++ b/src/radeon_atombios.c
@@ -1432,7 +1432,7 @@ rhdAtomFirmwareInfoQuery(atomBiosHandlePtr handle,
return ATOM_SUCCESS;
}
-const int object_connector_convert[] =
+static const int object_connector_convert[] =
{ CONNECTOR_NONE,
CONNECTOR_DVI_I,
CONNECTOR_DVI_I,
@@ -1870,20 +1870,23 @@ RADEONGetATOMConnectorInfoFromBIOSObject (ScrnInfoPtr pScrn)
igp_obj = info->atomBIOS->atomDataPtr->IntegratedSystemInfo.IntegratedSystemInfo_v2;
- if (!igp_obj)
+ if (!igp_obj) {
+ assert(con_obj_id < sizeof(object_connector_convert)/sizeof(int));
info->BiosConnector[i].ConnectorType = object_connector_convert[con_obj_id];
- else {
+ } else {
if (con_obj_num == 1)
slot_config = igp_obj->ulDDISlot1Config;
else
slot_config = igp_obj->ulDDISlot2Config;
ct = (slot_config >> 16) & 0xff;
+ assert(ct < sizeof(object_connector_convert)/sizeof(int));
info->BiosConnector[i].ConnectorType = object_connector_convert[ct];
info->BiosConnector[i].connector_object_id = ct;
info->BiosConnector[i].igp_lane_info = slot_config & 0xffff;
}
} else {
+ assert(con_obj_id < sizeof(object_connector_convert)/sizeof(int));
info->BiosConnector[i].ConnectorType = object_connector_convert[con_obj_id];
info->BiosConnector[i].connector_object_id = con_obj_id;
}
diff --git a/src/radeon_output.c b/src/radeon_output.c
index 107955d..330a0b3 100644
--- a/src/radeon_output.c
+++ b/src/radeon_output.c
@@ -2946,6 +2946,7 @@ Bool RADEONSetupConnectors(ScrnInfoPtr pScrn)
} else if (conntype == CONNECTOR_DISPLAY_PORT) {
output = RADEONOutputCreate(pScrn, "DisplayPort-%d", --num_dp);
} else {
+ assert(conntype < sizeof(ConnectorTypeName)/sizeof(char *));
output = RADEONOutputCreate(pScrn,
ConnectorTypeName[conntype], 0);
}
More information about the xorg-driver-ati
mailing list