From 42efe5be1ddac120897d77b8735fca5cda2ac9e5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 27 Aug 2024 10:20:03 +0900 Subject: [PATCH] tree-wide: drop msg argument for DEFINE_CONFIG_PARSE() macro and friends This makes the macros use log_syntax_parse_error(), hopefully which provides more informative log message in general, and reduces binary size. --- src/core/load-fragment.c | 64 +++++++++++----------- src/core/main.c | 2 +- src/coredump/coredump.c | 2 +- src/home/homed-conf.c | 2 +- src/journal-remote/journal-remote-main.c | 5 +- src/journal/journald-server.c | 4 +- src/login/logind-action.c | 2 +- src/network/netdev/bareudp.c | 3 +- src/network/netdev/batadv.c | 6 +- src/network/netdev/bond.c | 17 +++--- src/network/netdev/bridge.c | 3 +- src/network/netdev/fou-tunnel.c | 3 +- src/network/netdev/geneve.c | 2 +- src/network/netdev/ipoib.c | 2 +- src/network/netdev/ipvlan.c | 4 +- src/network/netdev/l2tp-tunnel.c | 2 +- src/network/netdev/macvlan.c | 2 +- src/network/netdev/tunnel.c | 2 +- src/network/netdev/vxlan.c | 2 +- src/network/networkd-dhcp4.c | 3 +- src/network/networkd-dhcp6.c | 3 +- src/network/networkd-dns.c | 2 +- src/network/networkd-ipv6ll.c | 3 +- src/network/networkd-lldp-rx.c | 2 +- src/network/networkd-ndisc.c | 3 +- src/network/networkd-network.c | 9 +-- src/network/networkd-routing-policy-rule.c | 3 +- src/network/networkd-sysctl.c | 6 +- src/network/networkd-util.c | 3 +- src/nspawn/nspawn-settings.c | 8 +-- src/partition/repart.c | 6 +- src/pstore/pstore.c | 2 +- src/resolve/resolved-conf.c | 2 +- src/shared/conf-parser.c | 8 +-- src/shared/conf-parser.h | 58 ++++++++------------ src/shared/ethtool-util.c | 4 +- src/shared/resolve-util.c | 8 +-- src/sysupdate/sysupdate-transfer.c | 4 +- src/udev/net/link-config.c | 9 +-- src/udev/udevd.c | 2 +- 40 files changed, 120 insertions(+), 157 deletions(-) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 7633589b0d4..cc6597dbb7b 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -126,38 +126,38 @@ int parse_confirm_spawn(const char *value, char **console) { return 0; } -DEFINE_CONFIG_PARSE(config_parse_socket_protocol, parse_socket_protocol, "Failed to parse socket protocol"); -DEFINE_CONFIG_PARSE(config_parse_exec_secure_bits, secure_bits_from_string, "Failed to parse secure bits"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_collect_mode, collect_mode, CollectMode, "Failed to parse garbage collection mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_device_policy, cgroup_device_policy, CGroupDevicePolicy, "Failed to parse device policy"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_keyring_mode, exec_keyring_mode, ExecKeyringMode, "Failed to parse keyring mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_proc, protect_proc, ProtectProc, "Failed to parse /proc/ protection mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_proc_subset, proc_subset, ProcSubset, "Failed to parse /proc/ subset mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_private_tmp, private_tmp, PrivateTmp, "Failed to parse private tmp value"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_utmp_mode, exec_utmp_mode, ExecUtmpMode, "Failed to parse utmp mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_job_mode, job_mode, JobMode, "Failed to parse job mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_notify_access, notify_access, NotifyAccess, "Failed to parse notify access specifier"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_home, protect_home, ProtectHome, "Failed to parse protect home value"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_system, protect_system, ProtectSystem, "Failed to parse protect system value"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_preserve_mode, exec_preserve_mode, ExecPreserveMode, "Failed to parse resource preserve mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_service_type, service_type, ServiceType, "Failed to parse service type"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_service_exit_type, service_exit_type, ServiceExitType, "Failed to parse service exit type"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_service_restart, service_restart, ServiceRestart, "Failed to parse service restart specifier"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_service_restart_mode, service_restart_mode, ServiceRestartMode, "Failed to parse service restart mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_service_timeout_failure_mode, service_timeout_failure_mode, ServiceTimeoutFailureMode, "Failed to parse timeout failure mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_socket_bind, socket_address_bind_ipv6_only_or_bool, SocketAddressBindIPv6Only, "Failed to parse bind IPv6 only value"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_oom_policy, oom_policy, OOMPolicy, "Failed to parse OOM policy"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_managed_oom_preference, managed_oom_preference, ManagedOOMPreference, "Failed to parse ManagedOOMPreference="); -DEFINE_CONFIG_PARSE_ENUM(config_parse_memory_pressure_watch, cgroup_pressure_watch, CGroupPressureWatch, "Failed to parse memory pressure watch setting"); -DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_ip_tos, ip_tos, int, -1, "Failed to parse IP TOS value"); -DEFINE_CONFIG_PARSE_PTR(config_parse_blockio_weight, cg_blkio_weight_parse, uint64_t, "Invalid block IO weight"); -DEFINE_CONFIG_PARSE_PTR(config_parse_cg_weight, cg_weight_parse, uint64_t, "Invalid weight"); -DEFINE_CONFIG_PARSE_PTR(config_parse_cg_cpu_weight, cg_cpu_weight_parse, uint64_t, "Invalid CPU weight"); -static DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares_internal, cg_cpu_shares_parse, uint64_t, "Invalid CPU shares"); -DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_propagation_flag, mount_propagation_flag_from_string, unsigned long, "Failed to parse mount propagation flag"); -DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_numa_policy, mpol, int, -1, "Invalid NUMA policy type"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_status_unit_format, status_unit_format, StatusUnitFormat, "Failed to parse status unit format"); -DEFINE_CONFIG_PARSE_ENUM_FULL(config_parse_socket_timestamping, socket_timestamping_from_string_harder, SocketTimestamping, "Failed to parse timestamping precision"); +DEFINE_CONFIG_PARSE(config_parse_socket_protocol, parse_socket_protocol); +DEFINE_CONFIG_PARSE(config_parse_exec_secure_bits, secure_bits_from_string); +DEFINE_CONFIG_PARSE_ENUM(config_parse_collect_mode, collect_mode, CollectMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_device_policy, cgroup_device_policy, CGroupDevicePolicy); +DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_keyring_mode, exec_keyring_mode, ExecKeyringMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_proc, protect_proc, ProtectProc); +DEFINE_CONFIG_PARSE_ENUM(config_parse_proc_subset, proc_subset, ProcSubset); +DEFINE_CONFIG_PARSE_ENUM(config_parse_private_tmp, private_tmp, PrivateTmp); +DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_utmp_mode, exec_utmp_mode, ExecUtmpMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_job_mode, job_mode, JobMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_notify_access, notify_access, NotifyAccess); +DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_home, protect_home, ProtectHome); +DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_system, protect_system, ProtectSystem); +DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_preserve_mode, exec_preserve_mode, ExecPreserveMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_service_type, service_type, ServiceType); +DEFINE_CONFIG_PARSE_ENUM(config_parse_service_exit_type, service_exit_type, ServiceExitType); +DEFINE_CONFIG_PARSE_ENUM(config_parse_service_restart, service_restart, ServiceRestart); +DEFINE_CONFIG_PARSE_ENUM(config_parse_service_restart_mode, service_restart_mode, ServiceRestartMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_service_timeout_failure_mode, service_timeout_failure_mode, ServiceTimeoutFailureMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_socket_bind, socket_address_bind_ipv6_only_or_bool, SocketAddressBindIPv6Only); +DEFINE_CONFIG_PARSE_ENUM(config_parse_oom_policy, oom_policy, OOMPolicy); +DEFINE_CONFIG_PARSE_ENUM(config_parse_managed_oom_preference, managed_oom_preference, ManagedOOMPreference); +DEFINE_CONFIG_PARSE_ENUM(config_parse_memory_pressure_watch, cgroup_pressure_watch, CGroupPressureWatch); +DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_ip_tos, ip_tos, int, -1); +DEFINE_CONFIG_PARSE_PTR(config_parse_blockio_weight, cg_blkio_weight_parse, uint64_t); +DEFINE_CONFIG_PARSE_PTR(config_parse_cg_weight, cg_weight_parse, uint64_t); +DEFINE_CONFIG_PARSE_PTR(config_parse_cg_cpu_weight, cg_cpu_weight_parse, uint64_t); +static DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares_internal, cg_cpu_shares_parse, uint64_t); +DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_propagation_flag, mount_propagation_flag_from_string, unsigned long); +DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_numa_policy, mpol, int, -1); +DEFINE_CONFIG_PARSE_ENUM(config_parse_status_unit_format, status_unit_format, StatusUnitFormat); +DEFINE_CONFIG_PARSE_ENUM_FULL(config_parse_socket_timestamping, socket_timestamping_from_string_harder, SocketTimestamping); int config_parse_cpu_shares( const char *unit, diff --git a/src/core/main.c b/src/core/main.c index 14c124dc32c..b9dc4506366 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -174,7 +174,7 @@ static const char* const crash_action_table[_CRASH_ACTION_MAX] = { DEFINE_STRING_TABLE_LOOKUP(crash_action, CrashAction); -static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_crash_action, crash_action, CrashAction, CRASH_FREEZE, "Invalid crash action"); +static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_crash_action, crash_action, CrashAction, CRASH_FREEZE); static int manager_find_user_config_paths(char ***ret_files, char ***ret_dirs) { _cleanup_free_ char *base = NULL; diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index e751b67417b..d21ea680bd9 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -158,7 +158,7 @@ static const char* const coredump_storage_table[_COREDUMP_STORAGE_MAX] = { }; DEFINE_PRIVATE_STRING_TABLE_LOOKUP(coredump_storage, CoredumpStorage); -static DEFINE_CONFIG_PARSE_ENUM(config_parse_coredump_storage, coredump_storage, CoredumpStorage, "Failed to parse storage setting"); +static DEFINE_CONFIG_PARSE_ENUM(config_parse_coredump_storage, coredump_storage, CoredumpStorage); static CoredumpStorage arg_storage = COREDUMP_STORAGE_EXTERNAL; static bool arg_compress = true; diff --git a/src/home/homed-conf.c b/src/home/homed-conf.c index 3f74096b648..21cb5106881 100644 --- a/src/home/homed-conf.c +++ b/src/home/homed-conf.c @@ -17,7 +17,7 @@ int manager_parse_config_file(Manager *m) { m); } -DEFINE_CONFIG_PARSE_ENUM(config_parse_default_storage, user_storage, UserStorage, "Failed to parse default storage setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_default_storage, user_storage, UserStorage); int config_parse_default_file_system_type( const char *unit, diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c index 1cc978d383e..7156bc7727e 100644 --- a/src/journal-remote/journal-remote-main.c +++ b/src/journal-remote/journal-remote-main.c @@ -72,10 +72,7 @@ static const char* const journal_write_split_mode_table[_JOURNAL_WRITE_SPLIT_MAX }; DEFINE_PRIVATE_STRING_TABLE_LOOKUP(journal_write_split_mode, JournalWriteSplitMode); -static DEFINE_CONFIG_PARSE_ENUM(config_parse_write_split_mode, - journal_write_split_mode, - JournalWriteSplitMode, - "Failed to parse split mode setting"); +static DEFINE_CONFIG_PARSE_ENUM(config_parse_write_split_mode, journal_write_split_mode, JournalWriteSplitMode); /********************************************************************** ********************************************************************** diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 09b80881b33..66f09e49453 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -2953,7 +2953,7 @@ static const char* const storage_table[_STORAGE_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP(storage, Storage); -DEFINE_CONFIG_PARSE_ENUM(config_parse_storage, storage, Storage, "Failed to parse storage setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_storage, storage, Storage); static const char* const split_mode_table[_SPLIT_MAX] = { [SPLIT_LOGIN] = "login", @@ -2962,7 +2962,7 @@ static const char* const split_mode_table[_SPLIT_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP(split_mode, SplitMode); -DEFINE_CONFIG_PARSE_ENUM(config_parse_split_mode, split_mode, SplitMode, "Failed to parse split mode setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_split_mode, split_mode, SplitMode); int config_parse_line_max( const char* unit, diff --git a/src/login/logind-action.c b/src/login/logind-action.c index 2a7766841f4..db9a0e1bbae 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -438,7 +438,7 @@ static const char* const handle_action_table[_HANDLE_ACTION_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP(handle_action, HandleAction); -DEFINE_CONFIG_PARSE_ENUM(config_parse_handle_action, handle_action, HandleAction, "Failed to parse handle action setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_handle_action, handle_action, HandleAction); int config_parse_handle_action_sleep( const char *unit, diff --git a/src/network/netdev/bareudp.c b/src/network/netdev/bareudp.c index fdde8815208..b2a161ee7a3 100644 --- a/src/network/netdev/bareudp.c +++ b/src/network/netdev/bareudp.c @@ -17,8 +17,7 @@ static const char* const bare_udp_protocol_table[_BARE_UDP_PROTOCOL_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP(bare_udp_protocol, BareUDPProtocol); -DEFINE_CONFIG_PARSE_ENUM(config_parse_bare_udp_iftype, bare_udp_protocol, BareUDPProtocol, - "Failed to parse EtherType="); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bare_udp_iftype, bare_udp_protocol, BareUDPProtocol); static int netdev_bare_udp_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) { assert(m); diff --git a/src/network/netdev/batadv.c b/src/network/netdev/batadv.c index 26da0231d45..e600727c200 100644 --- a/src/network/netdev/batadv.c +++ b/src/network/netdev/batadv.c @@ -47,12 +47,10 @@ static const char* const batadv_routing_algorithm_kernel_table[_BATADV_ROUTING_A }; DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(batadv_gateway_mode, BatadvGatewayModes); -DEFINE_CONFIG_PARSE_ENUM(config_parse_batadv_gateway_mode, batadv_gateway_mode, BatadvGatewayModes, - "Failed to parse GatewayMode="); +DEFINE_CONFIG_PARSE_ENUM(config_parse_batadv_gateway_mode, batadv_gateway_mode, BatadvGatewayModes); DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(batadv_routing_algorithm, BatadvRoutingAlgorithm); -DEFINE_CONFIG_PARSE_ENUM(config_parse_batadv_routing_algorithm, batadv_routing_algorithm, BatadvRoutingAlgorithm, - "Failed to parse RoutingAlgorithm="); +DEFINE_CONFIG_PARSE_ENUM(config_parse_batadv_routing_algorithm, batadv_routing_algorithm, BatadvRoutingAlgorithm); DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(batadv_routing_algorithm_kernel, BatadvRoutingAlgorithm); diff --git a/src/network/netdev/bond.c b/src/network/netdev/bond.c index 52a7f126b6d..de122f8eb38 100644 --- a/src/network/netdev/bond.c +++ b/src/network/netdev/bond.c @@ -44,17 +44,16 @@ #define GRATUITOUS_ARP_MAX 255 #define GRATUITOUS_ARP_DEFAULT 1 -DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_mode, bond_mode, BondMode, "Failed to parse bond mode"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_mode, bond_mode, BondMode); DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_xmit_hash_policy, bond_xmit_hash_policy, - BondXmitHashPolicy, - "Failed to parse bond transmit hash policy"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_lacp_rate, bond_lacp_rate, BondLacpRate, "Failed to parse bond lacp rate"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_ad_select, bond_ad_select, BondAdSelect, "Failed to parse bond AD select"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_fail_over_mac, bond_fail_over_mac, BondFailOverMac, "Failed to parse bond fail over MAC"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_arp_validate, bond_arp_validate, BondArpValidate, "Failed to parse bond arp validate"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_arp_all_targets, bond_arp_all_targets, BondArpAllTargets, "Failed to parse bond Arp all targets"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_primary_reselect, bond_primary_reselect, BondPrimaryReselect, "Failed to parse bond primary reselect"); + BondXmitHashPolicy); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_lacp_rate, bond_lacp_rate, BondLacpRate); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_ad_select, bond_ad_select, BondAdSelect); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_fail_over_mac, bond_fail_over_mac, BondFailOverMac); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_arp_validate, bond_arp_validate, BondArpValidate); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_arp_all_targets, bond_arp_all_targets, BondArpAllTargets); +DEFINE_CONFIG_PARSE_ENUM(config_parse_bond_primary_reselect, bond_primary_reselect, BondPrimaryReselect); static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) { assert(!link); diff --git a/src/network/netdev/bridge.c b/src/network/netdev/bridge.c index 27f39164767..25b0f81aa07 100644 --- a/src/network/netdev/bridge.c +++ b/src/network/netdev/bridge.c @@ -25,8 +25,7 @@ static const char* const multicast_router_table[_MULTICAST_ROUTER_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(multicast_router, MulticastRouter, _MULTICAST_ROUTER_INVALID); -DEFINE_CONFIG_PARSE_ENUM(config_parse_multicast_router, multicast_router, MulticastRouter, - "Failed to parse bridge multicast router setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_multicast_router, multicast_router, MulticastRouter); /* callback for bridge netdev's parameter set */ static int netdev_bridge_set_handler(sd_netlink *rtnl, sd_netlink_message *m, NetDev *netdev) { diff --git a/src/network/netdev/fou-tunnel.c b/src/network/netdev/fou-tunnel.c index 969a4e6de64..e962c6c64be 100644 --- a/src/network/netdev/fou-tunnel.c +++ b/src/network/netdev/fou-tunnel.c @@ -21,8 +21,7 @@ static const char* const fou_encap_type_table[_NETDEV_FOO_OVER_UDP_ENCAP_MAX] = }; DEFINE_STRING_TABLE_LOOKUP(fou_encap_type, FooOverUDPEncapType); -DEFINE_CONFIG_PARSE_ENUM(config_parse_fou_encap_type, fou_encap_type, FooOverUDPEncapType, - "Failed to parse Encapsulation="); +DEFINE_CONFIG_PARSE_ENUM(config_parse_fou_encap_type, fou_encap_type, FooOverUDPEncapType); static int netdev_fill_fou_tunnel_message(NetDev *netdev, sd_netlink_message *m) { FouTunnel *t = FOU(netdev); diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c index 22c2b00e1b7..493edcc42a5 100644 --- a/src/network/netdev/geneve.c +++ b/src/network/netdev/geneve.c @@ -26,7 +26,7 @@ static const char* const geneve_df_table[_NETDEV_GENEVE_DF_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(geneve_df, GeneveDF, NETDEV_GENEVE_DF_YES); -DEFINE_CONFIG_PARSE_ENUM(config_parse_geneve_df, geneve_df, GeneveDF, "Failed to parse Geneve IPDoNotFragment= setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_geneve_df, geneve_df, GeneveDF); static int netdev_geneve_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) { assert(m); diff --git a/src/network/netdev/ipoib.c b/src/network/netdev/ipoib.c index d5fe299b7b4..e2f879e7220 100644 --- a/src/network/netdev/ipoib.c +++ b/src/network/netdev/ipoib.c @@ -94,7 +94,7 @@ static const char * const ipoib_mode_table[_IP_OVER_INFINIBAND_MODE_MAX] = { }; DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(ipoib_mode, IPoIBMode); -DEFINE_CONFIG_PARSE_ENUM(config_parse_ipoib_mode, ipoib_mode, IPoIBMode, "Failed to parse IPoIB mode"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_ipoib_mode, ipoib_mode, IPoIBMode); int config_parse_ipoib_pkey( const char *unit, diff --git a/src/network/netdev/ipvlan.c b/src/network/netdev/ipvlan.c index 51ae64341db..892678b4add 100644 --- a/src/network/netdev/ipvlan.c +++ b/src/network/netdev/ipvlan.c @@ -11,8 +11,8 @@ #include "networkd-link.h" #include "string-util.h" -DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_mode, ipvlan_mode, IPVlanMode, "Failed to parse ipvlan mode"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_flags, ipvlan_flags, IPVlanFlags, "Failed to parse ipvlan flags"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_mode, ipvlan_mode, IPVlanMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_flags, ipvlan_flags, IPVlanFlags); static int netdev_ipvlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) { assert(netdev); diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c index 4f9e7189d17..3194f3f785c 100644 --- a/src/network/netdev/l2tp-tunnel.c +++ b/src/network/netdev/l2tp-tunnel.c @@ -29,7 +29,7 @@ static const char* const l2tp_encap_type_table[_NETDEV_L2TP_ENCAPTYPE_MAX] = { }; DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(l2tp_encap_type, L2tpEncapType); -DEFINE_CONFIG_PARSE_ENUM(config_parse_l2tp_encap_type, l2tp_encap_type, L2tpEncapType, "Failed to parse L2TP Encapsulation Type"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_l2tp_encap_type, l2tp_encap_type, L2tpEncapType); static const char* const l2tp_local_address_type_table[_NETDEV_L2TP_LOCAL_ADDRESS_MAX] = { [NETDEV_L2TP_LOCAL_ADDRESS_AUTO] = "auto", diff --git a/src/network/netdev/macvlan.c b/src/network/netdev/macvlan.c index 21933d3970a..1537d868b5f 100644 --- a/src/network/netdev/macvlan.c +++ b/src/network/netdev/macvlan.c @@ -16,7 +16,7 @@ typedef enum BCQueueThreshold { BC_QUEUE_THRESHOLD_DISABLE = -1, } BCQueueThreshold; -DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode, "Failed to parse macvlan mode"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode); static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) { assert(netdev); diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c index db84e7cf6ee..2bf58086b2f 100644 --- a/src/network/netdev/tunnel.c +++ b/src/network/netdev/tunnel.c @@ -30,7 +30,7 @@ static const char* const ip6tnl_mode_table[_NETDEV_IP6_TNL_MODE_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP(ip6tnl_mode, Ip6TnlMode); -DEFINE_CONFIG_PARSE_ENUM(config_parse_ip6tnl_mode, ip6tnl_mode, Ip6TnlMode, "Failed to parse ip6 tunnel Mode"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_ip6tnl_mode, ip6tnl_mode, Ip6TnlMode); #define HASH_KEY SD_ID128_MAKE(74,c4,de,12,f3,d9,41,34,bb,3d,c1,a4,42,93,50,87) diff --git a/src/network/netdev/vxlan.c b/src/network/netdev/vxlan.c index 37f65967a6b..e928b20d839 100644 --- a/src/network/netdev/vxlan.c +++ b/src/network/netdev/vxlan.c @@ -21,7 +21,7 @@ static const char* const df_table[_NETDEV_VXLAN_DF_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(df, VxLanDF, NETDEV_VXLAN_DF_YES); -DEFINE_CONFIG_PARSE_ENUM(config_parse_df, df, VxLanDF, "Failed to parse VXLAN IPDoNotFragment= setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_df, df, VxLanDF); static int vxlan_get_local_address(VxLan *v, Link *link, int *ret_family, union in_addr_union *ret_address) { assert(v); diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 4a9459f0068..0a784553d03 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -2018,5 +2018,4 @@ static const char* const dhcp_client_identifier_table[_DHCP_CLIENT_ID_MAX] = { }; DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_client_identifier, DHCPClientIdentifier); -DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_client_identifier, dhcp_client_identifier, DHCPClientIdentifier, - "Failed to parse client identifier type"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_client_identifier, dhcp_client_identifier, DHCPClientIdentifier); diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index 852987bd865..3f773cbb993 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -878,8 +878,7 @@ int config_parse_dhcp6_pd_prefix_hint( return 0; } -DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp6_client_start_mode, dhcp6_client_start_mode, DHCP6ClientStartMode, - "Failed to parse WithoutRA= setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp6_client_start_mode, dhcp6_client_start_mode, DHCP6ClientStartMode); static const char* const dhcp6_client_start_mode_table[_DHCP6_CLIENT_START_MODE_MAX] = { [DHCP6_CLIENT_START_MODE_NO] = "no", diff --git a/src/network/networkd-dns.c b/src/network/networkd-dns.c index 7078419d375..74a371b6d7d 100644 --- a/src/network/networkd-dns.c +++ b/src/network/networkd-dns.c @@ -291,4 +291,4 @@ static const char* const use_domains_table[_USE_DOMAINS_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(use_domains, UseDomains, USE_DOMAINS_YES); -DEFINE_CONFIG_PARSE_ENUM(config_parse_use_domains, use_domains, UseDomains, "Failed to parse UseDomains=") +DEFINE_CONFIG_PARSE_ENUM(config_parse_use_domains, use_domains, UseDomains); diff --git a/src/network/networkd-ipv6ll.c b/src/network/networkd-ipv6ll.c index 32229a3fc70..cd23cc94aa1 100644 --- a/src/network/networkd-ipv6ll.c +++ b/src/network/networkd-ipv6ll.c @@ -243,5 +243,4 @@ DEFINE_STRING_TABLE_LOOKUP(ipv6_link_local_address_gen_mode, IPv6LinkLocalAddres DEFINE_CONFIG_PARSE_ENUM( config_parse_ipv6_link_local_address_gen_mode, ipv6_link_local_address_gen_mode, - IPv6LinkLocalAddressGenMode, - "Failed to parse IPv6 link-local address generation mode"); + IPv6LinkLocalAddressGenMode); diff --git a/src/network/networkd-lldp-rx.c b/src/network/networkd-lldp-rx.c index f74485488eb..6ba198282e7 100644 --- a/src/network/networkd-lldp-rx.c +++ b/src/network/networkd-lldp-rx.c @@ -17,7 +17,7 @@ #include "strv.h" #include "tmpfile-util.h" -DEFINE_CONFIG_PARSE_ENUM(config_parse_lldp_mode, lldp_mode, LLDPMode, "Failed to parse LLDP= setting."); +DEFINE_CONFIG_PARSE_ENUM(config_parse_lldp_mode, lldp_mode, LLDPMode); static const char* const lldp_mode_table[_LLDP_MODE_MAX] = { [LLDP_MODE_NO] = "no", diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 21b76fafc45..f44f03365c3 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -2525,5 +2525,4 @@ static const char* const ndisc_start_dhcp6_client_table[_IPV6_ACCEPT_RA_START_DH DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_BOOLEAN(ndisc_start_dhcp6_client, IPv6AcceptRAStartDHCP6Client, IPV6_ACCEPT_RA_START_DHCP6_CLIENT_YES); -DEFINE_CONFIG_PARSE_ENUM(config_parse_ndisc_start_dhcp6_client, ndisc_start_dhcp6_client, IPv6AcceptRAStartDHCP6Client, - "Failed to parse DHCPv6Client= setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_ndisc_start_dhcp6_client, ndisc_start_dhcp6_client, IPv6AcceptRAStartDHCP6Client); diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 94666c2bdd0..56cf52bbe68 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -1056,11 +1056,8 @@ int config_parse_ignore_carrier_loss( return 0; } -DEFINE_CONFIG_PARSE_ENUM(config_parse_required_family_for_online, link_required_address_family, AddressFamily, - "Failed to parse RequiredFamilyForOnline= setting"); - -DEFINE_CONFIG_PARSE_ENUM(config_parse_keep_configuration, keep_configuration, KeepConfiguration, - "Failed to parse KeepConfiguration= setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_required_family_for_online, link_required_address_family, AddressFamily); +DEFINE_CONFIG_PARSE_ENUM(config_parse_keep_configuration, keep_configuration, KeepConfiguration); static const char* const keep_configuration_table[_KEEP_CONFIGURATION_MAX] = { [KEEP_CONFIGURATION_NO] = "no", @@ -1082,4 +1079,4 @@ static const char* const activation_policy_table[_ACTIVATION_POLICY_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP(activation_policy, ActivationPolicy); -DEFINE_CONFIG_PARSE_ENUM(config_parse_activation_policy, activation_policy, ActivationPolicy, "Failed to parse activation policy"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_activation_policy, activation_policy, ActivationPolicy); diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index 75b4224c8ad..1efb2bff943 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -1637,8 +1637,7 @@ static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT( config_parse_routing_policy_rule_family, routing_policy_rule_address_family, AddressFamily, - ADDRESS_FAMILY_NO, - "Invalid family"); + ADDRESS_FAMILY_NO); typedef struct RoutingPolicyRuleConfParser { ConfigParserCallback parser; diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c index a454322fd0e..2027a29f276 100644 --- a/src/network/networkd-sysctl.c +++ b/src/network/networkd-sysctl.c @@ -458,8 +458,7 @@ static const char* const ipv6_privacy_extensions_table[_IPV6_PRIVACY_EXTENSIONS_ DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(ipv6_privacy_extensions, IPv6PrivacyExtensions, IPV6_PRIVACY_EXTENSIONS_YES); -DEFINE_CONFIG_PARSE_ENUM(config_parse_ipv6_privacy_extensions, ipv6_privacy_extensions, IPv6PrivacyExtensions, - "Failed to parse IPv6 privacy extensions option"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_ipv6_privacy_extensions, ipv6_privacy_extensions, IPv6PrivacyExtensions); static const char* const ip_reverse_path_filter_table[_IP_REVERSE_PATH_FILTER_MAX] = { [IP_REVERSE_PATH_FILTER_NO] = "no", @@ -468,8 +467,7 @@ static const char* const ip_reverse_path_filter_table[_IP_REVERSE_PATH_FILTER_MA }; DEFINE_STRING_TABLE_LOOKUP(ip_reverse_path_filter, IPReversePathFilter); -DEFINE_CONFIG_PARSE_ENUM(config_parse_ip_reverse_path_filter, ip_reverse_path_filter, IPReversePathFilter, - "Failed to parse IP reverse path filter option"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_ip_reverse_path_filter, ip_reverse_path_filter, IPReversePathFilter); int config_parse_ip_forward_deprecated( const char* unit, diff --git a/src/network/networkd-util.c b/src/network/networkd-util.c index 46f90088790..8d6df6d2c11 100644 --- a/src/network/networkd-util.c +++ b/src/network/networkd-util.c @@ -110,8 +110,7 @@ AddressFamily link_local_address_family_from_string(const char *s) { DEFINE_STRING_TABLE_LOOKUP(routing_policy_rule_address_family, AddressFamily); DEFINE_STRING_TABLE_LOOKUP(nexthop_address_family, AddressFamily); DEFINE_STRING_TABLE_LOOKUP(duplicate_address_detection_address_family, AddressFamily); -DEFINE_CONFIG_PARSE_ENUM(config_parse_link_local_address_family, link_local_address_family, - AddressFamily, "Failed to parse option"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_link_local_address_family, link_local_address_family, AddressFamily); DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_deprecated_address_family, AddressFamily); DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(ip_masquerade_address_family, AddressFamily); DEFINE_STRING_TABLE_LOOKUP(dhcp_lease_server_type, sd_dhcp_lease_server_type_t); diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c index 132a54338f7..587da92cb27 100644 --- a/src/nspawn/nspawn-settings.c +++ b/src/nspawn/nspawn-settings.c @@ -232,7 +232,7 @@ int settings_allocate_properties(Settings *s) { return 0; } -DEFINE_CONFIG_PARSE_ENUM(config_parse_volatile_mode, volatile_mode, VolatileMode, "Failed to parse volatile mode"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_volatile_mode, volatile_mode, VolatileMode); int config_parse_expose_port( const char *unit, @@ -832,7 +832,7 @@ int config_parse_cpu_affinity( return parse_cpu_set_extend(rvalue, &settings->cpu_set, true, unit, filename, line, lvalue); } -DEFINE_CONFIG_PARSE_ENUM(config_parse_resolv_conf, resolv_conf_mode, ResolvConfMode, "Failed to parse resolv.conf mode"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_resolv_conf, resolv_conf_mode, ResolvConfMode); static const char *const resolv_conf_mode_table[_RESOLV_CONF_MODE_MAX] = { [RESOLV_CONF_OFF] = "off", @@ -914,7 +914,7 @@ int config_parse_link_journal( return 0; } -DEFINE_CONFIG_PARSE_ENUM(config_parse_timezone_mode, timezone_mode, TimezoneMode, "Failed to parse timezone mode"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_timezone_mode, timezone_mode, TimezoneMode); static const char *const timezone_mode_table[_TIMEZONE_MODE_MAX] = { [TIMEZONE_OFF] = "off", @@ -927,7 +927,7 @@ static const char *const timezone_mode_table[_TIMEZONE_MODE_MAX] = { DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(timezone_mode, TimezoneMode, TIMEZONE_AUTO); -DEFINE_CONFIG_PARSE_ENUM(config_parse_userns_ownership, user_namespace_ownership, UserNamespaceOwnership, "Failed to parse user namespace ownership mode"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_userns_ownership, user_namespace_ownership, UserNamespaceOwnership); static const char *const user_namespace_ownership_table[_USER_NAMESPACE_OWNERSHIP_MAX] = { [USER_NAMESPACE_OWNERSHIP_OFF] = "off", diff --git a/src/partition/repart.c b/src/partition/repart.c index 48b3b430137..427762a8f62 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -1712,7 +1712,7 @@ static int config_parse_default_subvolume( return free_and_replace(*subvol, p); } -static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_encrypt, encrypt_mode, EncryptMode, ENCRYPT_OFF, "Invalid encryption mode"); +static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_encrypt, encrypt_mode, EncryptMode, ENCRYPT_OFF); static int config_parse_gpt_flags( const char *unit, @@ -1899,8 +1899,8 @@ static int config_parse_encrypted_volume( return 0; } -static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_verity, verity_mode, VerityMode, VERITY_OFF, "Invalid verity mode"); -static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_minimize, minimize_mode, MinimizeMode, MINIMIZE_OFF, "Invalid minimize mode"); +static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_verity, verity_mode, VerityMode, VERITY_OFF); +static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_minimize, minimize_mode, MinimizeMode, MINIMIZE_OFF); static int partition_finalize_fstype(Partition *p, const char *path) { _cleanup_free_ char *e = NULL, *upper = NULL; diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c index e2dfc4d1a1e..0addaa6df6a 100644 --- a/src/pstore/pstore.c +++ b/src/pstore/pstore.c @@ -62,7 +62,7 @@ static const char* const pstore_storage_table[_PSTORE_STORAGE_MAX] = { }; DEFINE_PRIVATE_STRING_TABLE_LOOKUP(pstore_storage, PStoreStorage); -static DEFINE_CONFIG_PARSE_ENUM(config_parse_pstore_storage, pstore_storage, PStoreStorage, "Failed to parse storage setting"); +static DEFINE_CONFIG_PARSE_ENUM(config_parse_pstore_storage, pstore_storage, PStoreStorage); static PStoreStorage arg_storage = PSTORE_STORAGE_EXTERNAL; diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index 4441ee27c80..65a5611d091 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -21,7 +21,7 @@ #include "strv.h" #include "utf8.h" -DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_stub_listener_mode, dns_stub_listener_mode, DnsStubListenerMode, "Failed to parse DNS stub listener mode setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_stub_listener_mode, dns_stub_listener_mode, DnsStubListenerMode); static int manager_add_dns_server_by_string(Manager *m, DnsServerType type, const char *word) { _cleanup_free_ char *server_name = NULL; diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index d9ceb4508fb..dab51c40cdb 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -852,7 +852,7 @@ int _hashmap_by_section_find_unused_line( } #define DEFINE_PARSER(type, vartype, conv_func) \ - DEFINE_CONFIG_PARSE_PTR(config_parse_##type, conv_func, vartype, "Failed to parse " #type " value") + DEFINE_CONFIG_PARSE_PTR(config_parse_##type, conv_func, vartype) DEFINE_PARSER(int, int, safe_atoi); DEFINE_PARSER(long, long, safe_atoli); @@ -2054,9 +2054,9 @@ int config_parse_calendar( return 0; } -DEFINE_CONFIG_PARSE(config_parse_percent, parse_percent, "Failed to parse percent value"); -DEFINE_CONFIG_PARSE(config_parse_permyriad, parse_permyriad, "Failed to parse permyriad value"); -DEFINE_CONFIG_PARSE_PTR(config_parse_sec_fix_0, parse_sec_fix_0, usec_t, "Failed to parse time value"); +DEFINE_CONFIG_PARSE(config_parse_percent, parse_percent); +DEFINE_CONFIG_PARSE(config_parse_permyriad, parse_permyriad); +DEFINE_CONFIG_PARSE_PTR(config_parse_sec_fix_0, parse_sec_fix_0, usec_t); int config_parse_timezone( const char *unit, diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index 937bdc73ed6..3e00666e775 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -305,7 +305,7 @@ typedef enum ConfigParseStringFlags { CONFIG_PARSE_STRING_SAFE_AND_ASCII = CONFIG_PARSE_STRING_SAFE | CONFIG_PARSE_STRING_ASCII, } ConfigParseStringFlags; -#define DEFINE_CONFIG_PARSE(function, parser, msg) \ +#define DEFINE_CONFIG_PARSE(function, parser) \ CONFIG_PARSER_PROTOTYPE(function) { \ int *i = data, r; \ \ @@ -315,17 +315,14 @@ typedef enum ConfigParseStringFlags { assert(data); \ \ r = parser(rvalue); \ - if (r < 0) { \ - log_syntax(unit, LOG_WARNING, filename, line, r, \ - msg ", ignoring: %s", rvalue); \ - return 0; \ - } \ + if (r < 0) \ + return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue); \ \ *i = r; \ return 1; \ } -#define DEFINE_CONFIG_PARSE_PTR(function, parser, type, msg) \ +#define DEFINE_CONFIG_PARSE_PTR(function, parser, type) \ CONFIG_PARSER_PROTOTYPE(function) { \ type *i = ASSERT_PTR(data); \ int r; \ @@ -336,13 +333,12 @@ typedef enum ConfigParseStringFlags { \ r = parser(rvalue, i); \ if (r < 0) \ - log_syntax(unit, LOG_WARNING, filename, line, r, \ - msg ", ignoring: %s", rvalue); \ + return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue); \ \ return 1; \ } -#define DEFINE_CONFIG_PARSE_ENUM_FULL(function, from_string, type, msg) \ +#define DEFINE_CONFIG_PARSE_ENUM_FULL(function, from_string, type) \ CONFIG_PARSER_PROTOTYPE(function) { \ type *i = data, x; \ \ @@ -352,20 +348,17 @@ typedef enum ConfigParseStringFlags { assert(data); \ \ x = from_string(rvalue); \ - if (x < 0) { \ - log_syntax(unit, LOG_WARNING, filename, line, x, \ - msg ", ignoring: %s", rvalue); \ - return 0; \ - } \ + if (x < 0) \ + return log_syntax_parse_error(unit, filename, line, x, lvalue, rvalue); \ \ *i = x; \ return 1; \ } -#define DEFINE_CONFIG_PARSE_ENUM(function, name, type, msg) \ - DEFINE_CONFIG_PARSE_ENUM_FULL(function, name##_from_string, type, msg) +#define DEFINE_CONFIG_PARSE_ENUM(function, name, type) \ + DEFINE_CONFIG_PARSE_ENUM_FULL(function, name##_from_string, type) -#define DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(function, name, type, default_value, msg) \ +#define DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(function, name, type, default_value) \ CONFIG_PARSER_PROTOTYPE(function) { \ type *i = data, x; \ \ @@ -380,17 +373,14 @@ typedef enum ConfigParseStringFlags { } \ \ x = name##_from_string(rvalue); \ - if (x < 0) { \ - log_syntax(unit, LOG_WARNING, filename, line, x, \ - msg ", ignoring: %s", rvalue); \ - return 0; \ - } \ + if (x < 0) \ + return log_syntax_parse_error(unit, filename, line, x, lvalue, rvalue); \ \ *i = x; \ return 1; \ } -#define DEFINE_CONFIG_PARSE_ENUMV(function, name, type, invalid, msg) \ +#define DEFINE_CONFIG_PARSE_ENUMV(function, name, type, invalid) \ CONFIG_PARSER_PROTOTYPE(function) { \ type **enums = ASSERT_PTR(data); \ _cleanup_free_ type *xs = NULL; \ @@ -412,28 +402,24 @@ typedef enum ConfigParseStringFlags { type x, *new_xs; \ \ r = extract_first_word(&p, &en, NULL, 0); \ - if (r == -ENOMEM) \ - return log_oom(); \ - if (r < 0) { \ - log_syntax(unit, LOG_WARNING, filename, line, r, \ - msg ", ignoring: %s", en); \ - return 0; \ - } \ + if (r < 0) \ + return log_syntax_parse_error(unit, filename, line, r, lvalue, rvalue); \ if (r == 0) \ break; \ \ x = name##_from_string(en); \ if (x < 0) { \ log_syntax(unit, LOG_WARNING, filename, line, x, \ - msg ", ignoring: %s", en); \ + "Failed to parse %s in %s=, ignoring.", \ + en, lvalue); \ continue; \ } \ \ - for (type *ys = xs; x != invalid && *ys != invalid; ys++) \ - if (*ys == x) { \ + for (type *ys = xs; x != invalid && *ys != invalid; ys++) \ + if (*ys == x) { \ log_syntax(unit, LOG_NOTICE, filename, line, 0, \ - "Duplicate entry, ignoring: %s", \ - en); \ + "Duplicate entry %s in %s=, ignoring.", \ + en, lvalue); \ x = invalid; \ } \ \ diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c index 1e100c35ef5..174614a4320 100644 --- a/src/shared/ethtool-util.c +++ b/src/shared/ethtool-util.c @@ -23,7 +23,7 @@ static const char* const duplex_table[_DUP_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP(duplex, Duplex); -DEFINE_CONFIG_PARSE_ENUM(config_parse_duplex, duplex, Duplex, "Failed to parse duplex setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_duplex, duplex, Duplex); static const struct { uint32_t opt; @@ -72,7 +72,7 @@ static const char* const port_table[] = { }; DEFINE_STRING_TABLE_LOOKUP(port, NetDevPort); -DEFINE_CONFIG_PARSE_ENUM(config_parse_port, port, NetDevPort, "Failed to parse Port setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_port, port, NetDevPort); static const char* const mdi_table[] = { [ETH_TP_MDI_INVALID] = "unknown", diff --git a/src/shared/resolve-util.c b/src/shared/resolve-util.c index 820f9bb5305..e01578fbcb0 100644 --- a/src/shared/resolve-util.c +++ b/src/shared/resolve-util.c @@ -4,9 +4,9 @@ #include "resolve-util.h" #include "string-table.h" -DEFINE_CONFIG_PARSE_ENUM(config_parse_resolve_support, resolve_support, ResolveSupport, "Failed to parse resolve support setting"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_dnssec_mode, dnssec_mode, DnssecMode, "Failed to parse DNSSEC mode setting"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_over_tls_mode, dns_over_tls_mode, DnsOverTlsMode, "Failed to parse DNS-over-TLS mode setting"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_resolve_support, resolve_support, ResolveSupport); +DEFINE_CONFIG_PARSE_ENUM(config_parse_dnssec_mode, dnssec_mode, DnssecMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_over_tls_mode, dns_over_tls_mode, DnsOverTlsMode); static const char* const resolve_support_table[_RESOLVE_SUPPORT_MAX] = { [RESOLVE_SUPPORT_NO] = "no", @@ -42,7 +42,7 @@ bool dns_server_address_valid(int family, const union in_addr_union *sa) { return true; } -DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_cache_mode, dns_cache_mode, DnsCacheMode, "Failed to parse DNS cache mode setting") +DEFINE_CONFIG_PARSE_ENUM(config_parse_dns_cache_mode, dns_cache_mode, DnsCacheMode); static const char* const dns_cache_mode_table[_DNS_CACHE_MODE_MAX] = { [DNS_CACHE_MODE_YES] = "yes", diff --git a/src/sysupdate/sysupdate-transfer.c b/src/sysupdate/sysupdate-transfer.c index f7d9a043fc6..d12687ac040 100644 --- a/src/sysupdate/sysupdate-transfer.c +++ b/src/sysupdate/sysupdate-transfer.c @@ -377,10 +377,10 @@ static int config_parse_resource_path( return free_and_replace(rr->path, resolved); } -static DEFINE_CONFIG_PARSE_ENUM(config_parse_resource_type, resource_type, ResourceType, "Invalid resource type"); +static DEFINE_CONFIG_PARSE_ENUM(config_parse_resource_type, resource_type, ResourceType); static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_resource_path_relto, path_relative_to, PathRelativeTo, - PATH_RELATIVE_TO_ROOT, "Invalid PathRelativeTo= value"); + PATH_RELATIVE_TO_ROOT); static int config_parse_resource_ptype( const char *unit, diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 647cdeeb9db..645c7f840a9 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -1446,13 +1446,10 @@ DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT( config_parse_mac_address_policy, mac_address_policy, MACAddressPolicy, - MAC_ADDRESS_POLICY_NONE, - "Failed to parse MAC address policy"); + MAC_ADDRESS_POLICY_NONE); DEFINE_CONFIG_PARSE_ENUMV(config_parse_name_policy, name_policy, NamePolicy, - _NAMEPOLICY_INVALID, - "Failed to parse interface name policy"); + _NAMEPOLICY_INVALID); DEFINE_CONFIG_PARSE_ENUMV(config_parse_alternative_names_policy, alternative_names_policy, NamePolicy, - _NAMEPOLICY_INVALID, - "Failed to parse alternative names policy"); + _NAMEPOLICY_INVALID); diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 5018541661d..c46fcaa0382 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -65,7 +65,7 @@ static int listen_fds(int *ret_ctrl, int *ret_netlink) { return 0; } -static DEFINE_CONFIG_PARSE_ENUM(config_parse_resolve_name_timing, resolve_name_timing, ResolveNameTiming, "Failed to parse resolve name timing"); +static DEFINE_CONFIG_PARSE_ENUM(config_parse_resolve_name_timing, resolve_name_timing, ResolveNameTiming); static int manager_parse_udev_config(Manager *manager) { int r, log_val = -1;