OSDN Git Service

xf86drm: avoid loop initial declarations
authorChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 23 Mar 2017 13:04:59 +0000 (21:04 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 23 Mar 2017 13:04:59 +0000 (21:04 +0800)
To avoid the error:

external/libdrm/xf86drm.c: In function 'parse_separate_sysfs_files':
external/libdrm/xf86drm.c:3098:5: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
     for (unsigned i = ignore_revision ? 1 : 0; i < ARRAY_SIZE(attrs); i++) {
     ^
external/libdrm/xf86drm.c:3098:5: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code

xf86drm.c

index 88f86ed..a714506 100644 (file)
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3091,11 +3091,11 @@ static int parse_separate_sysfs_files(int maj, int min,
       "subsystem_device",
     };
     char path[PATH_MAX + 1];
-    unsigned int data[ARRAY_SIZE(attrs)];
+    unsigned int data[ARRAY_SIZE(attrs)], i;
     FILE *fp;
     int ret;
 
-    for (unsigned i = ignore_revision ? 1 : 0; i < ARRAY_SIZE(attrs); i++) {
+    for (i = ignore_revision ? 1 : 0; i < ARRAY_SIZE(attrs); i++) {
         snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/%s", maj, min,
                  attrs[i]);
         fp = fopen(path, "r");