diff options
author | deraadt@openbsd.org <deraadt@openbsd.org> | 2016-09-12 01:22:38 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2016-09-12 13:46:29 +1000 |
commit | 9136ec134c97a8aff2917760c03134f52945ff3c (patch) | |
tree | bfcab357e6e0f510d9b63bac43b18097e89fa58a /channels.c | |
parent | f219fc8f03caca7ac82a38ed74bbd6432a1195e7 (diff) |
upstream commit
Add MAXIMUM(), MINIMUM(), and ROUNDUP() to misc.h, then
use those definitions rather than pulling <sys/param.h> and unknown namespace
pollution. ok djm markus dtucker
Upstream-ID: 712cafa816c9f012a61628b66b9fbd5687223fb8
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/channels.c b/channels.c index 9f9e972f4..241aa3cdc 100644 --- a/channels.c +++ b/channels.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.c,v 1.351 2016/07/19 11:38:53 dtucker Exp $ */ | 1 | /* $OpenBSD: channels.c,v 1.352 2016/09/12 01:22:38 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -42,7 +42,6 @@ | |||
42 | #include "includes.h" | 42 | #include "includes.h" |
43 | 43 | ||
44 | #include <sys/types.h> | 44 | #include <sys/types.h> |
45 | #include <sys/param.h> /* MIN MAX */ | ||
46 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
47 | #include <sys/ioctl.h> | 46 | #include <sys/ioctl.h> |
48 | #include <sys/un.h> | 47 | #include <sys/un.h> |
@@ -245,9 +244,9 @@ channel_register_fds(Channel *c, int rfd, int wfd, int efd, | |||
245 | int extusage, int nonblock, int is_tty) | 244 | int extusage, int nonblock, int is_tty) |
246 | { | 245 | { |
247 | /* Update the maximum file descriptor value. */ | 246 | /* Update the maximum file descriptor value. */ |
248 | channel_max_fd = MAX(channel_max_fd, rfd); | 247 | channel_max_fd = MAXIMUM(channel_max_fd, rfd); |
249 | channel_max_fd = MAX(channel_max_fd, wfd); | 248 | channel_max_fd = MAXIMUM(channel_max_fd, wfd); |
250 | channel_max_fd = MAX(channel_max_fd, efd); | 249 | channel_max_fd = MAXIMUM(channel_max_fd, efd); |
251 | 250 | ||
252 | if (rfd != -1) | 251 | if (rfd != -1) |
253 | fcntl(rfd, F_SETFD, FD_CLOEXEC); | 252 | fcntl(rfd, F_SETFD, FD_CLOEXEC); |
@@ -373,9 +372,9 @@ channel_find_maxfd(void) | |||
373 | for (i = 0; i < channels_alloc; i++) { | 372 | for (i = 0; i < channels_alloc; i++) { |
374 | c = channels[i]; | 373 | c = channels[i]; |
375 | if (c != NULL) { | 374 | if (c != NULL) { |
376 | max = MAX(max, c->rfd); | 375 | max = MAXIMUM(max, c->rfd); |
377 | max = MAX(max, c->wfd); | 376 | max = MAXIMUM(max, c->wfd); |
378 | max = MAX(max, c->efd); | 377 | max = MAXIMUM(max, c->efd); |
379 | } | 378 | } |
380 | } | 379 | } |
381 | return max; | 380 | return max; |
@@ -1898,7 +1897,7 @@ read_mux(Channel *c, u_int need) | |||
1898 | 1897 | ||
1899 | if (buffer_len(&c->input) < need) { | 1898 | if (buffer_len(&c->input) < need) { |
1900 | rlen = need - buffer_len(&c->input); | 1899 | rlen = need - buffer_len(&c->input); |
1901 | len = read(c->rfd, buf, MIN(rlen, CHAN_RBUF)); | 1900 | len = read(c->rfd, buf, MINIMUM(rlen, CHAN_RBUF)); |
1902 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) | 1901 | if (len < 0 && (errno == EINTR || errno == EAGAIN)) |
1903 | return buffer_len(&c->input); | 1902 | return buffer_len(&c->input); |
1904 | if (len <= 0) { | 1903 | if (len <= 0) { |
@@ -2201,7 +2200,7 @@ channel_prepare_select(fd_set **readsetp, fd_set **writesetp, int *maxfdp, | |||
2201 | { | 2200 | { |
2202 | u_int n, sz, nfdset; | 2201 | u_int n, sz, nfdset; |
2203 | 2202 | ||
2204 | n = MAX(*maxfdp, channel_max_fd); | 2203 | n = MAXIMUM(*maxfdp, channel_max_fd); |
2205 | 2204 | ||
2206 | nfdset = howmany(n+1, NFDBITS); | 2205 | nfdset = howmany(n+1, NFDBITS); |
2207 | /* Explicitly test here, because xrealloc isn't always called */ | 2206 | /* Explicitly test here, because xrealloc isn't always called */ |
@@ -3633,7 +3632,7 @@ connect_next(struct channel_connect *cctx) | |||
3633 | { | 3632 | { |
3634 | int sock, saved_errno; | 3633 | int sock, saved_errno; |
3635 | struct sockaddr_un *sunaddr; | 3634 | struct sockaddr_un *sunaddr; |
3636 | char ntop[NI_MAXHOST], strport[MAX(NI_MAXSERV,sizeof(sunaddr->sun_path))]; | 3635 | char ntop[NI_MAXHOST], strport[MAXIMUM(NI_MAXSERV,sizeof(sunaddr->sun_path))]; |
3637 | 3636 | ||
3638 | for (; cctx->ai; cctx->ai = cctx->ai->ai_next) { | 3637 | for (; cctx->ai; cctx->ai = cctx->ai->ai_next) { |
3639 | switch (cctx->ai->ai_family) { | 3638 | switch (cctx->ai->ai_family) { |