chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libudev: we do not log errors from libraries
[elogind.git]
/
src
/
libudev
/
libudev.c
diff --git
a/src/libudev/libudev.c
b/src/libudev/libudev.c
index e2ab960d55e75aa1011366e65d82a121f5196c0c..674465878920e1e1c3c5ea317b73a6c3981fafb5 100644
(file)
--- a/
src/libudev/libudev.c
+++ b/
src/libudev/libudev.c
@@
-79,7
+79,7
@@
static void log_stderr(struct udev *udev,
* @udev: udev library context
*
* Retrieve stored data pointer from library context. This might be useful
* @udev: udev library context
*
* Retrieve stored data pointer from library context. This might be useful
- * to access from callbacks like a custom log
ging
function.
+ * to access from callbacks like a custom log function.
*
* Returns: stored userdata
**/
*
* Returns: stored userdata
**/
@@
-119,7
+119,7
@@
_public_ struct udev *udev_new(void)
{
struct udev *udev;
const char *env;
{
struct udev *udev;
const char *env;
-
FILE *f
;
+
_cleanup_fclose_ FILE *f = NULL
;
udev = new0(struct udev, 1);
if (udev == NULL)
udev = new0(struct udev, 1);
if (udev == NULL)
@@
-132,7
+132,7
@@
_public_ struct udev *udev_new(void)
f = fopen("/etc/udev/udev.conf", "re");
if (f != NULL) {
char line[UTIL_LINE_SIZE];
f = fopen("/etc/udev/udev.conf", "re");
if (f != NULL) {
char line[UTIL_LINE_SIZE];
-
int
line_nr = 0;
+
unsigned
line_nr = 0;
while (fgets(line, sizeof(line), f)) {
size_t len;
while (fgets(line, sizeof(line), f)) {
size_t len;
@@
-153,7
+153,7
@@
_public_ struct udev *udev_new(void)
/* split key/value */
val = strchr(key, '=');
if (val == NULL) {
/* split key/value */
val = strchr(key, '=');
if (val == NULL) {
- udev_
err(udev, "missing <key>=<value> in /etc/udev/udev.conf[%i]; skip line
\n", line_nr);
+ udev_
dbg(udev, "/etc/udev/udev.conf:%u: missing assignment, skipping line.
\n", line_nr);
continue;
}
val[0] = '\0';
continue;
}
val[0] = '\0';
@@
-185,7
+185,7
@@
_public_ struct udev *udev_new(void)
/* unquote */
if (val[0] == '"' || val[0] == '\'') {
if (val[len-1] != val[0]) {
/* unquote */
if (val[0] == '"' || val[0] == '\'') {
if (val[len-1] != val[0]) {
- udev_
err(udev, "inconsistent quoting in /etc/udev/udev.conf[%i]; skip line
\n", line_nr);
+ udev_
dbg(udev, "/etc/udev/udev.conf:%u: inconsistent quoting, skipping line.
\n", line_nr);
continue;
}
val[len-1] = '\0';
continue;
}
val[len-1] = '\0';
@@
-193,17
+193,29
@@
_public_ struct udev *udev_new(void)
}
if (streq(key, "udev_log")) {
}
if (streq(key, "udev_log")) {
- udev_set_log_priority(udev, util_log_priority(val));
+ int prio;
+
+ prio = util_log_priority(val);
+ if (prio < 0)
+ udev_dbg(udev, "/etc/udev/udev.conf:%u: invalid log level '%s', ignoring.\n", line_nr, val);
+ else
+ udev_set_log_priority(udev, prio);
continue;
}
}
continue;
}
}
- fclose(f);
}
/* environment overrides config */
env = secure_getenv("UDEV_LOG");
}
/* environment overrides config */
env = secure_getenv("UDEV_LOG");
- if (env != NULL)
- udev_set_log_priority(udev, util_log_priority(env));
+ if (env != NULL) {
+ int prio;
+
+ prio = util_log_priority(env);
+ if (prio < 0)
+ udev_dbg(udev, "$UDEV_LOG specifies invalid log level '%s', ignoring.\n", env);
+ else
+ udev_set_log_priority(udev, prio);
+ }
return udev;
}
return udev;
}
@@
-248,11
+260,11
@@
_public_ struct udev *udev_unref(struct udev *udev)
/**
* udev_set_log_fn:
* @udev: udev library context
/**
* udev_set_log_fn:
* @udev: udev library context
- * @log_fn: function to be called for log
ging
messages
+ * @log_fn: function to be called for log messages
*
* The built-in logging writes to stderr. It can be
* overridden by a custom function, to plug log messages
*
* The built-in logging writes to stderr. It can be
* overridden by a custom function, to plug log messages
- * into the users' log
ging
functionality.
+ * into the users' log functionality.
*
**/
_public_ void udev_set_log_fn(struct udev *udev,
*
**/
_public_ void udev_set_log_fn(struct udev *udev,
@@
-261,17
+273,16
@@
_public_ void udev_set_log_fn(struct udev *udev,
const char *format, va_list args))
{
udev->log_fn = log_fn;
const char *format, va_list args))
{
udev->log_fn = log_fn;
- udev_dbg(udev, "custom log
ging
function %p registered\n", log_fn);
+ udev_dbg(udev, "custom log function %p registered\n", log_fn);
}
/**
* udev_get_log_priority:
* @udev: udev library context
*
}
/**
* udev_get_log_priority:
* @udev: udev library context
*
- * The initial logging priority is read from the udev config file
- * at startup.
+ * The initial log level is read from the udev config file at startup.
*
*
- * Returns: the current log
ging priority
+ * Returns: the current log
level
**/
_public_ int udev_get_log_priority(struct udev *udev)
{
**/
_public_ int udev_get_log_priority(struct udev *udev)
{
@@
-281,10
+292,9
@@
_public_ int udev_get_log_priority(struct udev *udev)
/**
* udev_set_log_priority:
* @udev: udev library context
/**
* udev_set_log_priority:
* @udev: udev library context
- * @priority: the new log
ging
priority
+ * @priority: the new log priority
*
*
- * Set the current logging priority. The value controls which messages
- * are logged.
+ * Set the log level. This value controls which messages are logged.
**/
_public_ void udev_set_log_priority(struct udev *udev, int priority)
{
**/
_public_ void udev_set_log_priority(struct udev *udev, int priority)
{