Skip to contentSkip to conversation

Use integer as getopt_long returns integer

rdma-core/rdma-ndd Applied Honggang LI 4 participants 4 messages Apr 25, 2017 – Apr 26, 2017 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

From: Honggang Li <[email protected]>

ARM chars are unsigned by default. getopt_long return 255 instead -1. That will cause an endless loop for aarch64 platform.

---
 rdma-ndd/rdma-ndd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rdma-ndd/rdma-ndd.c +1 -1
index 1579a02..e7be22b 100644
@@ -297,7 +297,7 @@ int main(int argc, char *argv[])
 			{ }
 		};
 
-		char c = getopt_long(argc, argv, "fh", long_opts, &opt_idx);
+		int c = getopt_long(argc, argv, "fh", long_opts, &opt_idx);
 		if (c == -1)
 			break;
 
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1493099392-1883-1-git-send-email-honli-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 6 lines · Honggang LI

From: Honggang Li <[email protected]>

ARM chars are unsigned by default. getopt_long return 255 instead -1. That will cause an endless loop for aarch64 platform.

Yep

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to a message not in the archive
Quoted 16 lines · Honggang LI

From: Honggang Li <[email protected]>

ARM chars are unsigned by default. getopt_long return 255 instead -1. That will cause an endless loop for aarch64 platform.

---
 rdma-ndd/rdma-ndd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rdma-ndd/rdma-ndd.c +0 -0
index 1579a02..e7be22b 100644

rdma-ndd/rdma-ndd.c int main(int argc, char *argv[]) · line 303

Quoted 8 lines
rdma-ndd/rdma-ndd.c +1 -1
@@ -297,7 +297,7 @@ int main(int argc, char *argv[])
 			{ }
 		};
 
-		char c = getopt_long(argc, argv, "fh", long_opts, &opt_idx);
+		int c = getopt_long(argc, argv, "fh", long_opts, &opt_idx);
 		if (c == -1)
 			break;
 

int is the return type of the function signature anyway so this was wrong from the start.

https://linux.die.net/man/3/getopt_long

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html