chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
67c15b9
)
remove hasprefix(), use startswith()
author
Shawn Landden
<shawnlandden@gmail.com>
Thu, 22 Aug 2013 01:20:55 +0000
(18:20 -0700)
committer
Zbigniew Jędrzejewski-Szmek
<zbyszek@in.waw.pl>
Thu, 22 Aug 2013 04:52:14 +0000
(
00:52
-0400)
TODO
patch
|
blob
|
history
src/journal/journal-send.c
patch
|
blob
|
history
src/journal/journald-native.c
patch
|
blob
|
history
src/libsystemd-bus/bus-match.c
patch
|
blob
|
history
src/shared/logs-show.c
patch
|
blob
|
history
src/shared/macro.h
patch
|
blob
|
history
diff --git
a/TODO
b/TODO
index 9bc14fdbf531aef2b30f8b17ee8be80aeddfb50b..3800ce47676db92c1c528a1e29495dca3a52d88c 100644
(file)
--- a/
TODO
+++ b/
TODO
@@
-96,8
+96,6
@@
Features:
* systemctl list-unit-files should list generated files (and probably with a new state "generated" for them, or so)
* systemctl list-unit-files should list generated files (and probably with a new state "generated" for them, or so)
-* do we really need both hasprefix() and startswith()?
-
* journald: when we drop syslog messages because the syslog socket is
full, make sure to write how many messages are lost as first thing
to syslog when it works again.
* journald: when we drop syslog messages because the syslog socket is
full, make sure to write how many messages are lost as first thing
to syslog when it works again.
diff --git
a/src/journal/journal-send.c
b/src/journal/journal-send.c
index fef66fc29aed0c68a928c180b1fd753198764f2c..d00e26f1eb702d742659e14ef2dd601ea594b61b 100644
(file)
--- a/
src/journal/journal-send.c
+++ b/
src/journal/journal-send.c
@@
-245,7
+245,7
@@
_public_ int sd_journal_sendv(const struct iovec *iov, int n) {
have_syslog_identifier = have_syslog_identifier ||
(c == (char *) iov[i].iov_base + 17 &&
have_syslog_identifier = have_syslog_identifier ||
(c == (char *) iov[i].iov_base + 17 &&
-
hasprefix
(iov[i].iov_base, "SYSLOG_IDENTIFIER"));
+
startswith
(iov[i].iov_base, "SYSLOG_IDENTIFIER"));
nl = memchr(iov[i].iov_base, '\n', iov[i].iov_len);
if (nl) {
nl = memchr(iov[i].iov_base, '\n', iov[i].iov_len);
if (nl) {
diff --git
a/src/journal/journald-native.c
b/src/journal/journald-native.c
index 0f9af378cfd072dc7f8f87498cf920674c13e12d..c50cf64f5ce26641795b3f27cd6db108e6d0e837 100644
(file)
--- a/
src/journal/journald-native.c
+++ b/
src/journal/journald-native.c
@@
-154,23
+154,23
@@
void server_process_native_message(
* of this entry for the rate limiting
* logic */
if (l == 10 &&
* of this entry for the rate limiting
* logic */
if (l == 10 &&
-
hasprefix
(p, "PRIORITY=") &&
+
startswith
(p, "PRIORITY=") &&
p[9] >= '0' && p[9] <= '9')
priority = (priority & LOG_FACMASK) | (p[9] - '0');
else if (l == 17 &&
p[9] >= '0' && p[9] <= '9')
priority = (priority & LOG_FACMASK) | (p[9] - '0');
else if (l == 17 &&
-
hasprefix
(p, "SYSLOG_FACILITY=") &&
+
startswith
(p, "SYSLOG_FACILITY=") &&
p[16] >= '0' && p[16] <= '9')
priority = (priority & LOG_PRIMASK) | ((p[16] - '0') << 3);
else if (l == 18 &&
p[16] >= '0' && p[16] <= '9')
priority = (priority & LOG_PRIMASK) | ((p[16] - '0') << 3);
else if (l == 18 &&
-
hasprefix
(p, "SYSLOG_FACILITY=") &&
+
startswith
(p, "SYSLOG_FACILITY=") &&
p[16] >= '0' && p[16] <= '9' &&
p[17] >= '0' && p[17] <= '9')
priority = (priority & LOG_PRIMASK) | (((p[16] - '0')*10 + (p[17] - '0')) << 3);
else if (l >= 19 &&
p[16] >= '0' && p[16] <= '9' &&
p[17] >= '0' && p[17] <= '9')
priority = (priority & LOG_PRIMASK) | (((p[16] - '0')*10 + (p[17] - '0')) << 3);
else if (l >= 19 &&
-
hasprefix
(p, "SYSLOG_IDENTIFIER=")) {
+
startswith
(p, "SYSLOG_IDENTIFIER=")) {
char *t;
t = strndup(p + 18, l - 18);
char *t;
t = strndup(p + 18, l - 18);
@@
-179,7
+179,7
@@
void server_process_native_message(
identifier = t;
}
} else if (l >= 8 &&
identifier = t;
}
} else if (l >= 8 &&
-
hasprefix
(p, "MESSAGE=")) {
+
startswith
(p, "MESSAGE=")) {
char *t;
t = strndup(p + 8, l - 8);
char *t;
t = strndup(p + 8, l - 8);
@@
-189,7
+189,7
@@
void server_process_native_message(
}
} else if (l > strlen("OBJECT_PID=") &&
l < strlen("OBJECT_PID=") + DECIMAL_STR_MAX(pid_t) &&
}
} else if (l > strlen("OBJECT_PID=") &&
l < strlen("OBJECT_PID=") + DECIMAL_STR_MAX(pid_t) &&
-
hasprefix
(p, "OBJECT_PID=") &&
+
startswith
(p, "OBJECT_PID=") &&
allow_object_pid(ucred)) {
char buf[DECIMAL_STR_MAX(pid_t)];
memcpy(buf, p + strlen("OBJECT_PID="), l - strlen("OBJECT_PID="));
allow_object_pid(ucred)) {
char buf[DECIMAL_STR_MAX(pid_t)];
memcpy(buf, p + strlen("OBJECT_PID="), l - strlen("OBJECT_PID="));
diff --git
a/src/libsystemd-bus/bus-match.c
b/src/libsystemd-bus/bus-match.c
index 750acfe6d5386dcfad5ff31a6c9ce494baf5964d..1411167a7f4af4eb34368c36e458c639609f840f 100644
(file)
--- a/
src/libsystemd-bus/bus-match.c
+++ b/
src/libsystemd-bus/bus-match.c
@@
-555,22
+555,22
@@
static int bus_match_find_leaf(
enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n) {
assert(k);
enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n) {
assert(k);
- if (n == 4 &&
hasprefix
(k, "type"))
+ if (n == 4 &&
startswith
(k, "type"))
return BUS_MATCH_MESSAGE_TYPE;
return BUS_MATCH_MESSAGE_TYPE;
- if (n == 6 &&
hasprefix
(k, "sender"))
+ if (n == 6 &&
startswith
(k, "sender"))
return BUS_MATCH_SENDER;
return BUS_MATCH_SENDER;
- if (n == 11 &&
hasprefix
(k, "destination"))
+ if (n == 11 &&
startswith
(k, "destination"))
return BUS_MATCH_DESTINATION;
return BUS_MATCH_DESTINATION;
- if (n == 9 &&
hasprefix
(k, "interface"))
+ if (n == 9 &&
startswith
(k, "interface"))
return BUS_MATCH_INTERFACE;
return BUS_MATCH_INTERFACE;
- if (n == 6 &&
hasprefix
(k, "member"))
+ if (n == 6 &&
startswith
(k, "member"))
return BUS_MATCH_MEMBER;
return BUS_MATCH_MEMBER;
- if (n == 4 &&
hasprefix
(k, "path"))
+ if (n == 4 &&
startswith
(k, "path"))
return BUS_MATCH_PATH;
return BUS_MATCH_PATH;
- if (n == 14 &&
hasprefix
(k, "path_namespace"))
+ if (n == 14 &&
startswith
(k, "path_namespace"))
return BUS_MATCH_PATH_NAMESPACE;
return BUS_MATCH_PATH_NAMESPACE;
- if (n == 4 &&
hasprefix
(k, "arg")) {
+ if (n == 4 &&
startswith
(k, "arg")) {
int j;
j = undecchar(k[3]);
int j;
j = undecchar(k[3]);
@@
-580,7
+580,7
@@
enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return BUS_MATCH_ARG + j;
}
return BUS_MATCH_ARG + j;
}
- if (n == 5 &&
hasprefix
(k, "arg")) {
+ if (n == 5 &&
startswith
(k, "arg")) {
int a, b;
enum bus_match_node_type t;
int a, b;
enum bus_match_node_type t;
@@
-596,7
+596,7
@@
enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return t;
}
return t;
}
- if (n == 8 &&
hasprefix(k, "arg") && hasprefix
(k + 4, "path")) {
+ if (n == 8 &&
startswith(k, "arg") && startswith
(k + 4, "path")) {
int j;
j = undecchar(k[3]);
int j;
j = undecchar(k[3]);
@@
-606,7
+606,7
@@
enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return BUS_MATCH_ARG_PATH + j;
}
return BUS_MATCH_ARG_PATH + j;
}
- if (n == 9 &&
hasprefix(k, "arg") && hasprefix
(k + 5, "path")) {
+ if (n == 9 &&
startswith(k, "arg") && startswith
(k + 5, "path")) {
enum bus_match_node_type t;
int a, b;
enum bus_match_node_type t;
int a, b;
@@
-622,7
+622,7
@@
enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return t;
}
return t;
}
- if (n == 13 &&
hasprefix(k, "arg") && hasprefix
(k + 4, "namespace")) {
+ if (n == 13 &&
startswith(k, "arg") && startswith
(k + 4, "namespace")) {
int j;
j = undecchar(k[3]);
int j;
j = undecchar(k[3]);
@@
-632,7
+632,7
@@
enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return BUS_MATCH_ARG_NAMESPACE + j;
}
return BUS_MATCH_ARG_NAMESPACE + j;
}
- if (n == 14 &&
hasprefix(k, "arg") && hasprefix
(k + 5, "namespace")) {
+ if (n == 14 &&
startswith(k, "arg") && startswith
(k + 5, "namespace")) {
enum bus_match_node_type t;
int a, b;
enum bus_match_node_type t;
int a, b;
diff --git
a/src/shared/logs-show.c
b/src/shared/logs-show.c
index f0236eeae52244681daf70bf77a9ed034ba96c28..87633e78163652e50c1d7d29f10b6c29808339bd 100644
(file)
--- a/
src/shared/logs-show.c
+++ b/
src/shared/logs-show.c
@@
-536,7
+536,7
@@
static int output_export(
/* We already printed the boot id, from the data in
* the header, hence let's suppress it here */
if (length >= 9 &&
/* We already printed the boot id, from the data in
* the header, hence let's suppress it here */
if (length >= 9 &&
-
hasprefix
(data, "_BOOT_ID="))
+
startswith
(data, "_BOOT_ID="))
continue;
if (!utf8_is_printable(data, length)) {
continue;
if (!utf8_is_printable(data, length)) {
diff --git
a/src/shared/macro.h
b/src/shared/macro.h
index 0d3ff1cda578808ec2cb225ee4d97ce5ba213099..d4f92b60ec83ac37a88d932cf817d3d71413a308 100644
(file)
--- a/
src/shared/macro.h
+++ b/
src/shared/macro.h
@@
-186,8
+186,6
@@
static inline size_t ALIGN_TO(size_t l, size_t ali) {
#define char_array_0(x) x[sizeof(x)-1] = 0;
#define char_array_0(x) x[sizeof(x)-1] = 0;
-#define hasprefix(s, prefix) (memcmp(s, prefix, strlen(prefix)) == 0)
-
#define IOVEC_SET_STRING(i, s) \
do { \
struct iovec *_i = &(i); \
#define IOVEC_SET_STRING(i, s) \
do { \
struct iovec *_i = &(i); \