* 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.
This commit is contained in:
nekral-guest 2008-06-13 18:34:27 +00:00
parent 2296db3db6
commit 71dda8b648
2 changed files with 31 additions and 11 deletions

View File

@ -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> 2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/failure.c: Avoid assignments in comparisons. * libmisc/failure.c: Avoid assignments in comparisons.

View File

@ -110,21 +110,25 @@ static struct {
-1, -1} -1, -1}
}; };
static void get_remote_string (char *buf, int size) static void get_remote_string (char *buf, size_t size)
{ {
for (;;) { for (;;) {
if (read (0, buf, 1) != 1) if (read (0, buf, 1) != 1) {
exit (1); exit (1);
if (*buf == '\0') }
if ('\0' == *buf) {
return; return;
if (--size > 0) }
--size;
if (size > 0) {
++buf; ++buf;
}
} }
/*NOTREACHED*/} /*NOTREACHED*/}
int int
do_rlogin (const char *remote_host, char *name, int namelen, char *term, do_rlogin (const char *remote_host, char *name, size_t namelen, char *term,
int termlen) size_t termlen)
{ {
struct passwd *pwd; struct passwd *pwd;
char remote_name[32]; 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 (name, namelen);
get_remote_string (term, termlen); get_remote_string (term, termlen);
if ((cp = strchr (term, '/'))) { cp = strchr (term, '/');
*cp++ = '\0'; if (NULL != cp) {
*cp = '\0';
cp++;
remote_speed = atoi (cp); remote_speed = atoi (cp);
if (0 == remote_speed) { if (0 == remote_speed) {
remote_speed = 9600; remote_speed = 9600;
} }
} }
for (i = 0; speed_table[i].spd_baud != remote_speed && for (i = 0;
speed_table[i].spd_name != -1; i++); ( (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; speed_name = speed_table[i].spd_name;
}
/* /*
* Put the terminal in cooked mode with echo turned on. * Put the terminal in cooked mode with echo turned on.