Bug 23010

Summary: video-xgi: compile error in xgi_driver when opening framebuffer
Product: xorg Reporter: Gaetan Nadon <memsize>
Component: Driver/XGIAssignee: Gaetan Nadon <memsize>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium Keywords: janitor
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
[PATCH] video-xgi: fix incorrect function call to open() #23010 none

Description Gaetan Nadon 2009-07-28 16:39:21 UTC
Compiling on AMD64:
In function ‘open’,
    inlined from ‘XGIPreInit’ at xgi_driver.c:2589:
/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments

The opffending line is:
        if ((fd = open("/dev/fb", 'r')) != -1) {

The open function call signature is:
open (__const char *__path, int __oflag, ...)

The second parameter 'r' is of type 'char' and is compatible with 'int'. The octal value of 'r' is 0162 or 001.110.010 and the O_CREAT flag octal value on Linux is 0100 or 001.000.000. There is a match, the open call is interpreted as a "create" and requires a 3rd parameter which is missing.

Browing code, a framebuffer is typically accessed this way: FrameBufferFD = open("/dev/fb", O_RDWR); or O_RDONLY.
Comment 1 Gaetan Nadon 2009-07-28 17:22:13 UTC
I found that this has been fixed in the Pardus project some times ago.

--- xf86-video-xgi-1.5.0/src/xgi_driver.c.orig	2008-01-19 20:28:22.000000000 +0000
+++ xf86-video-xgi-1.5.0/src/xgi_driver.c	2008-01-19 20:28:55.000000000 +0000
@@ -2504,7 +2504,7 @@
 
     FbDevExist = FALSE;
     if (pXGI->Chipset != PCI_CHIP_XGIXG20) {
-        if ((fd = open("/dev/fb", 'r')) != -1) {
+        if ((fd = open("/dev/fb", O_RDONLY)) != -1) {
             PDEBUG(ErrorF("--- open /dev/fb....   \n"));
             ioctl(fd, FBIOGET_FSCREENINFO, &fix);
             if (fix.accel == FB_ACCEL_XGI_GLAMOUR) {

Also fixed in opensuse.org
+--- src/xgi_driver.c.orig 2008-01-19 20:28:22.000000000 +0000
++++ src/xgi_driver.c 2008-01-19 20:28:55.000000000 +0000
+@@ -2504,7 +2504,7 @@
+
+ FbDevExist = FALSE;
+ if (pXGI->Chipset != PCI_CHIP_XGIXG20) {
+- if ((fd = open("/dev/fb", 'r')) != -1) {
++ if ((fd = open("/dev/fb", O_RDONLY)) != -1) {
+ PDEBUG(ErrorF("--- open /dev/fb.... \n"));
+ ioctl(fd, FBIOGET_FSCREENINFO, &fix);
Comment 2 Gaetan Nadon 2009-07-28 18:59:05 UTC
Created attachment 28132 [details] [review]
[PATCH] video-xgi: fix incorrect function call to open() #23010
Comment 3 Peter Hutterer 2009-08-25 16:00:32 UTC
Pushed as b085ad2f3e68667e625eb60a675ff77180c0c288.
fwiw, I'm not sure if spending time on video-xgi is time well spent :)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.