aboutsummaryrefslogtreecommitdiffstats
path: root/tools/flask
diff options
context:
space:
mode:
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>2011-12-05 19:32:05 +0000
committerDaniel De Graaf <dgdegra@tycho.nsa.gov>2011-12-05 19:32:05 +0000
commit63ee70ebd0ed1a0ef6356995cd5beb0298f933c1 (patch)
tree1753550bbdeaee47f68f5e1ebb001bd061a3a7e0 /tools/flask
parentb4756b45ac1253c25973d687db739146d7d8ccfe (diff)
downloadxen-63ee70ebd0ed1a0ef6356995cd5beb0298f933c1.tar.gz
xen-63ee70ebd0ed1a0ef6356995cd5beb0298f933c1.tar.bz2
xen-63ee70ebd0ed1a0ef6356995cd5beb0298f933c1.zip
flask: Fix 32-bit compilation of label-pci tool
The 32-bit tools need to support 64-bit addresses, so use the correct printf/scanf formats. Also, some systems declare fscanf with attribute warn_unused_result, so check the result instead of relying on the value of start being unmodified across a failed call. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Committed-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'tools/flask')
-rw-r--r--tools/flask/utils/label-pci.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/flask/utils/label-pci.c b/tools/flask/utils/label-pci.c
index 839ad619ea..da0cb610f4 100644
--- a/tools/flask/utils/label-pci.c
+++ b/tools/flask/utils/label-pci.c
@@ -15,6 +15,7 @@
#include <sys/stat.h>
#include <string.h>
#include <unistd.h>
+#include <inttypes.h>
#include <libflask.h>
/* Pulled from linux/include/linux/ioport.h */
@@ -76,22 +77,22 @@ int main (int argCnt, char *argv[])
goto done;
}
- while (fscanf(f, "0x%lx 0x%lx 0x%lx\n", &start, &end, &flags) == 3) {
+ while (fscanf(f, "0x%"SCNx64" 0x%"SCNx64" 0x%"SCNx64"\n", &start, &end, &flags) == 3) {
if (flags & IORESOURCE_IO) {
- // printf("Port %lx-%lx\n", start, end);
+ // printf("Port %"PRIx64"-%"PRIx64"\n", start, end);
ret = flask_add_ioport(xch, start, end, argv[2]);
if (ret) {
- fprintf(stderr, "flask_add_ioport %lx-%lx failed: %d\n",
+ fprintf(stderr, "flask_add_ioport %"PRIx64"-%"PRIx64" failed: %d\n",
start, end, ret);
err = 2;
}
} else if (flags & IORESOURCE_MEM) {
start >>= 12;
end >>= 12;
- // printf("IOMEM %lx-%lx\n", start, end);
+ // printf("IOMEM %"PRIx64"-%"PRIx64"\n", start, end);
ret = flask_add_iomem(xch, start, end, argv[2]);
if (ret) {
- fprintf(stderr, "flask_add_iomem %lx-%lx failed: %d\n",
+ fprintf(stderr, "flask_add_iomem %"PRIx64"-%"PRIx64" failed: %d\n",
start, end, ret);
err = 2;
}
@@ -104,12 +105,12 @@ int main (int argCnt, char *argv[])
f = fopen(buf, "r");
if (!f)
goto done;
- start = 0;
- fscanf(f, "%ld", &start);
+ if (fscanf(f, "%" SCNu64, &start) != 1)
+ start = 0;
if (start) {
ret = flask_add_pirq(xch, start, argv[2]);
if (ret) {
- fprintf(stderr, "flask_add_pirq %ld failed: %d\n",
+ fprintf(stderr, "flask_add_pirq %"PRIu64" failed: %d\n",
start, ret);
err = 2;
}