Supplying a negative baudrate will now be implicitly converted to the unsigned
int equivalent. So don't do that.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 tools/isdv4-serial-inputattach.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/isdv4-serial-inputattach.c b/tools/isdv4-serial-inputattach.c
index 9d698b0..711f6ed 100644
--- a/tools/isdv4-serial-inputattach.c
+++ b/tools/isdv4-serial-inputattach.c
@@ -80,17 +80,17 @@ static int bind_kernel_driver(int fd)
        return 0;
 }
 
-static int get_baud_rate(int fd)
+static unsigned int get_baud_rate(int fd)
 {
        struct stat st;
-       int baudrate = 19200;
+       unsigned int baudrate = 19200;
        int id;
        struct udev *udev;
        struct udev_device *device, *parent;
        const char *attr_id = NULL;
 
        if (fstat(fd, &st) == -1)
-               return -1;
+               return 0;
 
        udev = udev_new();
        device = udev_device_new_from_devnum(udev, 'c', st.st_rdev);
@@ -129,7 +129,7 @@ int main(int argc, char **argv)
         int sensor_id;
        char *filename;
        int fd, rc = 1;
-       int baudrate = 0;
+       unsigned int baudrate = 0;
        int have_baudrate = 0;
 
        int c, optidx = 0;
@@ -151,8 +151,8 @@ int main(int argc, char **argv)
                                return 0;
                        case 'b':
                                have_baudrate = 1;
-                               baudrate = atoi(optarg);
-                               if (baudrate <= 0) {
+                               baudrate = (unsigned int)atoi(optarg);
+                               if (baudrate == 0) {
                                        usage();
                                        return 1;
                                }
@@ -176,7 +176,7 @@ int main(int argc, char **argv)
                goto out;
 
        /* only guess if we didn't get a baud rate */
-       if (!have_baudrate && (baudrate = get_baud_rate(fd)) < 0)
+       if (!have_baudrate && (baudrate = get_baud_rate(fd)) == 0)
                goto out;
 
        set_serial_attr(fd, baudrate);
-- 
2.1.0


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to