aboutsummaryrefslogtreecommitdiff
path: root/init/mesg.c
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-29 22:51:25 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-29 22:51:25 +0000
commit2f2ce3c4222378da84c9f5f555c32409566579d8 (patch)
treeb73c92aefaf614291a71d05e9d28ca68f4ef021b /init/mesg.c
parent32d944197db7cd9a6d6014aa83d1d9fd36e4f7ca (diff)
downloadbusybox-w32-2f2ce3c4222378da84c9f5f555c32409566579d8.tar.gz
busybox-w32-2f2ce3c4222378da84c9f5f555c32409566579d8.tar.bz2
busybox-w32-2f2ce3c4222378da84c9f5f555c32409566579d8.zip
preparatory patch for -Wwrite-strings #2
git-svn-id: svn://busybox.net/trunk/busybox@17654 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'init/mesg.c')
-rw-r--r--init/mesg.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/init/mesg.c b/init/mesg.c
index 7e47644c3..658c82447 100644
--- a/init/mesg.c
+++ b/init/mesg.c
@@ -8,8 +8,6 @@
8 */ 8 */
9 9
10#include "busybox.h" 10#include "busybox.h"
11#include <unistd.h>
12#include <stdlib.h>
13 11
14#ifdef USE_TTY_GROUP 12#ifdef USE_TTY_GROUP
15#define S_IWGRP_OR_S_IWOTH S_IWGRP 13#define S_IWGRP_OR_S_IWOTH S_IWGRP
@@ -20,24 +18,24 @@
20int mesg_main(int argc, char *argv[]) 18int mesg_main(int argc, char *argv[])
21{ 19{
22 struct stat sb; 20 struct stat sb;
23 char *tty; 21 const char *tty;
24 char c = 0; 22 char c = 0;
25 23
26 if ((--argc == 0) 24 if (--argc == 0
27 || ((argc == 1) && (((c = **++argv) == 'y') || (c == 'n')))) { 25 || (argc == 1 && ((c = **++argv) == 'y' || c == 'n'))
28 if ((tty = ttyname(STDERR_FILENO)) == NULL) { 26 ) {
27 tty = ttyname(STDERR_FILENO);
28 if (tty == NULL) {
29 tty = "ttyname"; 29 tty = "ttyname";
30 } else if (stat(tty, &sb) == 0) { 30 } else if (stat(tty, &sb) == 0) {
31 mode_t m;
31 if (argc == 0) { 32 if (argc == 0) {
32 puts(((sb.st_mode & (S_IWGRP | S_IWOTH)) == 33 puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n");
33 0) ? "is n" : "is y");
34 return EXIT_SUCCESS; 34 return EXIT_SUCCESS;
35 } 35 }
36 if (chmod 36 m = (c == 'y') ? sb.st_mode | S_IWGRP_OR_S_IWOTH
37 (tty, 37 : sb.st_mode & ~(S_IWGRP|S_IWOTH);
38 (c == 38 if (chmod(tty, m) == 0) {
39 'y') ? sb.st_mode | (S_IWGRP_OR_S_IWOTH) : sb.
40 st_mode & ~(S_IWGRP | S_IWOTH)) == 0) {
41 return EXIT_SUCCESS; 39 return EXIT_SUCCESS;
42 } 40 }
43 } 41 }