@@ -89,7 +89,7 @@ static struct g_syslog_intbuffer_s g_syslog_intbuffer;
89
89
*
90
90
****************************************************************************/
91
91
92
- int syslog_remove_intbuffer (void )
92
+ static int syslog_remove_intbuffer (void )
93
93
{
94
94
irqstate_t flags ;
95
95
uint32_t outndx ;
@@ -185,46 +185,11 @@ int syslog_add_intbuffer(int ch)
185
185
186
186
if (inuse == CONFIG_SYSLOG_INTBUFSIZE - 1 )
187
187
{
188
- int oldch = syslog_remove_intbuffer ();
189
- int i ;
188
+ char oldch = syslog_remove_intbuffer ();
190
189
191
- for (i = 0 ; i < CONFIG_SYSLOG_MAX_CHANNELS ; i ++ )
192
- {
193
- FAR syslog_channel_t * channel = g_syslog_channel [i ];
194
-
195
- if (channel == NULL )
196
- {
197
- break ;
198
- }
199
-
200
- #ifdef CONFIG_SYSLOG_IOCTL
201
- if (channel -> sc_state & SYSLOG_CHANNEL_DISABLE )
202
- {
203
- continue ;
204
- }
205
- #endif
206
-
207
- if (channel -> sc_ops -> sc_force == NULL )
208
- {
209
- continue ;
210
- }
211
-
212
- #ifdef CONFIG_SYSLOG_CRLF
213
- /* Check for LF */
214
-
215
- if (oldch == '\n' &&
216
- !(channel -> sc_state & SYSLOG_CHANNEL_DISABLE_CRLF ))
217
- {
218
- /* Add CR */
190
+ syslog_write_foreach (& oldch , 1 , true);
219
191
220
- channel -> sc_ops -> sc_force (channel , '\r' );
221
- }
222
- #endif
223
-
224
- channel -> sc_ops -> sc_force (channel , oldch );
225
- }
226
-
227
- ret = - ENOSPC ;
192
+ ret = - ENOSPC ;
228
193
}
229
194
230
195
/* Copy one character */
@@ -265,6 +230,7 @@ int syslog_add_intbuffer(int ch)
265
230
int syslog_flush_intbuffer (bool force )
266
231
{
267
232
irqstate_t flags ;
233
+ char c ;
268
234
int ch ;
269
235
270
236
/* This logic is performed with the scheduler disabled to protect from
@@ -275,8 +241,6 @@ int syslog_flush_intbuffer(bool force)
275
241
276
242
for (; ; )
277
243
{
278
- int i ;
279
-
280
244
/* Transfer one character to time. This is inefficient, but is
281
245
* done in this way to: (1) Deal with concurrent modification of
282
246
* the interrupt buffer from interrupt activity, (2) Avoid keeper
@@ -290,42 +254,9 @@ int syslog_flush_intbuffer(bool force)
290
254
break ;
291
255
}
292
256
293
- for (i = 0 ; i < CONFIG_SYSLOG_MAX_CHANNELS ; i ++ )
294
- {
295
- FAR syslog_channel_t * channel = g_syslog_channel [i ];
296
- syslog_putc_t putfunc ;
297
-
298
- if (channel == NULL )
299
- {
300
- break ;
301
- }
302
-
303
- #ifdef CONFIG_SYSLOG_IOCTL
304
- if (channel -> sc_state & SYSLOG_CHANNEL_DISABLE )
305
- {
306
- continue ;
307
- }
308
- #endif
309
-
310
- /* Select which putc function to use for this flush */
311
-
312
- putfunc = force ? channel -> sc_ops -> sc_force :
313
- channel -> sc_ops -> sc_putc ;
314
-
315
- #ifdef CONFIG_SYSLOG_CRLF
316
- /* Check for LF */
257
+ c = (char )ch ;
317
258
318
- if (ch == '\n' &&
319
- !(channel -> sc_state & SYSLOG_CHANNEL_DISABLE_CRLF ))
320
- {
321
- /* Add CR */
322
-
323
- putfunc (channel , '\r' );
324
- }
325
- #endif
326
-
327
- putfunc (channel , ch );
328
- }
259
+ syslog_write_foreach (& c , 1 , force );
329
260
}
330
261
331
262
leave_critical_section (flags );
0 commit comments