Skip to content

Commit f054830

Browse files
committed
BUILD: systemd: fix usage of reserved name "sun" in the address field
systemd.c doesn't build on Solaris / Illumos because it uses "sun" as the field name in a structure, while "sun" is the name of the macro used to detect Solaris: src/systemd.c: In function 'sd_notify': src/systemd.c:43:22: error: expected identifier or '(' before numeric constant struct sockaddr_un sun; ^ src/systemd.c:44:2: warning: no semicolon at end of struct or union } socket_addr = { ^ Admittedly, the OS could have instead defined "sun" to itself to avoid this. Any other name will work, let's just use "ux" for the short form of "unix". The problem appeared in 3.0-dev with commit aa36329 ("MEDIUM: mworker: get rid of libsystemd"), though by then this file was only built when USE_SYSTEMD was set, which was not the case for non-linux platforms. However since 3.1-dev14 with commit 1584524 ("MEDIUM: mworker: remove USE_SYSTEMD requirement for -Ws"), all platforms now build this file. No backport is needed even though it will not hurt to have it in 3.0 for completeness.
1 parent a941c92 commit f054830

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/systemd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ int sd_notify(int unset_environment, const char *message)
3939
{
4040
union sockaddr_union {
4141
struct sockaddr sa;
42-
struct sockaddr_un sun;
42+
struct sockaddr_un ux;
4343
} socket_addr = {
44-
.sun.sun_family = AF_UNIX,
44+
.ux.sun_family = AF_UNIX,
4545
};
4646
int ret = 1;
4747
int fd = -1;
@@ -77,16 +77,16 @@ int sd_notify(int unset_environment, const char *message)
7777

7878
path_length = strlen(socket_path);
7979
/* Ensure there is room for NUL byte */
80-
if (path_length >= sizeof(socket_addr.sun.sun_path)) {
80+
if (path_length >= sizeof(socket_addr.ux.sun_path)) {
8181
ret = -E2BIG;
8282
goto end;
8383
}
8484

85-
memcpy(socket_addr.sun.sun_path, socket_path, path_length);
85+
memcpy(socket_addr.ux.sun_path, socket_path, path_length);
8686

8787
/* Support for abstract socket */
88-
if (socket_addr.sun.sun_path[0] == '@')
89-
socket_addr.sun.sun_path[0] = 0;
88+
if (socket_addr.ux.sun_path[0] == '@')
89+
socket_addr.ux.sun_path[0] = 0;
9090

9191
fd = socket(AF_UNIX, SOCK_DGRAM, 0);
9292
if (fd < 0) {

0 commit comments

Comments
 (0)