summaryrefslogtreecommitdiffstats
path: root/src/shared/dns-domain.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-23 13:56:19 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-03-23 13:57:59 +0100
commit007950dcd1618643e0862aa17732d0544ff520c6 (patch)
treeebd955d3a70c06ac6863bc6c549d1ee822fd45a5 /src/shared/dns-domain.c
parenttest: add tests for device id (diff)
downloadsystemd-007950dcd1618643e0862aa17732d0544ff520c6.tar.xz
systemd-007950dcd1618643e0862aa17732d0544ff520c6.zip
dns-domain: use PTR_SUB1() macro
Diffstat (limited to 'src/shared/dns-domain.c')
-rw-r--r--src/shared/dns-domain.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c
index 48395fea24..0ae1de1c5b 100644
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -168,24 +168,18 @@ int dns_label_unescape_suffix(const char *name, const char **label_terminal, cha
/* Skip current terminal character (and accept domain names ending it ".") */
if (*terminal == 0)
- terminal--;
+ terminal = PTR_SUB1(terminal, name);
if (terminal >= name && *terminal == '.')
- terminal--;
+ terminal = PTR_SUB1(terminal, name);
/* Point name to the last label, and terminal to the preceding terminal symbol (or make it a NULL pointer) */
- for (;;) {
- if (terminal < name) {
- /* Reached the first label, so indicate that there are no more */
- terminal = NULL;
- break;
- }
-
+ while (terminal) {
/* Find the start of the last label */
if (*terminal == '.') {
const char *y;
unsigned slashes = 0;
- for (y = terminal - 1; y >= name && *y == '\\'; y--)
+ for (y = PTR_SUB1(terminal, name); y && *y == '\\'; y = PTR_SUB1(y, name))
slashes++;
if (slashes % 2 == 0) {
@@ -198,7 +192,7 @@ int dns_label_unescape_suffix(const char *name, const char **label_terminal, cha
}
}
- terminal--;
+ terminal = PTR_SUB1(terminal, name);
}
r = dns_label_unescape(&name, dest, sz, 0);