[PATCH 4/11] checktty: Use EXIT_*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Marek Polacek <mmpolacek@xxxxxxxxx>
---
 login-utils/checktty.c |   46
+++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/login-utils/checktty.c b/login-utils/checktty.c
index 92bebfb..b8f9001 100644
--- a/login-utils/checktty.c
+++ b/login-utils/checktty.c
@@ -69,10 +69,10 @@ am_in_group(char *group)
 	g = getgrnam(group);
 	if (g) {
 		for (ge = mygroups; ge < mygroups + num_groups; ge++) {
-			if (g->gr_gid== *ge) return 1;
+			if (g->gr_gid== *ge) return EXIT_FAILURE;
 		}
 	}
-    	return 0;
+    	return EXIT_SUCCESS;
 }

 static void
@@ -130,7 +130,7 @@ isapty(const char *tty)

     /* avoid snprintf - old systems do not have it */
     if (strlen(tty) + 6 > sizeof(devname))
-	    return 0;
+	    return EXIT_SUCCESS;
     sprintf(devname, "/dev/%s", tty);

     if((stat(devname, &stb) >= 0) && S_ISCHR(stb.st_mode)) {
@@ -138,24 +138,24 @@ isapty(const char *tty)

 	    /* this is for linux versions before 1.3: use major 4 */
 	    if(majordev == TTY_MAJOR && minor(stb.st_rdev) >= 192)
-		    return 1;
+		    return EXIT_FAILURE;

 #if defined(PTY_SLAVE_MAJOR)
 	    /* this is for linux 1.3 and newer: use major 3 */
 	    if(majordev == PTY_SLAVE_MAJOR)
-		    return 1;
+		    return EXIT_FAILURE;
 #endif

 #if defined(UNIX98_PTY_SLAVE_MAJOR) && defined(UNIX98_PTY_MAJOR_COUNT)
 	    /* this is for linux 2.1.116 and newer: use majors 136-143 */
 	    if(majordev >= UNIX98_PTY_SLAVE_MAJOR &&
 	       majordev < UNIX98_PTY_SLAVE_MAJOR + UNIX98_PTY_MAJOR_COUNT)
-		    return 1;
+		    return EXIT_FAILURE;
 #endif

     }
 #endif	/* __linux__ */
-    return 0;
+    return EXIT_SUCCESS;
 }


@@ -170,7 +170,7 @@ hnmatch_ip4(const char *pat)
 	/* pattern is an IP QUAD address and a mask x.x.x.x/y.y.y.y */
 	if (sscanf(pat, "%d.%d.%d.%d/%d.%d.%d.%d",
 			&x1, &x2, &x3, &x4, &y1, &y2, &y3, &y4) < 8)
-		return 0;
+		return EXIT_SUCCESS;

 	p = (((unsigned long)x1<<24)+((unsigned long)x2<<16)
 	     +((unsigned long)x3<<8)+((unsigned long)x4));
@@ -178,7 +178,7 @@ hnmatch_ip4(const char *pat)
 		+((unsigned long)y3<<8)+((unsigned long)y4));

 	if (hostaddress[0] == 0)
-		return 0;
+		return EXIT_SUCCESS;

 	ha = (unsigned char *)hostaddress;
 	a = (((unsigned long)ha[0]<<24)+((unsigned long)ha[1]<<16)
@@ -199,7 +199,7 @@ hnmatch_ip6(const char *pat)
 	char *p;

 	if (pat == NULL || *pat != '[')
-		return 0;
+		return EXIT_SUCCESS;

 	memcpy(&addr, hostaddress, sizeof(addr));

@@ -250,11 +250,11 @@ hnmatch_ip6(const char *pat)
 	}

 	free(patnet);
-	return 1;
+	return EXIT_FAILURE;

 mismatch:
 	free(patnet);
-	return 0;
+	return EXIT_SUCCESS;
 }

 /* match the hostname hn against the pattern pat */
@@ -263,9 +263,9 @@ hnmatch(const char *hn, const char *pat)
 {

 	if ((hn == NULL) && (strcmp(pat, "localhost") == 0))
-		return 1;
+		return EXIT_FAILURE;
 	if ((hn == NULL) || *hn == '\0')
-		return 0;
+		return EXIT_SUCCESS;

 	if (*pat >= '0' && *pat <= '9')
 		return hostfamily == AF_INET ? hnmatch_ip4(pat) : 0;
@@ -277,7 +277,7 @@ hnmatch(const char *hn, const char *pat)
 			m = strlen(hn);

 		if (n > m)
-			return 0;
+			return EXIT_SUCCESS;
 		return (strcasecmp(pat, hn + m - n) == 0);
 	}
 }
@@ -340,7 +340,7 @@ main(int argc, char **argv)
 			printf("getaddrinfo() failed\n");

 	}
-	return 0;
+	return EXIT_SUCCESS;
 }
 #endif /* MAIN_TEST_CHECKTTY */

@@ -404,16 +404,16 @@ in_class(const char *tty, char *class)
 	    *p = 0;
 	    xstrncpy(timespec, class+1, sizeof(timespec));
 	    *p = ']';
-	    if(!timeok(tm, timespec)) return 0;
+	    if(!timeok(tm, timespec)) return EXIT_SUCCESS;
 	    class = p+1;
 	}
 	/* really ought to warn about syntax error */
     }

-    if (strcmp(tty, class) == 0) return 1;
+    if (strcmp(tty, class) == 0) return EXIT_FAILURE;

     if ((class[0] == '@') && isapty(tty)
-	&& hnmatch(hostname, class+1)) return 1;
+	&& hnmatch(hostname, class+1)) return EXIT_FAILURE;

     for (tc = ttyclasses; tc; tc = tc->next) {
 	if (strcmp(tc->classname, class) == 0) {
@@ -431,15 +431,15 @@ in_class(const char *tty, char *class)
 		    /* really ought to warn about syntax error */
 		}

-		if (strcmp(n, tty) == 0) return 1;
+		if (strcmp(n, tty) == 0) return EXIT_FAILURE;

 		if ((n[0] == '@') && isapty(tty)
-		    && hnmatch(hostname, n+1)) return 1;
+		    && hnmatch(hostname, n+1)) return EXIT_FAILURE;
 	    }
-	    return 0;
+	    return EXIT_SUCCESS;
 	}
     }
-    return 0;
+    return EXIT_SUCCESS;
 }

 /* start JDS - SBA */
-- 
1.7.3.2


--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux