* libmisc/ttytype.c: Avoid implicit conversion of pointers / integers to booleans.

* libmisc/ttytype.c: Avoid assignments in comparisons.
	* libmisc/ttytype.c: Add brackets and parenthesis.
	* libmisc/ttytype.c: The return values of fclose is not checked on purpose.
This commit is contained in:
nekral-guest 2008-05-26 00:02:15 +00:00
parent c249832df1
commit 3d7aa44c8e
2 changed files with 25 additions and 9 deletions

View File

@ -1,3 +1,12 @@
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/ttytype.c: Avoid implicit conversion of pointers /
integers to booleans.
* libmisc/ttytype.c: Avoid assignments in comparisons.
* libmisc/ttytype.c: Add brackets and parenthesis.
* libmisc/ttytype.c: The return values of fclose is not checked on
purpose.
2008-05-26 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/mail.c: Avoid implicit conversion of pointers to

View File

@ -53,26 +53,33 @@ void ttytype (const char *line)
return;
if ((typefile = getdef_str ("TTYTYPE_FILE")) == NULL)
return;
if (access (typefile, F_OK))
if (access (typefile, F_OK) != 0)
return;
if (!(fp = fopen (typefile, "r"))) {
fp = fopen (typefile, "r");
if (NULL == fp) {
perror (typefile);
return;
}
while (fgets (buf, sizeof buf, fp)) {
if (buf[0] == '#')
while (fgets (buf, sizeof buf, fp) == buf) {
if (buf[0] == '#') {
continue;
}
if ((cp = strchr (buf, '\n')))
cp = strchr (buf, '\n');
if (NULL != cp) {
*cp = '\0';
}
if (sscanf (buf, "%s %s", type, port) == 2 &&
strcmp (line, port) == 0)
if ((sscanf (buf, "%s %s", type, port) == 2) &&
(strcmp (line, port) == 0)) {
break;
}
}
if (!feof (fp) && !ferror (fp))
if ((feof (fp) == 0) && (ferror (fp) == 0)) {
addenv ("TERM", type);
}
fclose (fp);
(void) fclose (fp);
}