aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-03-23 17:04:47 +0000
committerEric Andersen <andersen@codepoet.org>2001-03-23 17:04:47 +0000
commit8ffaf8d139a51b33497a3e80804d7bf1f60875e6 (patch)
tree8baf8f1bb0c74fa6efeae2862dff18312b657819
parentc54f9530eee722a6959087b3b0938b4bb0a3603b (diff)
downloadbusybox-w32-8ffaf8d139a51b33497a3e80804d7bf1f60875e6.tar.gz
busybox-w32-8ffaf8d139a51b33497a3e80804d7bf1f60875e6.tar.bz2
busybox-w32-8ffaf8d139a51b33497a3e80804d7bf1f60875e6.zip
-Wshadow logread fix from Jeff Garzik
-rw-r--r--logread.c18
-rw-r--r--sysklogd/logread.c18
2 files changed, 18 insertions, 18 deletions
diff --git a/logread.c b/logread.c
index ea881e659..19e8aefa6 100644
--- a/logread.c
+++ b/logread.c
@@ -58,8 +58,8 @@ static struct shbuf_ds {
58static struct sembuf SMrup[1] = {{0, -1, IPC_NOWAIT | SEM_UNDO}}; // set SMrup 58static struct sembuf SMrup[1] = {{0, -1, IPC_NOWAIT | SEM_UNDO}}; // set SMrup
59static struct sembuf SMrdn[2] = {{1, 0}, {0, +1, SEM_UNDO}}; // set SMrdn 59static struct sembuf SMrdn[2] = {{1, 0}, {0, +1, SEM_UNDO}}; // set SMrdn
60 60
61static int shmid = -1; // ipc shared memory id 61static int log_shmid = -1; // ipc shared memory id
62static int semid = -1; // ipc semaphore id 62static int log_semid = -1; // ipc semaphore id
63static jmp_buf jmp_env; 63static jmp_buf jmp_env;
64 64
65static void error_exit(const char *str); 65static void error_exit(const char *str);
@@ -97,17 +97,17 @@ extern int logread_main(int argc, char **argv)
97 // attempt to redefine ^C signal 97 // attempt to redefine ^C signal
98 signal(SIGINT, interrupted); 98 signal(SIGINT, interrupted);
99 99
100 if ( (shmid = shmget(KEY_ID, 0, 0)) == -1) 100 if ( (log_shmid = shmget(KEY_ID, 0, 0)) == -1)
101 error_exit("Can't find circular buffer"); 101 error_exit("Can't find circular buffer");
102 102
103 // Attach shared memory to our char* 103 // Attach shared memory to our char*
104 if ( (buf = shmat(shmid, NULL, SHM_RDONLY)) == NULL) 104 if ( (buf = shmat(log_shmid, NULL, SHM_RDONLY)) == NULL)
105 error_exit("Can't get access to circular buffer from syslogd"); 105 error_exit("Can't get access to circular buffer from syslogd");
106 106
107 if ( (semid = semget(KEY_ID, 0, 0)) == -1) 107 if ( (log_semid = semget(KEY_ID, 0, 0)) == -1)
108 error_exit("Can't get access to semaphone(s) for circular buffer from syslogd"); 108 error_exit("Can't get access to semaphone(s) for circular buffer from syslogd");
109 109
110 sem_down(semid); 110 sem_down(log_semid);
111 // Read Memory 111 // Read Memory
112 i=buf->head; 112 i=buf->head;
113 113
@@ -122,10 +122,10 @@ extern int logread_main(int argc, char **argv)
122 if (i >= buf->size ) 122 if (i >= buf->size )
123 i=0; 123 i=0;
124 } 124 }
125 sem_up(semid); 125 sem_up(log_semid);
126 126
127output_end: 127output_end:
128 if (shmid != -1) 128 if (log_shmid != -1)
129 shmdt(buf); 129 shmdt(buf);
130 130
131 return EXIT_SUCCESS; 131 return EXIT_SUCCESS;
@@ -139,7 +139,7 @@ static void interrupted(int sig){
139static void error_exit(const char *str){ 139static void error_exit(const char *str){
140 perror(str); 140 perror(str);
141 //release all acquired resources 141 //release all acquired resources
142 if (shmid != -1) 142 if (log_shmid != -1)
143 shmdt(buf); 143 shmdt(buf);
144 144
145 exit(1); 145 exit(1);
diff --git a/sysklogd/logread.c b/sysklogd/logread.c
index ea881e659..19e8aefa6 100644
--- a/sysklogd/logread.c
+++ b/sysklogd/logread.c
@@ -58,8 +58,8 @@ static struct shbuf_ds {
58static struct sembuf SMrup[1] = {{0, -1, IPC_NOWAIT | SEM_UNDO}}; // set SMrup 58static struct sembuf SMrup[1] = {{0, -1, IPC_NOWAIT | SEM_UNDO}}; // set SMrup
59static struct sembuf SMrdn[2] = {{1, 0}, {0, +1, SEM_UNDO}}; // set SMrdn 59static struct sembuf SMrdn[2] = {{1, 0}, {0, +1, SEM_UNDO}}; // set SMrdn
60 60
61static int shmid = -1; // ipc shared memory id 61static int log_shmid = -1; // ipc shared memory id
62static int semid = -1; // ipc semaphore id 62static int log_semid = -1; // ipc semaphore id
63static jmp_buf jmp_env; 63static jmp_buf jmp_env;
64 64
65static void error_exit(const char *str); 65static void error_exit(const char *str);
@@ -97,17 +97,17 @@ extern int logread_main(int argc, char **argv)
97 // attempt to redefine ^C signal 97 // attempt to redefine ^C signal
98 signal(SIGINT, interrupted); 98 signal(SIGINT, interrupted);
99 99
100 if ( (shmid = shmget(KEY_ID, 0, 0)) == -1) 100 if ( (log_shmid = shmget(KEY_ID, 0, 0)) == -1)
101 error_exit("Can't find circular buffer"); 101 error_exit("Can't find circular buffer");
102 102
103 // Attach shared memory to our char* 103 // Attach shared memory to our char*
104 if ( (buf = shmat(shmid, NULL, SHM_RDONLY)) == NULL) 104 if ( (buf = shmat(log_shmid, NULL, SHM_RDONLY)) == NULL)
105 error_exit("Can't get access to circular buffer from syslogd"); 105 error_exit("Can't get access to circular buffer from syslogd");
106 106
107 if ( (semid = semget(KEY_ID, 0, 0)) == -1) 107 if ( (log_semid = semget(KEY_ID, 0, 0)) == -1)
108 error_exit("Can't get access to semaphone(s) for circular buffer from syslogd"); 108 error_exit("Can't get access to semaphone(s) for circular buffer from syslogd");
109 109
110 sem_down(semid); 110 sem_down(log_semid);
111 // Read Memory 111 // Read Memory
112 i=buf->head; 112 i=buf->head;
113 113
@@ -122,10 +122,10 @@ extern int logread_main(int argc, char **argv)
122 if (i >= buf->size ) 122 if (i >= buf->size )
123 i=0; 123 i=0;
124 } 124 }
125 sem_up(semid); 125 sem_up(log_semid);
126 126
127output_end: 127output_end:
128 if (shmid != -1) 128 if (log_shmid != -1)
129 shmdt(buf); 129 shmdt(buf);
130 130
131 return EXIT_SUCCESS; 131 return EXIT_SUCCESS;
@@ -139,7 +139,7 @@ static void interrupted(int sig){
139static void error_exit(const char *str){ 139static void error_exit(const char *str){
140 perror(str); 140 perror(str);
141 //release all acquired resources 141 //release all acquired resources
142 if (shmid != -1) 142 if (log_shmid != -1)
143 shmdt(buf); 143 shmdt(buf);
144 144
145 exit(1); 145 exit(1);