public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/lib/log log.c
@ 2011-08-11 19:21 zkabelac
0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2011-08-11 19:21 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-08-11 19:21:42
Modified files:
lib/log : log.c
Log message:
Trivial, add void to ignore dm_snprinf result
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65
--- LVM2/lib/log/log.c 2011/04/29 00:21:14 1.64
+++ LVM2/lib/log/log.c 2011/08/11 19:21:42 1.65
@@ -276,8 +276,8 @@
log_it:
if (!_log_suppress) {
if (verbose_level() > _LOG_DEBUG)
- dm_snprintf(locn, sizeof(locn), "#%s:%d ",
- file, line);
+ (void) dm_snprintf(locn, sizeof(locn), "#%s:%d ",
+ file, line);
else
locn[0] = '\0';
^ permalink raw reply [flat|nested] 8+ messages in thread
* LVM2/lib/log log.c
@ 2012-02-27 11:31 zkabelac
0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2012-02-27 11:31 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2012-02-27 11:31:31
Modified files:
lib/log : log.c
Log message:
Explicitely ignore fail error on hash_insert
We cannot do anything better here anyway - we are already in logging function,
so just ignore this issue here - it will most likely stop application later.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69
--- LVM2/lib/log/log.c 2012/02/08 11:31:29 1.68
+++ LVM2/lib/log/log.c 2012/02/27 11:31:30 1.69
@@ -262,7 +262,7 @@
if (_duplicated) {
if (dm_hash_lookup(_duplicated, message))
level = _LOG_NOTICE;
- dm_hash_insert(_duplicated, message, (void*)1);
+ (void) dm_hash_insert(_duplicated, message, (void*)1);
}
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* LVM2/lib/log log.c
@ 2011-03-30 12:53 zkabelac
0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2011-03-30 12:53 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-03-30 12:53:04
Modified files:
lib/log : log.c
Log message:
Optimise error message write to _lvm_errmsg
Isn't usually perfomance critical - but log_error is used i.e.for debuging,
this code noticable slows down the processing.
Added 512KB limit to avoid memory exhastions in case of some endless loop.
TODO: use _lvm_errmsg buffer only when lvm2api needs it.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62
--- LVM2/lib/log/log.c 2011/02/18 14:16:12 1.61
+++ LVM2/lib/log/log.c 2011/03/30 12:53:04 1.62
@@ -43,6 +43,9 @@
static int _lvm_errno = 0;
static int _store_errmsg = 0;
static char *_lvm_errmsg = NULL;
+static size_t _lvm_errmsg_size = 0;
+static size_t _lvm_errmsg_len = 0;
+#define MAX_ERRMSG_LEN (512 * 1024) /* Max size of error buffer 512KB */
void init_log_fn(lvm2_log_fn_t log_fn)
{
@@ -154,6 +157,7 @@
if (_lvm_errmsg) {
dm_free(_lvm_errmsg);
_lvm_errmsg = NULL;
+ _lvm_errmsg_size = _lvm_errmsg_len = 0;
}
_store_errmsg = store_errmsg;
@@ -189,6 +193,7 @@
int use_stderr = level & _LOG_STDERR;
int log_once = level & _LOG_ONCE;
int fatal_internal_error = 0;
+ size_t msglen;
level &= ~(_LOG_STDERR|_LOG_ONCE);
@@ -229,14 +234,24 @@
message = &buf2[0];
}
- if (_store_errmsg && (level <= _LOG_ERR)) {
- if (!_lvm_errmsg)
- _lvm_errmsg = dm_strdup(message);
- else if ((newbuf = dm_realloc(_lvm_errmsg,
- strlen(_lvm_errmsg) +
- strlen(message) + 2))) {
- _lvm_errmsg = strcat(newbuf, "\n");
- _lvm_errmsg = strcat(newbuf, message);
+ if (_store_errmsg && (level <= _LOG_ERR) &&
+ _lvm_errmsg_len < MAX_ERRMSG_LEN) {
+ msglen = strlen(message);
+ if ((_lvm_errmsg_len + msglen + 1) >= _lvm_errmsg_size) {
+ _lvm_errmsg_size = 2 * (_lvm_errmsg_len + msglen + 1);
+ if ((newbuf = dm_realloc(_lvm_errmsg,
+ _lvm_errmsg_size)))
+ _lvm_errmsg = newbuf;
+ else
+ _lvm_errmsg_size = _lvm_errmsg_len;
+ }
+ if (_lvm_errmsg &&
+ (_lvm_errmsg_len + msglen + 2) < _lvm_errmsg_size) {
+ /* prepend '\n' and copy with '\0' but do not count in */
+ if (_lvm_errmsg_len)
+ _lvm_errmsg[_lvm_errmsg_len++] = '\n';
+ memcpy(_lvm_errmsg + _lvm_errmsg_len, message, msglen + 1);
+ _lvm_errmsg_len += msglen;
}
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* LVM2/lib/log log.c
@ 2010-10-26 8:53 zkabelac
0 siblings, 0 replies; 8+ messages in thread
From: zkabelac @ 2010-10-26 8:53 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2010-10-26 08:53:25
Modified files:
lib/log : log.c
Log message:
Remove bufused for calculation
As bufused is assigned 0 in preceding source line
clang Idempotent operation
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60
--- LVM2/lib/log/log.c 2010/05/05 22:37:53 1.59
+++ LVM2/lib/log/log.c 2010/10/26 08:53:25 1.60
@@ -359,7 +359,7 @@
_already_logging = 1;
memset(&buf, ' ', sizeof(buf));
bufused = 0;
- if ((n = dm_snprintf(buf, sizeof(buf) - bufused - 1,
+ if ((n = dm_snprintf(buf, sizeof(buf) - 1,
"%s:%d %s%s", file, line, log_command_name(),
_msg_prefix)) == -1)
goto done;
^ permalink raw reply [flat|nested] 8+ messages in thread
* LVM2/lib/log log.c
@ 2010-03-23 18:18 mornfall
0 siblings, 0 replies; 8+ messages in thread
From: mornfall @ 2010-03-23 18:18 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall@sourceware.org 2010-03-23 18:18:50
Modified files:
lib/log : log.c
Log message:
Also honour abort_on_internal_errors when log_fn is set.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58
--- LVM2/lib/log/log.c 2010/01/11 20:41:39 1.57
+++ LVM2/lib/log/log.c 2010/03/23 18:18:49 1.58
@@ -231,7 +231,8 @@
if (_lvm2_log_fn) {
_lvm2_log_fn(level, file, line, 0, message);
-
+ if (fatal_internal_error)
+ abort();
return;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* LVM2/lib/log log.c
@ 2010-01-11 20:41 agk
0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2010-01-11 20:41 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-01-11 20:41:40
Modified files:
lib/log : log.c
Log message:
Use _LOG_FATAL when aborting on an internal error.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57
--- LVM2/lib/log/log.c 2010/01/11 20:30:32 1.56
+++ LVM2/lib/log/log.c 2010/01/11 20:41:39 1.57
@@ -179,16 +179,20 @@
const char *trformat; /* Translated format string */
char *newbuf;
int use_stderr = level & _LOG_STDERR;
- int internal_error = 0;
+ int fatal_internal_error = 0;
level &= ~_LOG_STDERR;
if (_abort_on_internal_errors &&
!strncmp(format, INTERNAL_ERROR,
- strlen(INTERNAL_ERROR)))
- internal_error = 1;
- else if (_log_suppress == 2)
+ strlen(INTERNAL_ERROR))) {
+ fatal_internal_error = 1;
/* Internal errors triggering abort cannot be suppressed. */
+ _log_suppress = 0;
+ level = _LOG_FATAL;
+ }
+
+ if (_log_suppress == 2)
return;
if (level <= _LOG_ERR)
@@ -245,7 +249,7 @@
if (!strcmp("<backtrace>", format) &&
verbose_level() <= _LOG_DEBUG)
break;
- if (internal_error || verbose_level() >= _LOG_DEBUG) {
+ if (verbose_level() >= _LOG_DEBUG) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
if (_indent)
@@ -256,7 +260,7 @@
break;
case _LOG_INFO:
- if (internal_error || verbose_level() >= _LOG_INFO) {
+ if (verbose_level() >= _LOG_INFO) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
if (_indent)
@@ -266,7 +270,7 @@
}
break;
case _LOG_NOTICE:
- if (internal_error || verbose_level() >= _LOG_NOTICE) {
+ if (verbose_level() >= _LOG_NOTICE) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
if (_indent)
@@ -276,7 +280,7 @@
}
break;
case _LOG_WARN:
- if (internal_error || verbose_level() >= _LOG_WARN) {
+ if (verbose_level() >= _LOG_WARN) {
fprintf(use_stderr ? stderr : stdout, "%s%s",
log_command_name(), _msg_prefix);
vfprintf(use_stderr ? stderr : stdout, trformat, ap);
@@ -284,7 +288,7 @@
}
break;
case _LOG_ERR:
- if (internal_error || verbose_level() >= _LOG_ERR) {
+ if (verbose_level() >= _LOG_ERR) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
vfprintf(stderr, trformat, ap);
@@ -293,7 +297,7 @@
break;
case _LOG_FATAL:
default:
- if (internal_error || verbose_level() >= _LOG_FATAL) {
+ if (verbose_level() >= _LOG_FATAL) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
vfprintf(stderr, trformat, ap);
@@ -304,7 +308,7 @@
va_end(ap);
}
- if (internal_error)
+ if (fatal_internal_error)
abort();
if (level > debug_level())
^ permalink raw reply [flat|nested] 8+ messages in thread
* LVM2/lib/log log.c
@ 2010-01-11 20:30 agk
0 siblings, 0 replies; 8+ messages in thread
From: agk @ 2010-01-11 20:30 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-01-11 20:30:33
Modified files:
lib/log : log.c
Log message:
Internal errors triggering abort cannot be suppressed. (kabi)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56
--- LVM2/lib/log/log.c 2009/12/16 19:22:12 1.55
+++ LVM2/lib/log/log.c 2010/01/11 20:30:32 1.56
@@ -187,8 +187,8 @@
!strncmp(format, INTERNAL_ERROR,
strlen(INTERNAL_ERROR)))
internal_error = 1;
-
- if (_log_suppress == 2)
+ else if (_log_suppress == 2)
+ /* Internal errors triggering abort cannot be suppressed. */
return;
if (level <= _LOG_ERR)
^ permalink raw reply [flat|nested] 8+ messages in thread
* LVM2/lib/log log.c
@ 2009-12-01 13:54 mornfall
0 siblings, 0 replies; 8+ messages in thread
From: mornfall @ 2009-12-01 13:54 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall@sourceware.org 2009-12-01 13:54:28
Modified files:
lib/log : log.c
Log message:
If aborting due to an internal error, always print the message causing this.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54
--- LVM2/lib/log/log.c 2009/11/30 17:17:12 1.53
+++ LVM2/lib/log/log.c 2009/12/01 13:54:27 1.54
@@ -183,7 +183,8 @@
level &= ~_LOG_STDERR;
- if (!strncmp(format, "Internal error:",
+ if (_abort_on_internal_errors &&
+ !strncmp(format, "Internal error:",
strlen("Internal error:")))
internal_error = 1;
@@ -244,7 +245,7 @@
if (!strcmp("<backtrace>", format) &&
verbose_level() <= _LOG_DEBUG)
break;
- if (verbose_level() >= _LOG_DEBUG) {
+ if (internal_error || verbose_level() >= _LOG_DEBUG) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
if (_indent)
@@ -255,7 +256,7 @@
break;
case _LOG_INFO:
- if (verbose_level() >= _LOG_INFO) {
+ if (internal_error || verbose_level() >= _LOG_INFO) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
if (_indent)
@@ -265,7 +266,7 @@
}
break;
case _LOG_NOTICE:
- if (verbose_level() >= _LOG_NOTICE) {
+ if (internal_error || verbose_level() >= _LOG_NOTICE) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
if (_indent)
@@ -275,7 +276,7 @@
}
break;
case _LOG_WARN:
- if (verbose_level() >= _LOG_WARN) {
+ if (internal_error || verbose_level() >= _LOG_WARN) {
fprintf(use_stderr ? stderr : stdout, "%s%s",
log_command_name(), _msg_prefix);
vfprintf(use_stderr ? stderr : stdout, trformat, ap);
@@ -283,7 +284,7 @@
}
break;
case _LOG_ERR:
- if (verbose_level() >= _LOG_ERR) {
+ if (internal_error || verbose_level() >= _LOG_ERR) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
vfprintf(stderr, trformat, ap);
@@ -292,7 +293,7 @@
break;
case _LOG_FATAL:
default:
- if (verbose_level() >= _LOG_FATAL) {
+ if (internal_error || verbose_level() >= _LOG_FATAL) {
fprintf(stderr, "%s%s%s", locn, log_command_name(),
_msg_prefix);
vfprintf(stderr, trformat, ap);
@@ -303,7 +304,7 @@
va_end(ap);
}
- if (internal_error && _abort_on_internal_errors)
+ if (internal_error)
abort();
if (level > debug_level())
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-02-27 11:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-11 19:21 LVM2/lib/log log.c zkabelac
-- strict thread matches above, loose matches on Subject: below --
2012-02-27 11:31 zkabelac
2011-03-30 12:53 zkabelac
2010-10-26 8:53 zkabelac
2010-03-23 18:18 mornfall
2010-01-11 20:41 agk
2010-01-11 20:30 agk
2009-12-01 13:54 mornfall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).