Skip to contentSkip to conversation

nfsrahead: getopt return type is int

PATCH In review Thiago Becker 2 participants 2 messages May 13, 2022 – May 26, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsrahead: getopt return type is int

While compiling for aarch64, the compiler throws the warning below because char is unsigned for aarch64.

main.c: In function ‘main’:
main.c:145:48: warning: comparison is always true due to limited range of data type [-Wtype-limits]

  145 |         while((opt = getopt(argc, argv, "dF")) != -1) {
      |

This makes nfsrahead to run forever. Fix opt type to the same as getopt type.

---
 tools/nfsrahead/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/nfsrahead/main.c +1 -2
index 5fae941c..c83c6f71 100644
@@ -135,10 +135,9 @@ static int conf_get_readahead(const char *kind) {
 
 int main(int argc, char **argv)
 {
-	int ret = 0, retry;
+	int ret = 0, retry, opt;
 	struct device_info device;
 	unsigned int readahead = 128, log_level, log_stderr = 0;
-	char opt;
 
 
 	log_level = D_ALL & ~D_GENERAL;
Signature · 1 line
2.35.1
#1 lore raw
Quoted 5 lines · Thiago Becker

While compiling for aarch64, the compiler throws the warning below because char is unsigned for aarch64.

main.c: In function ‘main’:
main.c:145:48: warning: comparison is always true due to limited range of data type [-Wtype-limits]

Quoted 7 lines
   145 |         while((opt = getopt(argc, argv, "dF")) != -1) {
       |

This makes nfsrahead to run forever. Fix opt type to the same as getopt type.

Committed... (tag: nfs-utils-2-6-2-rc5)

steved

Quoted 20 lines
---
  tools/nfsrahead/main.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
tools/nfsrahead/main.c +1 -2
index 5fae941c..c83c6f71 100644
@@ -135,10 +135,9 @@ static int conf_get_readahead(const char *kind) {
 
  int main(int argc, char **argv)
  {
-	int ret = 0, retry;
+	int ret = 0, retry, opt;
  	struct device_info device;
  	unsigned int readahead = 128, log_level, log_stderr = 0;
-	char opt;
 
 
  	log_level = D_ALL & ~D_GENERAL;