~ubuntu-branches/ubuntu/vivid/lvm2/vivid

« back to all changes in this revision

Viewing changes to lib/log/log.c

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2012-05-01 20:27:50 UTC
  • mto: (3.1.23 sid)
  • mto: This revision was merged to the branch mainline in revision 72.
  • Revision ID: package-import@ubuntu.com-20120501202750-gljjjtblowwq9mw8
Tags: upstream-2.02.95
ImportĀ upstreamĀ versionĀ 2.02.95

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
void fin_log(void)
111
111
{
112
112
        if (_log_direct) {
113
 
                dev_close(&_log_dev);
 
113
                (void) dev_close(&_log_dev);
114
114
                _log_direct = 0;
115
115
        }
116
116
 
136
136
 
137
137
void init_msg_prefix(const char *prefix)
138
138
{
139
 
        strncpy(_msg_prefix, prefix, sizeof(_msg_prefix));
 
139
        strncpy(_msg_prefix, prefix, sizeof(_msg_prefix) - 1);
140
140
        _msg_prefix[sizeof(_msg_prefix) - 1] = '\0';
141
141
}
142
142
 
185
185
               const char *format, ...)
186
186
{
187
187
        va_list ap;
188
 
        char buf[1024], buf2[4096], locn[4096];
 
188
        char buf[1024], locn[4096];
189
189
        int bufused, n;
190
190
        const char *message;
191
191
        const char *trformat;           /* Translated format string */
221
221
            (_store_errmsg && (level <= _LOG_ERR)) ||
222
222
            log_once) {
223
223
                va_start(ap, format);
224
 
                n = vsnprintf(buf2, sizeof(buf2) - 1, trformat, ap);
 
224
                n = vsnprintf(locn, sizeof(locn) - 1, trformat, ap);
225
225
                va_end(ap);
226
226
 
227
227
                if (n < 0) {
230
230
                        goto log_it;
231
231
                }
232
232
 
233
 
                buf2[sizeof(buf2) - 1] = '\0';
234
 
                message = &buf2[0];
 
233
                locn[sizeof(locn) - 1] = '\0';
 
234
                message = &locn[0];
235
235
        }
236
236
 
237
237
/* FIXME Avoid pointless use of message buffer when it'll never be read! */
262
262
                if (_duplicated) {
263
263
                        if (dm_hash_lookup(_duplicated, message))
264
264
                                level = _LOG_NOTICE;
265
 
                        dm_hash_insert(_duplicated, message, (void*)1);
 
265
                        (void) dm_hash_insert(_duplicated, message, (void*)1);
266
266
                }
267
267
        }
268
268
 
388
388
                va_end(ap);
389
389
                bufused += n;
390
390
 
 
391
                buf[bufused - 1] = '\n';
391
392
              done:
392
 
                buf[bufused - 1] = '\n';
393
393
                buf[bufused] = '\n';
394
394
                buf[sizeof(buf) - 1] = '\n';
395
395
                /* FIXME real size bufused */