summaryrefslogtreecommitdiff
path: root/src/mga_driver.c
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2007-02-01 13:45:18 -0800
committerIan Romanick <idr@us.ibm.com>2007-02-01 13:45:18 -0800
commit4432091b2597cf4bba09009622d247c0d8ff151f (patch)
treeb471506be144b00ab8c4b1a10bb274dc2a326ce4 /src/mga_driver.c
parent3a47132af4dfab420e3c35d7d100dd93fb7bf9c6 (diff)
Ensure the result of MGAMapMem is checked.
Add GCC warn_unused_result attribute to MGAMapMem. Add a check of the return value to one place that was missing it (in MGACountRam), and check the return of that function.
Diffstat (limited to 'src/mga_driver.c')
-rw-r--r--src/mga_driver.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mga_driver.c b/src/mga_driver.c
index 1a72e76..4f86b9c 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -129,8 +129,14 @@ static void MGAFreeScreen(int scrnIndex, int flags);
static ModeStatus MGAValidMode(int scrnIndex, DisplayModePtr mode,
Bool verbose, int flags);
+#if ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ >= 4)
+#define __must_check __attribute__((warn_unused_result))
+#else
+#define __must_check /* */
+#endif
+
/* Internally used functions */
-static Bool MGAMapMem(ScrnInfoPtr pScrn);
+static Bool __must_check MGAMapMem(ScrnInfoPtr pScrn);
static Bool MGAUnmapMem(ScrnInfoPtr pScrn);
static void MGASave(ScrnInfoPtr pScrn);
static void MGARestore(ScrnInfoPtr pScrn);
@@ -820,7 +826,10 @@ MGACountRam(ScrnInfoPtr pScrn)
int i;
pMga->FbMapSize = ProbeSize * 1024;
- MGAMapMem(pScrn);
+ if (!MGAMapMem(pScrn)) {
+ return 0;
+ }
+
base = pMga->FbBase;
/* turn MGA mode on - enable linear frame buffer (CRTCEXT3) */
@@ -1796,6 +1805,12 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pScrn->videoRam = MGACountRam(pScrn);
}
+ if (pScrn->videoRam == 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Unable to detect video RAM.\n");
+ return FALSE;
+ }
+
if (pMga->DualHeadEnabled) {
/* This takes gives either half or 8 meg to the second head
* whichever is less. */