Author: cgutman Date: Sat Jul 25 04:28:11 2009 New Revision: 42188
URL: http://svn.reactos.org/svn/reactos?rev=42188&view=rev Log: ws2_32_new compatibility fixes - Fix the rest of the code which was using errno instead of WSAGetLastError() - Remove some dead code
Modified: trunk/reactos/base/services/dhcp/dhclient.c trunk/reactos/base/services/dhcp/dispatch.c trunk/reactos/base/services/dhcp/include/dhcpd.h trunk/reactos/base/services/dhcp/privsep.c
Modified: trunk/reactos/base/services/dhcp/dhclient.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/dhclient... ============================================================================== --- trunk/reactos/base/services/dhcp/dhclient.c [iso-8859-1] (original) +++ trunk/reactos/base/services/dhcp/dhclient.c [iso-8859-1] Sat Jul 25 04:28:11 2009 @@ -1540,7 +1540,7 @@ if (!leaseFile) { leaseFile = fopen(path_dhclient_db, "w"); if (!leaseFile) - error("can't create %s: %s", path_dhclient_db, strerror(errno)); + error("can't create %s", path_dhclient_db); } else { fflush(leaseFile); rewind(leaseFile); @@ -1577,7 +1577,7 @@ if (!leaseFile) { /* XXX */ leaseFile = fopen(path_dhclient_db, "w"); if (!leaseFile) - error("can't create %s: %s", path_dhclient_db, strerror(errno)); + error("can't create %s", path_dhclient_db); }
fprintf(leaseFile, "lease {\n"); @@ -1632,7 +1632,7 @@ sizeof(size_t) + strlen(reason);
if ((buf = buf_open(hdr.len)) == NULL) - error("buf_open: %s", strerror(errno)); + return;
errs = 0; errs += buf_add(buf, &hdr, sizeof(hdr)); @@ -1644,10 +1644,10 @@ errs += buf_add(buf, reason, len);
if (errs) - error("buf_add: %s", strerror(errno)); + error("buf_add: %d", WSAGetLastError());
if (buf_close(privfd, buf) == -1) - error("buf_close: %s", strerror(errno)); + error("buf_close: %d", WSAGetLastError()); }
void @@ -1822,7 +1822,7 @@ scripttime = time(NULL);
if ((buf = buf_open(hdr.len)) == NULL) - error("buf_open: %s", strerror(errno)); + return;
errs = 0; errs += buf_add(buf, &hdr, sizeof(hdr)); @@ -1842,10 +1842,10 @@ }
if (errs) - error("buf_add: %s", strerror(errno)); + error("buf_add: %d", WSAGetLastError());
if (buf_close(privfd, buf) == -1) - error("buf_close: %s", strerror(errno)); + error("buf_close: %d", WSAGetLastError()); }
int @@ -2075,41 +2075,3 @@ return "<error>"; }
-#if 0 -int -fork_privchld(int fd, int fd2) -{ - struct pollfd pfd[1]; - int nfds; - - switch (fork()) { - case -1: - error("cannot fork"); - case 0: - break; - default: - return (0); - } - - setproctitle("%s [priv]", ifi->name); - - dup2(nullfd, STDIN_FILENO); - dup2(nullfd, STDOUT_FILENO); - dup2(nullfd, STDERR_FILENO); - close(nullfd); - close(fd2); - - for (;;) { - pfd[0].fd = fd; - pfd[0].events = POLLIN; - if ((nfds = poll(pfd, 1, INFTIM)) == -1) - if (errno != EINTR) - error("poll error"); - - if (nfds == 0 || !(pfd[0].revents & POLLIN)) - continue; - - dispatch_imsg(fd); - } -} -#endif
Modified: trunk/reactos/base/services/dhcp/dispatch.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/dispatch... ============================================================================== --- trunk/reactos/base/services/dhcp/dispatch.c [iso-8859-1] (original) +++ trunk/reactos/base/services/dhcp/dispatch.c [iso-8859-1] Sat Jul 25 04:28:11 2009 @@ -198,8 +198,8 @@
if ((result = receive_packet(ip, u.packbuf, sizeof(u), &from, &hfrom)) == -1) { - warning("receive_packet failed on %s: %s", ip->name, - strerror(errno)); + warning("receive_packet failed on %s: %d", ip->name, + WSAGetLastError()); ip->errors++; if (ip->errors > 20) { /* our interface has gone away. */ @@ -374,33 +374,5 @@ int interface_link_status(char *ifname) { -#if 0 - struct ifmediareq ifmr; - int sock; - - if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) - error("Can't create socket"); - - memset(&ifmr, 0, sizeof(ifmr)); - strlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name)); - if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) { - /* EINVAL -> link state unknown. treat as active */ - if (errno != EINVAL) - syslog(LOG_DEBUG, "ioctl(SIOCGIFMEDIA) on %s: %m", - ifname); - close(sock); - return (1); - } - close(sock); - - if (ifmr.ifm_status & IFM_AVALID) { - if ((ifmr.ifm_active & IFM_NMASK) == IFM_ETHER) { - if (ifmr.ifm_status & IFM_ACTIVE) - return (1); - else - return (0); - } - } -#endif return (1); }
Modified: trunk/reactos/base/services/dhcp/include/dhcpd.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/include/... ============================================================================== --- trunk/reactos/base/services/dhcp/include/dhcpd.h [iso-8859-1] (original) +++ trunk/reactos/base/services/dhcp/include/dhcpd.h [iso-8859-1] Sat Jul 25 04:28:11 2009 @@ -98,7 +98,6 @@ #include <sys/stat.h> //#include <sys/time.h> #include <ctype.h> -#include <errno.h> #include <fcntl.h> #include <limits.h> //#include <unistd.h>
Modified: trunk/reactos/base/services/dhcp/privsep.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/privsep.... ============================================================================== --- trunk/reactos/base/services/dhcp/privsep.c [iso-8859-1] (original) +++ trunk/reactos/base/services/dhcp/privsep.c [iso-8859-1] Sat Jul 25 04:28:11 2009 @@ -52,19 +52,16 @@ { ssize_t n;
- do { - n = write(sock, buf->buf + buf->rpos, buf->size - buf->rpos); - if (n != -1) - buf->rpos += n; - if (n == 0) { /* connection closed */ - errno = 0; - return (-1); - } - } while (n == -1 && (errno == EAGAIN || errno == EINTR)); + n = write(sock, buf->buf + buf->rpos, buf->size - buf->rpos); + if (n != -1) + buf->rpos += n; + if (n == 0) { /* connection closed */ + return (-1); + }
if (buf->rpos < buf->size) - error("short %s write: wanted %lu got %ld bytes", - strerror(errno), (unsigned long)buf->size, (long)buf->rpos); + error("short write: wanted %lu got %ld bytes", + (unsigned long)buf->size, (long)buf->rpos);
free(buf->buf); free(buf); @@ -77,19 +74,17 @@ ssize_t n, r = 0; char *p = buf;
- do { - n = read(sock, p, nbytes); - if (n == 0) - error("connection closed"); - if (n != -1) { - r += n; - p += n; - nbytes -= n; - } - } while (n == -1 && (errno == EINTR || errno == EAGAIN)); + n = read(sock, p, nbytes); + if (n == 0) + error("connection closed"); + if (n != -1) { + r += n; + p += n; + nbytes -= n; + }
if (n == -1) - error("buf_read: %s", strerror(errno)); + error("buf_read: %d", WSAGetLastError());
if (r < nbytes) error("short read: wanted %lu got %ld bytes", @@ -121,9 +116,8 @@ + sizeof(size_t) || medium_len == SIZE_T_MAX) error("corrupted message received"); if (medium_len > 0) { - if ((medium = calloc(1, medium_len + 1)) == NULL) - error("%s", strerror(errno)); - buf_read(fd, medium, medium_len); + if ((medium = calloc(1, medium_len + 1)) != NULL) + buf_read(fd, medium, medium_len); } else medium = NULL;
@@ -132,9 +126,8 @@ reason_len == SIZE_T_MAX) error("corrupted message received"); if (reason_len > 0) { - if ((reason = calloc(1, reason_len + 1)) == NULL) - error("%s", strerror(errno)); - buf_read(fd, reason, reason_len); + if ((reason = calloc(1, reason_len + 1)) != NULL) + buf_read(fd, reason, reason_len); } else reason = NULL;
@@ -155,9 +148,8 @@ if (hdr.len < totlen || filename_len == SIZE_T_MAX) error("corrupted message received"); if (filename_len > 0) { - if ((filename = calloc(1, filename_len + 1)) == NULL) - error("%s", strerror(errno)); - buf_read(fd, filename, filename_len); + if ((filename = calloc(1, filename_len + 1)) != NULL) + buf_read(fd, filename, filename_len); } else filename = NULL;
@@ -167,9 +159,8 @@ error("corrupted message received"); if (servername_len > 0) { if ((servername = - calloc(1, servername_len + 1)) == NULL) - error("%s", strerror(errno)); - buf_read(fd, servername, servername_len); + calloc(1, servername_len + 1)) != NULL) + buf_read(fd, servername, servername_len); } else servername = NULL;
@@ -178,9 +169,8 @@ if (hdr.len < totlen || prefix_len == SIZE_T_MAX) error("corrupted message received"); if (prefix_len > 0) { - if ((prefix = calloc(1, prefix_len + 1)) == NULL) - error("%s", strerror(errno)); - buf_read(fd, prefix, prefix_len); + if ((prefix = calloc(1, prefix_len + 1)) != NULL) + buf_read(fd, prefix, prefix_len); } else prefix = NULL;
@@ -197,9 +187,8 @@ error("corrupted message received"); lease.options[i].data = calloc(1, optlen + 1); - if (lease.options[i].data == NULL) - error("%s", strerror(errno)); - buf_read(fd, lease.options[i].data, optlen); + if (lease.options[i].data != NULL) + buf_read(fd, lease.options[i].data, optlen); } } lease.server_name = servername; @@ -222,14 +211,13 @@
hdr.code = IMSG_SCRIPT_GO_RET; hdr.len = sizeof(struct imsg_hdr) + sizeof(int); - if ((buf = buf_open(hdr.len)) == NULL) - error("buf_open: %s", strerror(errno)); - if (buf_add(buf, &hdr, sizeof(hdr))) - error("buf_add: %s", strerror(errno)); - if (buf_add(buf, &ret, sizeof(ret))) - error("buf_add: %s", strerror(errno)); - if (buf_close(fd, buf) == -1) - error("buf_close: %s", strerror(errno)); + buf = buf_open(hdr.len); + + if (buf != NULL) { + buf_add(buf, &hdr, sizeof(hdr)); + buf_add(buf, &ret, sizeof(ret)); + buf_close(fd, buf); + } break; default: error("received unknown message, code %d", hdr.code);