mirror of
https://github.com/systemd/systemd.git
synced 2025-01-05 13:18:06 +03:00
tree-wide: port various places over to STARTSWITH_SET()
This commit is contained in:
parent
52f1552073
commit
49fe5c0996
@ -44,9 +44,7 @@ static int find_pci_or_platform_parent(sd_device *device, sd_device **ret) {
|
||||
c += strspn(c, DIGITS);
|
||||
if (*c == '-') {
|
||||
/* A connector DRM device, let's ignore all but LVDS and eDP! */
|
||||
|
||||
if (!startswith(c, "-LVDS-") &&
|
||||
!startswith(c, "-Embedded DisplayPort-"))
|
||||
if (!STARTSWITH_SET(c, "-LVDS-", "-Embedded DisplayPort-"))
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
@ -919,8 +919,7 @@ bool valid_device_allow_pattern(const char *path) {
|
||||
/* Like valid_device_node_path(), but also allows full-subsystem expressions, like DeviceAllow= and DeviceDeny=
|
||||
* accept it */
|
||||
|
||||
if (startswith(path, "block-") ||
|
||||
startswith(path, "char-"))
|
||||
if (STARTSWITH_SET(path, "block-", "char-"))
|
||||
return true;
|
||||
|
||||
return valid_device_node_path(path);
|
||||
|
@ -3242,7 +3242,7 @@ int config_parse_device_allow(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!startswith(resolved, "block-") && !startswith(resolved, "char-")) {
|
||||
if (!STARTSWITH_SET(resolved, "block-", "char-")) {
|
||||
|
||||
r = path_simplify_and_warn(resolved, 0, unit, filename, line, lvalue);
|
||||
if (r < 0)
|
||||
|
@ -510,11 +510,9 @@ static int add_crypttab_devices(void) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uuid = startswith(device, "UUID=");
|
||||
uuid = STARTSWITH_SET(device, "UUID=", "luks-");
|
||||
if (!uuid)
|
||||
uuid = path_startswith(device, "/dev/disk/by-uuid/");
|
||||
if (!uuid)
|
||||
uuid = startswith(name, "luks-");
|
||||
if (uuid)
|
||||
d = hashmap_get(arg_disks, uuid);
|
||||
|
||||
|
@ -630,10 +630,9 @@ static int create_remoteserver(
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
hostname =
|
||||
startswith(arg_url, "https://") ?:
|
||||
startswith(arg_url, "http://") ?:
|
||||
arg_url;
|
||||
hostname = STARTSWITH_SET(arg_url, "https://", "http://");
|
||||
if (!hostname)
|
||||
hostname = arg_url;
|
||||
|
||||
hostname = strdupa(hostname);
|
||||
if ((p = strchr(hostname, '/')))
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "sigbus.h"
|
||||
#include "signal-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "util.h"
|
||||
|
||||
#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem"
|
||||
@ -408,7 +409,8 @@ static int setup_uploader(Uploader *u, const char *url, const char *state_file)
|
||||
memzero(u, sizeof(Uploader));
|
||||
u->input = -1;
|
||||
|
||||
if (!(host = startswith(url, "http://")) && !(host = startswith(url, "https://"))) {
|
||||
host = STARTSWITH_SET(url, "http://", "https://");
|
||||
if (!host) {
|
||||
host = url;
|
||||
proto = "https://";
|
||||
}
|
||||
|
@ -606,9 +606,8 @@ static int manager_count_external_displays(Manager *m) {
|
||||
return r;
|
||||
|
||||
FOREACH_DEVICE(e, d) {
|
||||
const char *status, *enabled, *dash, *nn, *subsys;
|
||||
sd_device *p;
|
||||
const char *status, *enabled, *dash, *nn, *i, *subsys;
|
||||
bool external = false;
|
||||
|
||||
if (sd_device_get_parent(d, &p) < 0)
|
||||
continue;
|
||||
@ -631,16 +630,10 @@ static int manager_count_external_displays(Manager *m) {
|
||||
continue;
|
||||
|
||||
dash++;
|
||||
FOREACH_STRING(i, "VGA-", "DVI-I-", "DVI-D-", "DVI-A-"
|
||||
"Composite-", "SVIDEO-", "Component-",
|
||||
"DIN-", "DP-", "HDMI-A-", "HDMI-B-", "TV-") {
|
||||
|
||||
if (startswith(dash, i)) {
|
||||
external = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!external)
|
||||
if (!STARTSWITH_SET(dash,
|
||||
"VGA-", "DVI-I-", "DVI-D-", "DVI-A-"
|
||||
"Composite-", "SVIDEO-", "Component-",
|
||||
"DIN-", "DP-", "HDMI-A-", "HDMI-B-", "TV-"))
|
||||
continue;
|
||||
|
||||
/* Ignore ports that are not enabled */
|
||||
|
@ -384,12 +384,13 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
return log_oom();
|
||||
|
||||
with_timer = with_timer ||
|
||||
!!startswith(optarg, "OnActiveSec=") ||
|
||||
!!startswith(optarg, "OnBootSec=") ||
|
||||
!!startswith(optarg, "OnStartupSec=") ||
|
||||
!!startswith(optarg, "OnUnitActiveSec=") ||
|
||||
!!startswith(optarg, "OnUnitInactiveSec=") ||
|
||||
!!startswith(optarg, "OnCalendar=");
|
||||
STARTSWITH_SET(optarg,
|
||||
"OnActiveSec=",
|
||||
"OnBootSec=",
|
||||
"OnStartupSec=",
|
||||
"OnUnitActiveSec=",
|
||||
"OnUnitInactiveSec=",
|
||||
"OnCalendar=");
|
||||
break;
|
||||
|
||||
case ARG_PATH_PROPERTY:
|
||||
|
@ -219,14 +219,11 @@ int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want
|
||||
STRV_FOREACH(entry, split) {
|
||||
char *p;
|
||||
|
||||
p = startswith(*entry, "default:");
|
||||
p = STARTSWITH_SET(*entry, "default:", "d:");
|
||||
if (!p)
|
||||
p = startswith(*entry, "d:");
|
||||
p = *entry;
|
||||
|
||||
if (p)
|
||||
r = strv_push(&d, p);
|
||||
else
|
||||
r = strv_push(&a, *entry);
|
||||
r = strv_push(&d, p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "utf8.h"
|
||||
#include "web-util.h"
|
||||
|
||||
@ -13,7 +14,7 @@ bool http_etag_is_valid(const char *etag) {
|
||||
if (!endswith(etag, "\""))
|
||||
return false;
|
||||
|
||||
if (!startswith(etag, "\"") && !startswith(etag, "W/\""))
|
||||
if (!STARTSWITH_SET(etag, "\"", "W/\""))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -25,9 +26,7 @@ bool http_url_is_valid(const char *url) {
|
||||
if (isempty(url))
|
||||
return false;
|
||||
|
||||
p = startswith(url, "http://");
|
||||
if (!p)
|
||||
p = startswith(url, "https://");
|
||||
p = STARTSWITH_SET(url, "http://", "https://");
|
||||
if (!p)
|
||||
return false;
|
||||
|
||||
@ -46,12 +45,7 @@ bool documentation_url_is_valid(const char *url) {
|
||||
if (http_url_is_valid(url))
|
||||
return true;
|
||||
|
||||
p = startswith(url, "file:/");
|
||||
if (!p)
|
||||
p = startswith(url, "info:");
|
||||
if (!p)
|
||||
p = startswith(url, "man:");
|
||||
|
||||
p = STARTSWITH_SET(url, "file:/", "info:", "man:");
|
||||
if (isempty(p))
|
||||
return false;
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "signal-util.h"
|
||||
#include "socket-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "strxcpyx.h"
|
||||
#include "syslog-util.h"
|
||||
#include "udev-builtin.h"
|
||||
@ -361,9 +362,7 @@ static int worker_lock_block_device(sd_device *dev, int *ret_fd) {
|
||||
if (r < 0)
|
||||
return log_device_debug_errno(dev, r, "Failed to get sysname: %m");
|
||||
|
||||
if (startswith(val, "dm-") ||
|
||||
startswith(val, "md") ||
|
||||
startswith(val, "drbd"))
|
||||
if (STARTSWITH_SET(val, "dm-", "md", "drbd"))
|
||||
return 0;
|
||||
|
||||
r = sd_device_get_devtype(dev, &val);
|
||||
|
Loading…
Reference in New Issue
Block a user