Skip to content

Commit d5c5e4d

Browse files
author
someguy
committed
Use the string table. Correct an error code.
1 parent 65e961c commit d5c5e4d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/netlog/netlog-conf.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,21 @@ int config_parse_protocol(const char *unit,
4545
void *data,
4646
void *userdata) {
4747
Manager *m = userdata;
48+
int r;
4849

4950
assert(filename);
5051
assert(lvalue);
5152
assert(rvalue);
5253
assert(data);
5354

54-
if (strcaseeq(rvalue, "tcp"))
55-
m->protocol = SOCK_STREAM;
56-
else if (strcaseeq(rvalue, "udp"))
57-
m->protocol = SOCK_DGRAM;
58-
else {
59-
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
60-
"Unrecognised protocol '%s'; should be either 'tcp' or 'udp'", rvalue);
61-
return -EINVAL;
55+
r = protocol_from_string(rvalue);
56+
if (r < 0) {
57+
log_syntax(unit, LOG_ERR, filename, line, -r,
58+
"Unrecognised Protocol '%s'", rvalue);
59+
return -EPROTONOSUPPORT;
6260
}
6361

62+
m->protocol = r;
6463
return 0;
6564
}
6665

src/netlog/netlog-network.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ int manager_open_network_socket(Manager *m) {
188188
m->socket = socket(m->address.sockaddr.sa.sa_family, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
189189
break;
190190
default:
191-
return -EINVAL;
191+
return -EPROTONOSUPPORT;
192192
}
193193
if (m->socket < 0)
194194
return -errno;

0 commit comments

Comments
 (0)