> From: Brent Cook <bust...@gmail.com>
> Date: Fri,  2 Jan 2015 14:27:10 -0600
> 
> From: Brent Cook <bust...@gmail.com>
> 
> Solaris build environments seem to define 'sun' as a constant.
> Hilarity ensues.

Hmm, sock is a bit of a bad choice.  At least I associate it with
being the file descriptor of a socket.  Looking through the tree,
"addr" or "sa" seem to be the canonical names for a sockaddr_un
variable.

> ---
>  src/usr.sbin/ntpd/control.c | 18 +++++++++---------
>  src/usr.sbin/ntpd/ntpd.c    | 12 ++++++------
>  2 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/src/usr.sbin/ntpd/control.c b/src/usr.sbin/ntpd/control.c
> index 6c5b05d..eb3575b 100644
> --- a/src/usr.sbin/ntpd/control.c
> +++ b/src/usr.sbin/ntpd/control.c
> @@ -36,7 +36,7 @@
>  int
>  control_init(char *path)
>  {
> -     struct sockaddr_un       sun;
> +     struct sockaddr_un       sock;
>       int                      fd;
>       mode_t                   old_umask;
>  
> @@ -45,10 +45,10 @@ control_init(char *path)
>               return (-1);
>       }
>  
> -     bzero(&sun, sizeof(sun));
> -     sun.sun_family = AF_UNIX;
> -     if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
> -         sizeof(sun.sun_path))
> +     bzero(&sock, sizeof(sock));
> +     sock.sun_family = AF_UNIX;
> +     if (strlcpy(sock.sun_path, path, sizeof(sock.sun_path)) >=
> +         sizeof(sock.sun_path))
>               errx(1, "ctl socket name too long");
>  
>       if (unlink(path) == -1)
> @@ -59,7 +59,7 @@ control_init(char *path)
>               }
>  
>       old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH);
> -     if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
> +     if (bind(fd, (struct sockaddr *)&sock, sizeof(sock)) == -1) {
>               log_warn("control_init: bind: %s", path);
>               close(fd);
>               umask(old_umask);
> @@ -108,12 +108,12 @@ control_accept(int listenfd)
>  {
>       int                      connfd;
>       socklen_t                len;
> -     struct sockaddr_un       sun;
> +     struct sockaddr_un       sock;
>       struct ctl_conn         *ctl_conn;
>  
> -     len = sizeof(sun);
> +     len = sizeof(sock);
>       if ((connfd = accept(listenfd,
> -         (struct sockaddr *)&sun, &len)) == -1) {
> +         (struct sockaddr *)&sock, &len)) == -1) {
>               if (errno != EWOULDBLOCK && errno != EINTR)
>                       log_warn("control_accept: accept");
>               return (0);
> diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
> index 17ebf67..d764a50 100644
> --- a/src/usr.sbin/ntpd/ntpd.c
> +++ b/src/usr.sbin/ntpd/ntpd.c
> @@ -527,7 +527,7 @@ writefreq(double d)
>  void
>  ctl_main(int argc, char *argv[])
>  {
> -     struct sockaddr_un       sun;
> +     struct sockaddr_un       sock;
>       struct imsg              imsg;
>       struct imsgbuf          *ibuf_ctl;
>       int                      fd, n, done, ch, action;
> @@ -580,12 +580,12 @@ ctl_main(int argc, char *argv[])
>       if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
>               err(1, "ntpctl: socket");
>  
> -     bzero(&sun, sizeof(sun));
> -     sun.sun_family = AF_UNIX;
> -     if (strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path)) >=
> -         sizeof(sun.sun_path))
> +     bzero(&sock, sizeof(sock));
> +     sock.sun_family = AF_UNIX;
> +     if (strlcpy(sock.sun_path, sockname, sizeof(sock.sun_path)) >=
> +         sizeof(sock.sun_path))
>               errx(1, "ctl socket name too long");
> -     if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1)
> +     if (connect(fd, (struct sockaddr *)&sock, sizeof(sock)) == -1)
>               err(1, "connect: %s", sockname);
>  
>       if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL)
> -- 
> 1.9.1
> 
> 

Reply via email to