Blob Blame History Raw
From 2a2d9a8200f987b42966ab4e96b7769b8f9a159f Mon Sep 17 00:00:00 2001
From: Gris Ge <fge@redhat.com>
Date: Wed, 22 Feb 2017 16:18:20 +0800
Subject: [PATCH] udev: Fix gcc warning on non-x86 platform.

Issue:
    Got failure on s390x:

        scan-scsi-target.c:90:2: error: comparison is always true due to limited
        range of data type [-Werror=type-limits]

Root cause:
    The error is on these lines:

        char c;
        ...
        while ((c = getopt_long(argc, argv, "rh", longopts, NULL)) != -1) {

    On non-x86 platform, char is unsigned. Which makes the (c != -1)
    always true.

Fix:
    Take return of getopt_long() as int.

Signed-off-by: Gris Ge <fge@redhat.com>
---
 tools/udev/scan-scsi-target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/udev/scan-scsi-target.c b/tools/udev/scan-scsi-target.c
index bb83c65..00126b9 100644
--- a/tools/udev/scan-scsi-target.c
+++ b/tools/udev/scan-scsi-target.c
@@ -54,7 +54,7 @@ static void __attribute__ ((__noreturn__)) invalid(char **argv, char *devpath)
 
 int main(int argc, char **argv)
 {
-	char	c;
+	int	c;
 	char	*devpath;
 
 	char	*sysfs_path;
-- 
1.8.3.1