udev: drop util_log_priority() and use log_level_from_string()
The function util_log_priority() is almost same as log_level_from_string(). The difference between them is only that util_log_priority() accepts such that '3 hogehoge'.
This commit is contained in:
@@ -99,7 +99,6 @@ void udev_list_entry_set_num(struct udev_list_entry *list_entry, int num);
|
||||
#define UTIL_NAME_SIZE 512
|
||||
#define UTIL_LINE_SIZE 16384
|
||||
#define UDEV_ALLOWED_CHARS_INPUT "/ $%?,"
|
||||
int util_log_priority(const char *priority);
|
||||
size_t util_path_encode(const char *src, char *dest, size_t size);
|
||||
int util_replace_whitespace(const char *str, char *to, size_t len);
|
||||
int util_replace_chars(char *str, const char *white);
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "MurmurHash2.h"
|
||||
#include "device-nodes.h"
|
||||
#include "libudev-private.h"
|
||||
#include "syslog-util.h"
|
||||
#include "utf8.h"
|
||||
|
||||
/**
|
||||
@@ -84,21 +83,6 @@ int util_resolve_subsys_kernel(const char *string,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int util_log_priority(const char *priority) {
|
||||
char *endptr;
|
||||
int prio;
|
||||
|
||||
prio = strtoul(priority, &endptr, 10);
|
||||
if (endptr[0] == '\0' || isspace(endptr[0])) {
|
||||
if (prio >= 0 && prio <= 7)
|
||||
return prio;
|
||||
else
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
return log_level_from_string(priority);
|
||||
}
|
||||
|
||||
size_t util_path_encode(const char *src, char *dest, size_t size) {
|
||||
size_t i, j;
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libudev-private.h"
|
||||
#include "parse-util.h"
|
||||
#include "process-util.h"
|
||||
#include "syslog-util.h"
|
||||
#include "time-util.h"
|
||||
#include "udevadm.h"
|
||||
#include "udev-ctrl.h"
|
||||
@@ -84,18 +84,15 @@ int control_main(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
break;
|
||||
case 'l': {
|
||||
int i;
|
||||
case 'l':
|
||||
r = log_level_from_string(optarg);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse log priority '%s': %m", optarg);
|
||||
|
||||
i = util_log_priority(optarg);
|
||||
if (i < 0)
|
||||
return log_error_errno(i, "invalid number '%s'", optarg);
|
||||
|
||||
r = udev_ctrl_send_set_log_level(uctrl, i, timeout);
|
||||
r = udev_ctrl_send_set_log_level(uctrl, r, timeout);
|
||||
if (r < 0)
|
||||
return r;
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
r = udev_ctrl_send_stop_exec_queue(uctrl, timeout);
|
||||
if (r < 0)
|
||||
|
||||
+2
-1
@@ -51,6 +51,7 @@
|
||||
#include "signal-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "string-util.h"
|
||||
#include "syslog-util.h"
|
||||
#include "terminal-util.h"
|
||||
#include "udev-builtin.h"
|
||||
#include "udev-ctrl.h"
|
||||
@@ -1452,7 +1453,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
||||
r = util_log_priority(value);
|
||||
r = log_level_from_string(value);
|
||||
if (r >= 0)
|
||||
log_set_max_level(r);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user