All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel De Graaf <dgdegra@tycho.nsa.gov>
To: Keir Fraser <keir@xen.org>, olaf@aepfle.de
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>,
	xen-devel@lists.xensource.com, JBeulich@suse.com
Subject: [PATCH v3] flask: Fix 32-bit compilation of label-pci tool
Date: Mon,  5 Dec 2011 13:45:10 -0500	[thread overview]
Message-ID: <1323110710-18260-1-git-send-email-dgdegra@tycho.nsa.gov> (raw)
In-Reply-To: <20111205180538.GA31722@aepfle.de>

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>
---
 tools/flask/utils/label-pci.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/tools/flask/utils/label-pci.c b/tools/flask/utils/label-pci.c
index 839ad61..da0cb61 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;
 		}
-- 
1.7.7.3

      reply	other threads:[~2011-12-05 18:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05  4:11 [xen-unstable test] 10332: regressions - FAIL xen.org
2011-12-05  9:25 ` Jan Beulich
2011-12-05 11:29   ` [PATCH] flask: Fix 32-bit compilation of label-pci tool Daniel De Graaf
2011-12-05 11:34   ` [PATCH v2] " Daniel De Graaf
2011-12-05 18:05     ` Olaf Hering
2011-12-05 18:45       ` Daniel De Graaf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1323110710-18260-1-git-send-email-dgdegra@tycho.nsa.gov \
    --to=dgdegra@tycho.nsa.gov \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=olaf@aepfle.de \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.