Loading...
gen/FreeBSD/fmtmsg.c Libc-1725.40.4 Libc-583
--- Libc/Libc-1725.40.4/gen/FreeBSD/fmtmsg.c
+++ Libc/Libc-583/gen/FreeBSD/fmtmsg.c
@@ -25,9 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/gen/fmtmsg.c,v 1.6 2009/11/08 14:02:54 brueffer Exp $");
-
-#include <sys/stat.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/fmtmsg.c,v 1.5 2003/05/01 19:03:13 nectar Exp $");
 
 #include <fmtmsg.h>
 #include <stdio.h>
@@ -47,7 +45,7 @@
 		*sevinfo(int);
 static int	 validmsgverb(const char *);
 
-static const char * const validlist[] = {
+static const char *validlist[] = {
 	"label", "severity", "text", "action", "tag", NULL
 };
 
@@ -57,10 +55,6 @@
 {
 	FILE *fp;
 	char *env, *msgverb, *output;
-	int ret = MM_OK;
-
-	if (action == NULL)
-		action = "";
 
 	if (class & MM_PRINT) {
 		if ((env = getenv("MSGVERB")) != NULL && *env != '\0' &&
@@ -82,10 +76,8 @@
 			free(msgverb);
 			return (MM_NOTOK);
 		}
-		if (*output != '\0') {
-			if (fprintf(stderr, "%s", output) < 0)
-				ret = MM_NOMSG;
-		}
+		if (*output != '\0')
+			fprintf(stderr, "%s", output);
 		free(msgverb);
 		free(output);
 	}
@@ -95,57 +87,16 @@
 		if (output == NULL)
 			return (MM_NOCON);
 		if (*output != '\0') {
-			/*
-			 * The Unix conformance test suite expects the
-			 * console to be a socket or a device node on a
-			 * normal writeable file system.  It tests console
-			 * functionality such as fmtmsg(MM_CONSOLE) by
-			 * temporarily replacing that socket or device
-			 * with a regular file which it can then inspect
-			 * after the test.  This worked fine in the 1980s,
-			 * but we are no longer in the 1980s, so in order
-			 * for the test suite to work at all we have to
-			 * lie and tell it that the console is
-			 * `/var/log/console`.
-			 *
-			 * Furthermore, part of the test suite for
-			 * fmtmsg() attempts to verify that it returns the
-			 * correct error codes when it fails to write to
-			 * the console (either MM_NOCON if it successfully
-			 * wrote to stderr or MM_NOTOK if it didn't).  It
-			 * does this by replacing what it thinks is the
-			 * console with a directory, rather than a regular
-			 * file, in order to trigger a failure from
-			 * fopen().
-			 *
-			 * In order to pass this misbegotten test, we
-			 * check to see if `/var/log/console` exists and
-			 * is a directory.  If that is the case, we try to
-			 * open that instead of the real console.  We will
-			 * of course fail, but that's what we're expected
-			 * to do at this point.
-			 */
-			struct stat sb;
-			const char *trap_path = "/var/log/console";
-			const char *console_path = "/dev/console";
-			if (stat(trap_path, &sb) == 0 && S_ISDIR(sb.st_mode)) {
-				/* the trap has been laid, walk into it */
-				console_path = trap_path;
+			if ((fp = fopen("/dev/console", "a")) == NULL) {
+				free(output);
+				return (MM_NOCON);
 			}
-			if ((fp = fopen(console_path, "a")) == NULL) {
-				if (ret == MM_OK) {
-					ret = MM_NOCON;
-				} else {
-					ret = MM_NOTOK;
-				}
-			} else {
-				fprintf(fp, "%s", output);
-				fclose(fp);
-			}
+			fprintf(fp, "%s", output);
+			fclose(fp);
 		}
 		free(output);
 	}
-	return (ret);
+	return (MM_OK);
 }
 
 #define INSERT_COLON							\
@@ -177,7 +128,7 @@
 		size += strlen(sevname);
 	if (text != MM_NULLTXT)
 		size += strlen(text);
-	if (act != MM_NULLACT)
+	if (text != MM_NULLACT)
 		size += strlen(act);
 	if (tag != MM_NULLTAG)
 		size += strlen(tag);