[PATCH 11/12] write: improve coding style

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

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 term-utils/write.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/term-utils/write.c b/term-utils/write.c
index b10c129..e3e749e 100644
--- a/term-utils/write.c
+++ b/term-utils/write.c
@@ -76,7 +76,7 @@ struct write_control {
 	char dst_tty[PATH_MAX];
 };
 
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(FILE *out)
 {
 	fputs(USAGE_HEADER, out);
 	fprintf(out,
@@ -199,11 +199,9 @@ static void search_utmp(struct write_control *ctl)
 			return;
 		}
 		errx(EXIT_FAILURE, _("%s has messages disabled"), ctl->dst_login);
-	} else if (valid_ttys > 1) {
+	} else if (valid_ttys > 1)
 		warnx(_("%s is logged in more than once; writing to %s"),
 		      ctl->dst_login, ctl->dst_tty);
-	}
-
 }
 
 /*
@@ -215,6 +213,15 @@ static void signal_handler(int signo)
 }
 
 /*
+ * PUTC - fputc_careful wrapper
+ */
+static inline void PUTC(char c)
+{
+	if (fputc_careful(c, stdout, '^') == EOF)
+		err(EXIT_FAILURE, _("carefulputc failed"));
+}
+
+/*
  * write_line - like fputs(), but makes control characters visible and
  *     turns \n into \r\n.
  */
@@ -222,8 +229,6 @@ static void write_line(char *s)
 {
 	char c;
 
-#define	PUTC(c)	if (fputc_careful(c, stdout, '^') == EOF) \
-    err(EXIT_FAILURE, _("carefulputc failed"));
 	while (*s) {
 		c = *s++;
 		if (c == '\n')
@@ -231,7 +236,6 @@ static void write_line(char *s)
 		PUTC(c);
 	}
 	return;
-#undef PUTC
 }
 
 /*
@@ -333,7 +337,6 @@ int main(int argc, char **argv)
 		if (!(ctl.src_tty = ttyname(src_fd)))
 			errx(EXIT_FAILURE,
 			     _("can't find your tty's name"));
-
 		/*
 		 * We may have /dev/ttyN but also /dev/pts/xx. Below,
 		 * check_tty() will put "/dev/" in front, so remove that
-- 
2.8.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