]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/busctl/busctl-introspect.c
Merge pull request #17549 from yuwata/tiny-fixes
[thirdparty/systemd.git] / src / busctl / busctl-introspect.c
index 54d6e07d2c38f5319478031585595f3c14252b3b..7a5d57f8c83705b331213d088f2e2d65953899b5 100644 (file)
@@ -1,27 +1,10 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "sd-bus.h"
 
 #include "alloc-util.h"
 #include "busctl-introspect.h"
+#include "path-util.h"
 #include "string-util.h"
 #include "util.h"
 #include "xml.h"
@@ -85,10 +68,9 @@ static int parse_xml_annotation(Context *context, uint64_t *flags) {
                         return t;
                 }
 
-                if (t == XML_END) {
-                        log_error("Premature end of XML data.");
-                        return -EBADMSG;
-                }
+                if (t == XML_END)
+                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                               "Premature end of XML data.");
 
                 switch (state) {
 
@@ -102,10 +84,10 @@ static int parse_xml_annotation(Context *context, uint64_t *flags) {
                                 else if (streq_ptr(name, "value"))
                                         state = STATE_VALUE;
 
-                                else {
-                                        log_error("Unexpected <annotation> attribute %s.", name);
-                                        return -EBADMSG;
-                                }
+                                else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                                               "Unexpected <annotation> attribute %s.",
+                                                               name);
 
                         } else if (t == XML_TAG_CLOSE_EMPTY ||
                                    (t == XML_TAG_CLOSE && streq_ptr(name, "annotation"))) {
@@ -134,10 +116,9 @@ static int parse_xml_annotation(Context *context, uint64_t *flags) {
 
                                 return 0;
 
-                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE)) {
-                                log_error("Unexpected token in <annotation>. (1)");
-                                return -EINVAL;
-                        }
+                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE))
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <annotation>. (1)");
 
                         break;
 
@@ -147,10 +128,9 @@ static int parse_xml_annotation(Context *context, uint64_t *flags) {
                                 free_and_replace(field, name);
 
                                 state = STATE_ANNOTATION;
-                        } else {
-                                log_error("Unexpected token in <annotation>. (2)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <annotation>. (2)");
 
                         break;
 
@@ -160,10 +140,9 @@ static int parse_xml_annotation(Context *context, uint64_t *flags) {
                                 free_and_replace(value, name);
 
                                 state = STATE_ANNOTATION;
-                        } else {
-                                log_error("Unexpected token in <annotation>. (3)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <annotation>. (3)");
 
                         break;
 
@@ -205,10 +184,8 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
         assert(context);
         assert(prefix);
 
-        if (n_depth > NODE_DEPTH_MAX) {
-                log_error("<node> depth too high.");
-                return -EINVAL;
-        }
+        if (n_depth > NODE_DEPTH_MAX)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "<node> depth too high.");
 
         for (;;) {
                 _cleanup_free_ char *name = NULL;
@@ -220,10 +197,8 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                         return t;
                 }
 
-                if (t == XML_END) {
-                        log_error("Premature end of XML data.");
-                        return -EBADMSG;
-                }
+                if (t == XML_END)
+                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Premature end of XML data.");
 
                 switch (state) {
 
@@ -232,10 +207,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
 
                                 if (streq_ptr(name, "name"))
                                         state = STATE_NODE_NAME;
-                                else {
-                                        log_error("Unexpected <node> attribute %s.", name);
-                                        return -EBADMSG;
-                                }
+                                else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                                               "Unexpected <node> attribute %s.", name);
 
                         } else if (t == XML_TAG_OPEN) {
 
@@ -246,10 +220,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         r = parse_xml_node(context, np, n_depth+1);
                                         if (r < 0)
                                                 return r;
-                                } else {
-                                        log_error("Unexpected <node> tag %s.", name);
-                                        return -EBADMSG;
-                                }
+                                } else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                                               "Unexpected <node> tag %s.", name);
 
                         } else if (t == XML_TAG_CLOSE_EMPTY ||
                                    (t == XML_TAG_CLOSE && streq_ptr(name, "node"))) {
@@ -262,10 +235,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
 
                                 return 0;
 
-                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE)) {
-                                log_error("Unexpected token in <node>. (1)");
-                                return -EINVAL;
-                        }
+                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE))
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <node>. (1)");
 
                         break;
 
@@ -275,25 +247,20 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
 
                                 free(node_path);
 
-                                if (name[0] == '/') {
-                                        node_path = name;
-                                        name = NULL;
-                                } else {
+                                if (name[0] == '/')
+                                        node_path = TAKE_PTR(name);
+                                else {
 
-                                        if (endswith(prefix, "/"))
-                                                node_path = strappend(prefix, name);
-                                        else
-                                                node_path = strjoin(prefix, "/", name);
+                                        node_path = path_join(prefix, name);
                                         if (!node_path)
                                                 return log_oom();
                                 }
 
                                 np = node_path;
                                 state = STATE_NODE;
-                        } else {
-                                log_error("Unexpected token in <node>. (2)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <node>. (2)");
 
                         break;
 
@@ -302,10 +269,10 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                         if (t == XML_ATTRIBUTE_NAME) {
                                 if (streq_ptr(name, "name"))
                                         state = STATE_INTERFACE_NAME;
-                                else {
-                                        log_error("Unexpected <interface> attribute %s.", name);
-                                        return -EBADMSG;
-                                }
+                                else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                                               "Unexpected <interface> attribute %s.",
+                                                               name);
 
                         } else if (t == XML_TAG_OPEN) {
                                 if (streq_ptr(name, "method"))
@@ -319,10 +286,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         r = parse_xml_annotation(context, &context->interface_flags);
                                         if (r < 0)
                                                 return r;
-                                } else {
-                                        log_error("Unexpected <interface> tag %s.", name);
-                                        return -EINVAL;
-                                }
+                                } else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                               "Unexpected <interface> tag %s.", name);
                         } else if (t == XML_TAG_CLOSE_EMPTY ||
                                    (t == XML_TAG_CLOSE && streq_ptr(name, "interface"))) {
 
@@ -338,10 +304,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
 
                                 state = STATE_NODE;
 
-                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE)) {
-                                log_error("Unexpected token in <interface>. (1)");
-                                return -EINVAL;
-                        }
+                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE))
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <interface>. (1)");
 
                         break;
 
@@ -352,10 +317,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         free_and_replace(context->interface_name, name);
 
                                 state = STATE_INTERFACE;
-                        } else {
-                                log_error("Unexpected token in <interface>. (2)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <interface>. (2)");
 
                         break;
 
@@ -364,10 +328,10 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                         if (t == XML_ATTRIBUTE_NAME) {
                                 if (streq_ptr(name, "name"))
                                         state = STATE_METHOD_NAME;
-                                else {
-                                        log_error("Unexpected <method> attribute %s", name);
-                                        return -EBADMSG;
-                                }
+                                else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                                               "Unexpected <method> attribute %s",
+                                                               name);
                         } else if (t == XML_TAG_OPEN) {
                                 if (streq_ptr(name, "arg"))
                                         state = STATE_METHOD_ARG;
@@ -375,10 +339,10 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         r = parse_xml_annotation(context, &context->member_flags);
                                         if (r < 0)
                                                 return r;
-                                } else {
-                                        log_error("Unexpected <method> tag %s.", name);
-                                        return -EINVAL;
-                                }
+                                } else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                               "Unexpected <method> tag %s.",
+                                                               name);
                         } else if (t == XML_TAG_CLOSE_EMPTY ||
                                    (t == XML_TAG_CLOSE && streq_ptr(name, "method"))) {
 
@@ -394,10 +358,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
 
                                 state = STATE_INTERFACE;
 
-                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE)) {
-                                log_error("Unexpected token in <method> (1).");
-                                return -EINVAL;
-                        }
+                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE))
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <method> (1).");
 
                         break;
 
@@ -408,10 +371,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         free_and_replace(context->member_name, name);
 
                                 state = STATE_METHOD;
-                        } else {
-                                log_error("Unexpected token in <method> (2).");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <method> (2).");
 
                         break;
 
@@ -424,19 +386,19 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         state = STATE_METHOD_ARG_TYPE;
                                 else if (streq_ptr(name, "direction"))
                                         state = STATE_METHOD_ARG_DIRECTION;
-                                else {
-                                        log_error("Unexpected method <arg> attribute %s.", name);
-                                        return -EBADMSG;
-                                }
+                                else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                                               "Unexpected method <arg> attribute %s.",
+                                                               name);
                         } else if (t == XML_TAG_OPEN) {
                                 if (streq_ptr(name, "annotation")) {
                                         r = parse_xml_annotation(context, NULL);
                                         if (r < 0)
                                                 return r;
-                                } else {
-                                        log_error("Unexpected method <arg> tag %s.", name);
-                                        return -EINVAL;
-                                }
+                                } else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                               "Unexpected method <arg> tag %s.",
+                                                               name);
                         } else if (t == XML_TAG_CLOSE_EMPTY ||
                                    (t == XML_TAG_CLOSE && streq_ptr(name, "arg"))) {
 
@@ -458,10 +420,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                 }
 
                                 state = STATE_METHOD;
-                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE)) {
-                                log_error("Unexpected token in method <arg>. (1)");
-                                return -EINVAL;
-                        }
+                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE))
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in method <arg>. (1)");
 
                         break;
 
@@ -469,10 +430,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
 
                         if (t == XML_ATTRIBUTE_VALUE)
                                 state = STATE_METHOD_ARG;
-                        else {
-                                log_error("Unexpected token in method <arg>. (2)");
-                                return -EINVAL;
-                        }
+                        else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in method <arg>. (2)");
 
                         break;
 
@@ -482,10 +442,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                 free_and_replace(argument_type, name);
 
                                 state = STATE_METHOD_ARG;
-                        } else {
-                                log_error("Unexpected token in method <arg>. (3)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in method <arg>. (3)");
 
                         break;
 
@@ -495,10 +454,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                 free_and_replace(argument_direction, name);
 
                                 state = STATE_METHOD_ARG;
-                        } else {
-                                log_error("Unexpected token in method <arg>. (4)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in method <arg>. (4)");
 
                         break;
 
@@ -507,10 +465,10 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                         if (t == XML_ATTRIBUTE_NAME) {
                                 if (streq_ptr(name, "name"))
                                         state = STATE_SIGNAL_NAME;
-                                else {
-                                        log_error("Unexpected <signal> attribute %s.", name);
-                                        return -EBADMSG;
-                                }
+                                else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                                               "Unexpected <signal> attribute %s.",
+                                                               name);
                         } else if (t == XML_TAG_OPEN) {
                                 if (streq_ptr(name, "arg"))
                                         state = STATE_SIGNAL_ARG;
@@ -518,10 +476,10 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         r = parse_xml_annotation(context, &context->member_flags);
                                         if (r < 0)
                                                 return r;
-                                } else {
-                                        log_error("Unexpected <signal> tag %s.", name);
-                                        return -EINVAL;
-                                }
+                                } else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                               "Unexpected <signal> tag %s.",
+                                                               name);
                         } else if (t == XML_TAG_CLOSE_EMPTY ||
                                    (t == XML_TAG_CLOSE && streq_ptr(name, "signal"))) {
 
@@ -537,10 +495,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
 
                                 state = STATE_INTERFACE;
 
-                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE)) {
-                                log_error("Unexpected token in <signal>. (1)");
-                                return -EINVAL;
-                        }
+                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE))
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <signal>. (1)");
 
                         break;
 
@@ -551,14 +508,12 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         free_and_replace(context->member_name, name);
 
                                 state = STATE_SIGNAL;
-                        } else {
-                                log_error("Unexpected token in <signal>. (2)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <signal>. (2)");
 
                         break;
 
-
                 case STATE_SIGNAL_ARG:
 
                         if (t == XML_ATTRIBUTE_NAME) {
@@ -568,19 +523,19 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         state = STATE_SIGNAL_ARG_TYPE;
                                 else if (streq_ptr(name, "direction"))
                                         state = STATE_SIGNAL_ARG_DIRECTION;
-                                else {
-                                        log_error("Unexpected signal <arg> attribute %s.", name);
-                                        return -EBADMSG;
-                                }
+                                else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                                               "Unexpected signal <arg> attribute %s.",
+                                                               name);
                         } else if (t == XML_TAG_OPEN) {
                                 if (streq_ptr(name, "annotation")) {
                                         r = parse_xml_annotation(context, NULL);
                                         if (r < 0)
                                                 return r;
-                                } else {
-                                        log_error("Unexpected signal <arg> tag %s.", name);
-                                        return -EINVAL;
-                                }
+                                } else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                               "Unexpected signal <arg> tag %s.",
+                                                               name);
                         } else if (t == XML_TAG_CLOSE_EMPTY ||
                                    (t == XML_TAG_CLOSE && streq_ptr(name, "arg"))) {
 
@@ -595,10 +550,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                 }
 
                                 state = STATE_SIGNAL;
-                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE)) {
-                                log_error("Unexpected token in signal <arg> (1).");
-                                return -EINVAL;
-                        }
+                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE))
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in signal <arg> (1).");
 
                         break;
 
@@ -606,10 +560,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
 
                         if (t == XML_ATTRIBUTE_VALUE)
                                 state = STATE_SIGNAL_ARG;
-                        else {
-                                log_error("Unexpected token in signal <arg> (2).");
-                                return -EINVAL;
-                        }
+                        else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in signal <arg> (2).");
 
                         break;
 
@@ -619,10 +572,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                 free_and_replace(argument_type, name);
 
                                 state = STATE_SIGNAL_ARG;
-                        } else {
-                                log_error("Unexpected token in signal <arg> (3).");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in signal <arg> (3).");
 
                         break;
 
@@ -632,10 +584,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                 free_and_replace(argument_direction, name);
 
                                 state = STATE_SIGNAL_ARG;
-                        } else {
-                                log_error("Unexpected token in signal <arg>. (4)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in signal <arg>. (4)");
 
                         break;
 
@@ -648,20 +599,20 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         state  = STATE_PROPERTY_TYPE;
                                 else if (streq_ptr(name, "access"))
                                         state  = STATE_PROPERTY_ACCESS;
-                                else {
-                                        log_error("Unexpected <property> attribute %s.", name);
-                                        return -EBADMSG;
-                                }
+                                else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EBADMSG),
+                                                               "Unexpected <property> attribute %s.",
+                                                               name);
                         } else if (t == XML_TAG_OPEN) {
 
                                 if (streq_ptr(name, "annotation")) {
                                         r = parse_xml_annotation(context, &context->member_flags);
                                         if (r < 0)
                                                 return r;
-                                } else {
-                                        log_error("Unexpected <property> tag %s.", name);
-                                        return -EINVAL;
-                                }
+                                } else
+                                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                               "Unexpected <property> tag %s.",
+                                                               name);
 
                         } else if (t == XML_TAG_CLOSE_EMPTY ||
                                    (t == XML_TAG_CLOSE && streq_ptr(name, "property"))) {
@@ -678,10 +629,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
 
                                 state = STATE_INTERFACE;
 
-                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE)) {
-                                log_error("Unexpected token in <property>. (1)");
-                                return -EINVAL;
-                        }
+                        } else if (t != XML_TEXT || !in_charset(name, WHITESPACE))
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <property>. (1)");
 
                         break;
 
@@ -692,10 +642,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         free_and_replace(context->member_name, name);
 
                                 state = STATE_PROPERTY;
-                        } else {
-                                log_error("Unexpected token in <property>. (2)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <property>. (2)");
 
                         break;
 
@@ -706,10 +655,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         free_and_replace(context->member_signature, name);
 
                                 state = STATE_PROPERTY;
-                        } else {
-                                log_error("Unexpected token in <property>. (3)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <property>. (3)");
 
                         break;
 
@@ -721,10 +669,9 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
                                         context->member_writable = true;
 
                                 state = STATE_PROPERTY;
-                        } else {
-                                log_error("Unexpected token in <property>. (4)");
-                                return -EINVAL;
-                        }
+                        } else
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Unexpected token in <property>. (4)");
 
                         break;
                 }