fcoe-utils/0022-fcnsq-Fixup-64bit-integer-handling.patch
2014-03-19 09:20:41 +00:00

80 lines
1.9 KiB
Diff

From d8deef20a4a427dfa866398047e00cd3e28c0545 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 6 Dec 2013 19:51:55 +0000
Subject: fcnsq: Fixup 64bit integer handling
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Robert Love <robert.w.love@intel.com>
---
fcnsq.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/fcnsq.c b/fcnsq.c
index 2510f1c..1597cd5 100644
--- a/fcnsq.c
+++ b/fcnsq.c
@@ -24,6 +24,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <unistd.h>
+#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
@@ -228,7 +229,7 @@ static int gpn_id(int bsg, u32 fcid)
rjt = gn_id(bsg, fcid, FC_NS_GPN_ID, &wwpn);
if (rjt)
goto fail;
- print_result("Port Name", "%16.16llx\n", wwpn);
+ print_result("Port Name", "%16.16jx\n", (uintmax_t)wwpn);
return 0;
fail:
if (rjt == (u16) ~0)
@@ -249,7 +250,7 @@ static int gnn_id(int bsg, u32 fcid)
rjt = gn_id(bsg, fcid, FC_NS_GNN_ID, &wwnn);
if (rjt)
goto fail;
- print_result("Node Name", "%16.16llx\n", wwnn);
+ print_result("Node Name", "%16.16jx\n", (uintmax_t)wwnn);
return 0;
fail:
if (rjt == (u16) ~0)
@@ -376,11 +377,12 @@ int main(int argc, char *argv[])
{
char *bsg;
int bsg_dev;
- u32 port_id;
- u64 wwnn;
+ u32 port_id = 0;
+ u64 wwnn = 0;
int rc = 0;
enum commands cmd = 0;
char c;
+ uintmax_t wwnn_tmp = 0;
while(1) {
c = getopt_long_only(argc, argv, "", options, NULL);
@@ -399,13 +401,17 @@ int main(int argc, char *argv[])
if (cmd)
help(-1);
cmd = c;
- sscanf(optarg, "%x", &port_id);
+ if (sscanf(optarg, "%x", &port_id) != 1)
+ help(-1);
break;
case GSNN_NN:
if (cmd)
help(-1);
cmd = c;
- sscanf(optarg, "%llx", &wwnn);
+ if (sscanf(optarg, "%jx", &wwnn_tmp) == 1)
+ wwnn = (u64)wwnn_tmp;
+ else
+ help(-1);
break;
}
}
--
1.8.1.4