From: nekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Date: Mon, 26 May 2008 00:02:15 +0000 (+0000)
Subject: 	* libmisc/ttytype.c: Avoid implicit conversion of pointers / integers to booleans.
X-Git-Tag: 4.1.3~475
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d7aa44c8e0928d066c492edd54777c8e2696e12;p=shadow

	* 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.
---

diff --git a/ChangeLog b/ChangeLog
index 41dc9d63..e65af62f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/libmisc/ttytype.c b/libmisc/ttytype.c
index b50a770f..5c52c735 100644
--- a/libmisc/ttytype.c
+++ b/libmisc/ttytype.c
@@ -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);
 }
+