[PATCH 7/8] Always use width in scanf
Tim Wiederhake
twied at gmx.net
Mon Jul 16 07:02:51 PDT 2012
---
tests/modetest/modetest.c | 8 ++++----
xf86drm.c | 8 ++++----
xf86drmMode.c | 2 +-
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index dff40d1..4540aa0 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1215,10 +1215,10 @@ int main(int argc, char **argv)
break;
case 's':
con_args[count].crtc = -1;
- if (sscanf(optarg, "%d:%64s",
+ if (sscanf(optarg, "%20d:%64s",
&con_args[count].id,
con_args[count].mode_str) != 2 &&
- sscanf(optarg, "%d@%d:%64s",
+ sscanf(optarg, "%20d@%20d:%64s",
&con_args[count].id,
&con_args[count].crtc,
con_args[count].mode_str) != 3)
@@ -1227,12 +1227,12 @@ int main(int argc, char **argv)
break;
case 'P':
strcpy(plane_args[plane_count].format_str, "XR24");
- if (sscanf(optarg, "%d:%dx%d@%4s",
+ if (sscanf(optarg, "%20d:%20dx%20d@%4s",
&plane_args[plane_count].con_id,
&plane_args[plane_count].w,
&plane_args[plane_count].h,
plane_args[plane_count].format_str) != 4 &&
- sscanf(optarg, "%d:%dx%d",
+ sscanf(optarg, "%20d:%20dx%20d",
&plane_args[plane_count].con_id,
&plane_args[plane_count].w,
&plane_args[plane_count].h) != 3)
diff --git a/xf86drm.c b/xf86drm.c
index 94f634d..bcb9fbf 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -224,18 +224,18 @@ static int drmMatchBusID(const char *id1, const char *id2, int pci_domain_ok)
unsigned int o2, b2, d2, f2;
int ret;
- ret = sscanf(id1, "pci:%04x:%02x:%02x.%u", &o1, &b1, &d1, &f1);
+ ret = sscanf(id1, "pci:%04x:%02x:%02x.%20u", &o1, &b1, &d1, &f1);
if (ret != 4) {
o1 = 0;
- ret = sscanf(id1, "PCI:%u:%u:%u", &b1, &d1, &f1);
+ ret = sscanf(id1, "PCI:%20u:%20u:%20u", &b1, &d1, &f1);
if (ret != 3)
return 0;
}
- ret = sscanf(id2, "pci:%04x:%02x:%02x.%u", &o2, &b2, &d2, &f2);
+ ret = sscanf(id2, "pci:%04x:%02x:%02x.%20u", &o2, &b2, &d2, &f2);
if (ret != 4) {
o2 = 0;
- ret = sscanf(id2, "PCI:%u:%u:%u", &b2, &d2, &f2);
+ ret = sscanf(id2, "PCI:%20u:%20u:%20u", &b2, &d2, &f2);
if (ret != 3)
return 0;
}
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 04fdf1f..31b5abd 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -693,7 +693,7 @@ int drmCheckModesettingSupported(const char *busid)
struct dirent *dent;
int found = 0, ret;
- ret = sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev, &func);
+ ret = sscanf(busid, "pci:%04x:%02x:%02x.%20d", &domain, &bus, &dev, &func);
if (ret != 4)
return -EINVAL;
--
1.7.10.4
More information about the dri-devel
mailing list