--------------------- PatchSet 3930 Date: 2002/04/07 09:59:51 Author: serassio Branch: nt-2_5 Tag: (none) Log: WIN32 various code clean Members: include/config.h:1.5.18.2->1.5.18.3 include/util.h:1.10.14.2->1.10.14.3 lib/win32lib.c:1.1.32.1->1.1.32.2 port/win32/squid.dsw:1.1.2.5->1.1.2.6 port/win32/include/squid-mswin.h:1.1.2.6->1.1.2.7 src/comm.c:1.18.6.1.2.5->1.18.6.1.2.6 src/helper.c:1.16.10.2->1.16.10.3 src/icmp.c:1.4.74.2->1.4.74.3 src/ipc.c:1.7.10.3->1.7.10.4 src/main.c:1.28.6.1.4.5->1.28.6.1.4.6 src/structs.h:1.48.6.3->1.48.6.4 src/tools.c:1.19.14.3->1.19.14.4 src/win32.c:1.5.14.5->1.5.14.6 src/fs/awin32/store_dir_aufs.c:1.1.62.2->1.1.62.3 src/fs/ufs/store_dir_ufs.c:1.21.6.1.4.5->1.21.6.1.4.6 Index: squid/include/config.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/config.h,v retrieving revision 1.5.18.2 retrieving revision 1.5.18.3 diff -u -r1.5.18.2 -r1.5.18.3 --- squid/include/config.h 23 Mar 2002 10:35:24 -0000 1.5.18.2 +++ squid/include/config.h 7 Apr 2002 09:59:51 -0000 1.5.18.3 @@ -105,7 +105,7 @@ #define _SQUID_CYGWIN_ #elif defined(WIN32) || defined(WINNT) || defined(__WIN32__) || defined(__WIN32) -#define _SQUID_MSWIN_ /* MS Compilers */ +#define _SQUID_MSWIN_ #include "squid-mswin.h" #elif defined(__APPLE__) Index: squid/include/util.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/util.h,v retrieving revision 1.10.14.2 retrieving revision 1.10.14.3 diff -u -r1.10.14.2 -r1.10.14.3 --- squid/include/util.h 16 Mar 2002 09:27:35 -0000 1.10.14.2 +++ squid/include/util.h 7 Apr 2002 09:59:51 -0000 1.10.14.3 @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.10.14.2 2002/03/16 09:27:35 serassio Exp $ + * $Id: util.h,v 1.10.14.3 2002/04/07 09:59:51 serassio Exp $ * * AUTHOR: Harvest Derived * @@ -146,6 +146,7 @@ extern const char * wsastrerror(int); extern struct passwd *getpwnam(char *); extern struct group *getgrnam(char *); +extern uid_t geteuid(void); #endif #endif /* SQUID_UTIL_H */ Index: squid/lib/win32lib.c =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/win32lib.c,v retrieving revision 1.1.32.1 retrieving revision 1.1.32.2 diff -u -r1.1.32.1 -r1.1.32.2 --- squid/lib/win32lib.c 16 Mar 2002 09:27:35 -0000 1.1.32.1 +++ squid/lib/win32lib.c 7 Apr 2002 09:59:51 -0000 1.1.32.2 @@ -1,5 +1,5 @@ /* - * $Id: win32lib.c,v 1.1.32.1 2002/03/16 09:27:35 serassio Exp $ + * $Id: win32lib.c,v 1.1.32.2 2002/04/07 09:59:51 serassio Exp $ * * * * * * * * * Legal stuff * * * * * * * * @@ -47,6 +47,13 @@ int opterr = 1; int optopt; + + +uid_t geteuid(void) +{ + return 100; +} + int chroot (const char *dirname) { if (SetCurrentDirectory(dirname)) Index: squid/port/win32/squid.dsw =================================================================== RCS file: /cvsroot/squid-sf//squid/port/win32/Attic/squid.dsw,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -r1.1.2.5 -r1.1.2.6 --- squid/port/win32/squid.dsw 27 Mar 2002 21:01:10 -0000 1.1.2.5 +++ squid/port/win32/squid.dsw 7 Apr 2002 09:59:52 -0000 1.1.2.6 @@ -119,6 +119,9 @@ Package=<4> {{{ + Begin Project Dependency + Project_Dep_Name modules + End Project Dependency }}} ############################################################################### Index: squid/port/win32/include/squid-mswin.h =================================================================== RCS file: /cvsroot/squid-sf//squid/port/win32/include/Attic/squid-mswin.h,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- squid/port/win32/include/squid-mswin.h 4 Apr 2002 21:48:52 -0000 1.1.2.6 +++ squid/port/win32/include/squid-mswin.h 7 Apr 2002 09:59:52 -0000 1.1.2.7 @@ -1,5 +1,5 @@ /* - * $Id: squid-mswin.h,v 1.1.2.6 2002/04/04 21:48:52 serassio Exp $ + * $Id: squid-mswin.h,v 1.1.2.7 2002/04/07 09:59:52 serassio Exp $ * * AUTHOR: Guido Serassio & Andrey Shorin * @@ -49,7 +49,6 @@ #define ftruncate WIN32_ftruncate #define getcwd _getcwd #define getpid _getpid -#define geteuid() 100 #define getegid() 100 #define getrusage WIN32_getrusage #define ioctl ioctlsocket @@ -270,7 +269,7 @@ (SOCKET_ERROR == getsockname(_get_osfhandle(s),n,l) ? \ (errno = WSAGetLastError()), -1 : 0) #define getsockopt(s,l,o,v,n) \ - (Sleep(1), SOCKET_ERROR == getsockopt(_get_osfhandle(s),l,o,v,n) ? \ + (Sleep(1), SOCKET_ERROR == getsockopt(_get_osfhandle(s),l,o,(char*)v,n) ? \ (errno = WSAGetLastError()), -1 : 0) #define setsockopt(s,l,o,v,n) \ (SOCKET_ERROR == setsockopt(_get_osfhandle(s),l,o,v,n) ? \ @@ -321,11 +320,11 @@ extern __declspec(thread) int _so_err_siz; #define read(fd,buf,siz) \ (_so_err_siz = sizeof(_so_err), \ - getsockopt((fd),SOL_SOCKET,SO_ERROR,(char*)&_so_err,&_so_err_siz) \ + getsockopt((fd),SOL_SOCKET,SO_ERROR,&_so_err,&_so_err_siz) \ == 0 ? recv((fd),(buf),(siz),0) : _read((fd),(buf),(siz))) #define write(fd,buf,siz) \ (_so_err_siz = sizeof(_so_err), \ - getsockopt((fd),SOL_SOCKET,SO_ERROR,(char*)&_so_err,&_so_err_siz) \ + getsockopt((fd),SOL_SOCKET,SO_ERROR,&_so_err,&_so_err_siz) \ == 0 ? send((fd),(buf),(siz),0) : _write((fd),(buf),(siz))) #endif Index: squid/src/comm.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm.c,v retrieving revision 1.18.6.1.2.5 retrieving revision 1.18.6.1.2.6 diff -u -r1.18.6.1.2.5 -r1.18.6.1.2.6 --- squid/src/comm.c 4 Apr 2002 19:52:56 -0000 1.18.6.1.2.5 +++ squid/src/comm.c 7 Apr 2002 09:59:52 -0000 1.18.6.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: comm.c,v 1.18.6.1.2.5 2002/04/04 19:52:56 serassio Exp $ + * $Id: comm.c,v 1.18.6.1.2.6 2002/04/07 09:59:52 serassio Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -790,7 +790,9 @@ int commSetNonBlocking(int fd) { +#ifndef _SQUID_MSWIN_ int flags; +#endif int dummy = 0; #if defined (_SQUID_CYGWIN_) || defined (_SQUID_MSWIN_) int nonblocking = TRUE; Index: squid/src/helper.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/helper.c,v retrieving revision 1.16.10.2 retrieving revision 1.16.10.3 diff -u -r1.16.10.2 -r1.16.10.3 --- squid/src/helper.c 4 Apr 2002 19:40:22 -0000 1.16.10.2 +++ squid/src/helper.c 7 Apr 2002 09:59:52 -0000 1.16.10.3 @@ -1,6 +1,6 @@ /* - * $Id: helper.c,v 1.16.10.2 2002/04/04 19:40:22 serassio Exp $ + * $Id: helper.c,v 1.16.10.3 2002/04/07 09:59:52 serassio Exp $ * * DEBUG: section 29 Helper process maintenance * AUTHOR: Harvest Derived? @@ -79,7 +79,6 @@ HANDLE hIpc; pid_t pid; #endif - if (hlp->cmdline == NULL) return; progname = hlp->cmdline->key; Index: squid/src/icmp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/icmp.c,v retrieving revision 1.4.74.2 retrieving revision 1.4.74.3 diff -u -r1.4.74.2 -r1.4.74.3 --- squid/src/icmp.c 4 Apr 2002 19:40:22 -0000 1.4.74.2 +++ squid/src/icmp.c 7 Apr 2002 09:59:52 -0000 1.4.74.3 @@ -1,6 +1,6 @@ /* - * $Id: icmp.c,v 1.4.74.2 2002/04/04 19:40:22 serassio Exp $ + * $Id: icmp.c,v 1.4.74.3 2002/04/07 09:59:52 serassio Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels @@ -33,6 +33,7 @@ * */ + #ifndef ICMP_C #define ICMP_C #include "squid.h" Index: squid/src/ipc.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ipc.c,v retrieving revision 1.7.10.3 retrieving revision 1.7.10.4 diff -u -r1.7.10.3 -r1.7.10.4 --- squid/src/ipc.c 27 Mar 2002 21:01:18 -0000 1.7.10.3 +++ squid/src/ipc.c 7 Apr 2002 09:59:52 -0000 1.7.10.4 @@ -1,6 +1,6 @@ /* - * $Id: ipc.c,v 1.7.10.3 2002/03/27 21:01:18 serassio Exp $ + * $Id: ipc.c,v 1.7.10.4 2002/04/07 09:59:52 serassio Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -632,7 +632,7 @@ ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } - x = write(c2p[1], &wpi, sizeof(wpi)); + x = write(c2p[1], (const char *) &wpi, sizeof(wpi)); if (x < sizeof(wpi)) { debug(50, 0) ("ipcCreate: CHILD: write FD %d: %s\n", c2p[1], xstrerror()); @@ -658,7 +658,7 @@ ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } - x = write(c2p[1], &PS_ipc, sizeof(PS_ipc)); + x = write(c2p[1], (const char *) &PS_ipc, sizeof(PS_ipc)); if (x < sizeof(PS_ipc)) { debug(50, 0) ("ipcCreate: CHILD: write FD %d: %s\n", c2p[1], xstrerror()); Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.28.6.1.4.5 retrieving revision 1.28.6.1.4.6 diff -u -r1.28.6.1.4.5 -r1.28.6.1.4.6 --- squid/src/main.c 6 Apr 2002 15:02:40 -0000 1.28.6.1.4.5 +++ squid/src/main.c 7 Apr 2002 09:59:52 -0000 1.28.6.1.4.6 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.28.6.1.4.5 2002/04/06 15:02:40 serassio Exp $ + * $Id: main.c,v 1.28.6.1.4.6 2002/04/07 09:59:52 serassio Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -487,7 +487,7 @@ leave_suid(); /* Run as non privilegied user */ #ifdef _SQUID_OS2_ return; -#else +#endif if (geteuid() == 0) { debug(0, 0) ("Squid is not safe to run as root! If you must\n"); debug(0, 0) ("start Squid as root, then you must configure\n"); @@ -495,7 +495,6 @@ debug(0, 0) ("'cache_effective_user' option in the config file.\n"); fatal("Don't run Squid as root, set 'cache_effective_user'!"); } -#endif } static void @@ -1149,11 +1148,7 @@ errorClean(); #endif #if !XMALLOC_TRACE -#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) - if ((WIN32_run_mode == _WIN_SQUID_RUN_MODE_INTERACTIVE) && (opt_no_daemon)) { -#else if (opt_no_daemon) { -#endif file_close(0); file_close(1); file_close(2); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.48.6.3 retrieving revision 1.48.6.4 diff -u -r1.48.6.3 -r1.48.6.4 --- squid/src/structs.h 4 Apr 2002 19:52:57 -0000 1.48.6.3 +++ squid/src/structs.h 7 Apr 2002 09:59:52 -0000 1.48.6.4 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.48.6.3 2002/04/04 19:52:57 serassio Exp $ + * $Id: structs.h,v 1.48.6.4 2002/04/07 09:59:52 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -749,11 +749,8 @@ u_short local_port; u_short remote_port; #ifdef _SQUID_MSWIN_ - FILE * fbuf; - #endif - struct in_addr local_addr; unsigned char tos; char ipaddr[16]; /* dotted decimal address of peer */ @@ -2059,13 +2056,9 @@ int uses; } stats; #ifdef _SQUID_MSWIN_ - HANDLE hIpc; - pid_t pid; - #endif - }; Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/tools.c,v retrieving revision 1.19.14.3 retrieving revision 1.19.14.4 diff -u -r1.19.14.3 -r1.19.14.4 --- squid/src/tools.c 4 Apr 2002 19:52:57 -0000 1.19.14.3 +++ squid/src/tools.c 7 Apr 2002 09:59:52 -0000 1.19.14.4 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.19.14.3 2002/04/04 19:52:57 serassio Exp $ + * $Id: tools.c,v 1.19.14.4 2002/04/07 09:59:52 serassio Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -306,13 +306,9 @@ sigusr2_handle(int sig) { #if defined(_SQUID_MSWIN_) && defined(_DEBUG) - do_debug = 1; - #endif - #if (defined(_SQUID_MSWIN_) && !defined(_DEBUG)) || !defined(_SQUID_MSWIN_) - static int state = 0; /* no debug() here; bad things happen if the signal is delivered during _db_print() */ if (state == 0) { @@ -331,7 +327,6 @@ state = 0; } #endif - #if !HAVE_SIGACTION signal(sig, sigusr2_handle); /* reinstall */ #endif @@ -426,7 +421,6 @@ sig_child(int sig) { #ifndef _SQUID_MSWIN_ - #ifdef _SQUID_NEXT_ union wait status; #else @@ -448,7 +442,6 @@ signal(sig, sig_child); #endif #endif - } const char * Index: squid/src/win32.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/win32.c,v retrieving revision 1.5.14.5 retrieving revision 1.5.14.6 diff -u -r1.5.14.5 -r1.5.14.6 --- squid/src/win32.c 4 Apr 2002 21:48:53 -0000 1.5.14.5 +++ squid/src/win32.c 7 Apr 2002 09:59:52 -0000 1.5.14.6 @@ -99,7 +99,7 @@ HKEY hKey; HKEY hKeyNext; int retval; - long rv; + LONG rv; hKey = HKEY_LOCAL_MACHINE; index = 0; @@ -151,7 +151,7 @@ WIN32_StoreKey(const char *key, DWORD type, unsigned char *value, int value_size) { - long rv; + LONG rv; HKEY hKey; int retval; @@ -345,16 +345,6 @@ WIN32_svcHandler); if (svcHandle == 0) return 1; - /* Set Service Staus to SERVICE_START_PENDING */ - svcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; - svcStatus.dwCurrentState = SERVICE_START_PENDING; - svcStatus.dwControlsAccepted = - SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; - svcStatus.dwWin32ExitCode = 0; - svcStatus.dwServiceSpecificExitCode = 0; - svcStatus.dwCheckPoint = 0; - svcStatus.dwWaitHint = 10000; - SetServiceStatus(svcHandle, &svcStatus); /* Set Process work dir to directory cointaining squid.exe */ GetModuleFileName(NULL, path, 512); WIN32_module_name=xstrdup(path); @@ -393,6 +383,16 @@ WIN32_build_argv(WIN32_Service_Command_Line); *argc = WIN32_argc; *argv = WIN32_argv; + /* Set Service Status to SERVICE_START_PENDING */ + svcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + svcStatus.dwCurrentState = SERVICE_START_PENDING; + svcStatus.dwControlsAccepted = + SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + svcStatus.dwWin32ExitCode = 0; + svcStatus.dwServiceSpecificExitCode = 0; + svcStatus.dwCheckPoint = 0; + svcStatus.dwWaitHint = 10000; + SetServiceStatus(svcHandle, &svcStatus); #ifdef _SQUID_MSWIN_ _setmaxstdio(Squid_MaxFD); #endif Index: squid/src/fs/awin32/store_dir_aufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/awin32/Attic/store_dir_aufs.c,v retrieving revision 1.1.62.2 retrieving revision 1.1.62.3 diff -u -r1.1.62.2 -r1.1.62.3 --- squid/src/fs/awin32/store_dir_aufs.c 4 Apr 2002 21:48:53 -0000 1.1.62.2 +++ squid/src/fs/awin32/store_dir_aufs.c 7 Apr 2002 09:59:53 -0000 1.1.62.3 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.c,v 1.1.62.2 2002/04/04 21:48:53 serassio Exp $ + * $Id: store_dir_aufs.c,v 1.1.62.3 2002/04/07 09:59:53 serassio Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -417,7 +417,12 @@ rb->sd->path, rb->counts.scancount); debug(20, 9) ("file_in: fd=%d %08X\n", fd, filn); statCounter.syscalls.disk.reads++; +#ifdef _SQUID_MSWIN_ + if (fread(hdr_buf, 1, SM_PAGE_SIZE, fd_table[fd].fbuf) == 0 + && ferror(fd_table[fd].fbuf)) { +#else if (read(fd, hdr_buf, SM_PAGE_SIZE) < 0) { +#endif debug(20, 1) ("storeAufsDirRebuildFromDirectory: read(FD %d): %s\n", fd, xstrerror()); file_close(fd); @@ -467,9 +472,9 @@ tmpe.hash.key = key; /* check sizes */ if (tmpe.swap_file_sz == 0) { - tmpe.swap_file_sz = sb.st_size; + tmpe.swap_file_sz = (size_t) sb.st_size; } else if (tmpe.swap_file_sz == sb.st_size - swap_hdr_len) { - tmpe.swap_file_sz = sb.st_size; + tmpe.swap_file_sz = (size_t) sb.st_size; } else if (tmpe.swap_file_sz != sb.st_size) { debug(20, 1) ("storeAufsDirRebuildFromDirectory: SIZE MISMATCH %ld!=%ld\n", (long int) tmpe.swap_file_sz, (long int) sb.st_size); @@ -917,6 +922,9 @@ debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror()); fatal("Failed to open swap log for reading"); } +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) + setmode(fileno(fp), O_BINARY); +#endif memset(&clean_sb, '\0', sizeof(struct stat)); if (stat(clean_path, &clean_sb) < 0) *clean_flag = 0; @@ -1019,7 +1027,11 @@ state->outbuf_offset += ss; /* buffered write */ if (state->outbuf_offset + ss > CLEAN_BUF_SZ) { +#ifdef _SQUID_MSWIN_ + if (fwrite(state->outbuf, 1, state->outbuf_offset, fd_table[state->fd].fbuf) < (size_t) state->outbuf_offset) { +#else if (write(state->fd, state->outbuf, state->outbuf_offset) < 0) { +#endif debug(50, 0) ("storeDirWriteCleanLogs: %s: write: %s\n", state->new, xstrerror()); debug(20, 0) ("storeDirWriteCleanLogs: Current swap logfile not replaced.\n"); @@ -1038,6 +1050,9 @@ static void storeAufsDirWriteCleanDone(SwapDir * sd) { +#ifdef _SQUID_MSWIN_ + FILE *fbuf; +#endif int fd; struct _clean_state *state = sd->log.clean.state; if (NULL == state) @@ -1045,7 +1060,13 @@ if (state->fd < 0) return; state->walker->Done(state->walker); +#ifdef _SQUID_MSWIN_ + fbuf=fd_table[state->fd].fbuf; + fwrite(state->outbuf, 1, state->outbuf_offset, fbuf); + if (ferror(fbuf) || feof(fbuf)){ +#else if (write(state->fd, state->outbuf, state->outbuf_offset) < 0) { +#endif debug(50, 0) ("storeDirWriteCleanLogs: %s: write: %s\n", state->new, xstrerror()); debug(20, 0) ("storeDirWriteCleanLogs: Current swap logfile " @@ -1589,8 +1610,6 @@ static int storeAufsCleanupDoubleCheck(SwapDir * sd, StoreEntry * e) { -#ifndef _SQUID_MSWIN_ - struct stat sb; if (stat(storeAufsDirFullPath(sd, e->swap_filen, NULL), &sb) < 0) { debug(20, 0) ("storeAufsCleanupDoubleCheck: MISSING SWAP FILE\n"); @@ -1610,8 +1629,6 @@ storeEntryDump(e, 0); return -1; } -#endif - return 0; } Index: squid/src/fs/ufs/store_dir_ufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/ufs/store_dir_ufs.c,v retrieving revision 1.21.6.1.4.5 retrieving revision 1.21.6.1.4.6 diff -u -r1.21.6.1.4.5 -r1.21.6.1.4.6 --- squid/src/fs/ufs/store_dir_ufs.c 4 Apr 2002 19:52:57 -0000 1.21.6.1.4.5 +++ squid/src/fs/ufs/store_dir_ufs.c 7 Apr 2002 09:59:53 -0000 1.21.6.1.4.6 @@ -957,7 +957,9 @@ storeUfsDirWriteCleanStart(SwapDir * sd) { struct _clean_state *state = xcalloc(1, sizeof(*state)); +#if HAVE_FCHMOD struct stat sb; +#endif sd->log.clean.write = NULL; sd->log.clean.state = NULL; state->new = xstrdup(storeUfsDirSwapLogFile(sd, ".clean")); @@ -1025,7 +1027,7 @@ /* buffered write */ if (state->outbuf_offset + ss > CLEAN_BUF_SZ) { #ifdef _SQUID_MSWIN_ - if (fwrite(state->outbuf, 1, state->outbuf_offset, fd_table[state->fd].fbuf) < state->outbuf_offset) { + if (fwrite(state->outbuf, 1, state->outbuf_offset, fd_table[state->fd].fbuf) < (size_t) state->outbuf_offset) { #else if (write(state->fd, state->outbuf, state->outbuf_offset) < 0) { #endif