]> granicus.if.org Git - shadow/commitdiff
* libmisc/rlogin.c: The size argument of read() is a size_t.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 13 Jun 2008 18:34:27 +0000 (18:34 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 13 Jun 2008 18:34:27 +0000 (18:34 +0000)
Propagate this time to the callers (the get_remote_string() and
do_rlogin() functions).
* libmisc/rlogin.c: Add brackets and parenthesis.
* libmisc/rlogin.c: Avoid multi-statements lines.
* libmisc/rlogin.c: Avoid assignments in comparisons.
* libmisc/rlogin.c: Avoid implicit conversion of pointers to
booleans.

ChangeLog
libmisc/rlogin.c

index b6257186dd517ea033560f35203a81895e19f8b5..726b56bcdd5866804b386c22ff67438851f8d310 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-06-13  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * libmisc/rlogin.c: The size argument of read() is a size_t.
+       Propagate this time to the callers (the get_remote_string() and
+       do_rlogin() functions).
+       * libmisc/rlogin.c: Add brackets and parenthesis.
+       * libmisc/rlogin.c: Avoid multi-statements lines.
+       * libmisc/rlogin.c: Avoid assignments in comparisons.
+       * libmisc/rlogin.c: Avoid implicit conversion of pointers to
+       booleans.
+
 2008-06-13  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/failure.c: Avoid assignments in comparisons.
index 0ca1a51b6785f0bce36e414a523c8dc8bdf0ecce..2217c22025da8c8d6c178d133d5272f9b5ff7035 100644 (file)
@@ -110,21 +110,25 @@ static struct {
        -1, -1}
 };
 
-static void get_remote_string (char *buf, int size)
+static void get_remote_string (char *buf, size_t size)
 {
        for (;;) {
-               if (read (0, buf, 1) != 1)
+               if (read (0, buf, 1) != 1) {
                        exit (1);
-               if (*buf == '\0')
+               }
+               if ('\0' == *buf) {
                        return;
-               if (--size > 0)
+               }
+               --size;
+               if (size > 0) {
                        ++buf;
+               }
        }
  /*NOTREACHED*/}
 
 int
-do_rlogin (const char *remote_host, char *name, int namelen, char *term,
-          int termlen)
+do_rlogin (const char *remote_host, char *name, size_t namelen, char *term,
+           size_t termlen)
 {
        struct passwd *pwd;
        char remote_name[32];
@@ -138,19 +142,24 @@ do_rlogin (const char *remote_host, char *name, int namelen, char *term,
        get_remote_string (name, namelen);
        get_remote_string (term, termlen);
 
-       if ((cp = strchr (term, '/'))) {
-               *cp++ = '\0';
+       cp = strchr (term, '/');
+       if (NULL != cp) {
+               *cp = '\0';
+               cp++;
 
                remote_speed = atoi (cp);
                if (0 == remote_speed) {
                        remote_speed = 9600;
                }
        }
-       for (i = 0; speed_table[i].spd_baud != remote_speed &&
-            speed_table[i].spd_name != -1; i++);
+       for (i = 0;
+            (   (speed_table[i].spd_baud != remote_speed)
+             && (speed_table[i].spd_name != -1));
+            i++);
 
-       if (speed_table[i].spd_name != -1)
+       if (-1 != speed_table[i].spd_name) {
                speed_name = speed_table[i].spd_name;
+       }
 
        /*
         * Put the terminal in cooked mode with echo turned on.