From 9c3e7020a8f07c099faa5f9bf4f6abd951fc38fa Mon Sep 17 00:00:00 2001 From: helge Date: Sun, 24 Apr 2005 18:52:51 +0000 Subject: [PATCH] fixed gcc 4.0 warnings do not flush input streams git-svn-id: http://svn.opengroupware.org/SOPE/trunk@772 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-core/NGStreams/ChangeLog | 8 +++++++ sope-core/NGStreams/NGCTextStream.m | 8 ++++--- sope-core/NGStreams/NGDatagramSocket.m | 8 +++---- sope-core/NGStreams/NGFileStream.m | 24 ++++++++++++------- sope-core/NGStreams/NGInternetSocketAddress.m | 6 ++--- sope-core/NGStreams/NGNetUtilities.m | 24 +++++++++++-------- sope-core/NGStreams/NGPassiveSocket.m | 4 ++-- sope-core/NGStreams/NGSocket.m | 9 +++++-- sope-core/NGStreams/Version | 2 +- 9 files changed, 59 insertions(+), 34 deletions(-) diff --git a/sope-core/NGStreams/ChangeLog b/sope-core/NGStreams/ChangeLog index f705d41c..247e80ac 100644 --- a/sope-core/NGStreams/ChangeLog +++ b/sope-core/NGStreams/ChangeLog @@ -1,3 +1,11 @@ +2005-04-24 Helge Hess + + * v4.5.47 + + * fixed some gcc 4.0 warnings + + * NGCTextStream.m, NGFileStream.m: do not flush input streams + 2004-11-07 Helge Hess * NGStreams.xcode: properly link against libssl/libcrypto and set diff --git a/sope-core/NGStreams/NGCTextStream.m b/sope-core/NGStreams/NGCTextStream.m index 4708ed1c..2fe1a447 100644 --- a/sope-core/NGStreams/NGCTextStream.m +++ b/sope-core/NGStreams/NGCTextStream.m @@ -64,13 +64,15 @@ NGStreams_DECLARE void NGInitTextStdio(void) { } + (void)_flushForExit:(NSNotification *)_notification { - [NGTextIn flush]; [NGTextIn release]; NGTextIn = nil; + // [NGTextIn flush]; + [NGTextIn release]; NGTextIn = nil; [NGTextOut flush]; [NGTextOut release]; NGTextOut = nil; [NGTextErr flush]; [NGTextErr release]; NGTextErr = nil; } static void _flushAtExit(void) { - [NGTextIn flush]; [NGTextIn release]; NGTextIn = nil; + // [NGTextIn flush]; + [NGTextIn release]; NGTextIn = nil; [NGTextOut flush]; [NGTextOut release]; NGTextOut = nil; [NGTextErr flush]; [NGTextErr release]; NGTextErr = nil; } @@ -293,7 +295,7 @@ static void _flushAtExit(void) { return YES; buf = str = calloc(toGo + 1, sizeof(unsigned char)); - [_string getCString:str]; str[toGo] = '\0'; + [_string getCString:(char *)str]; str[toGo] = '\0'; NS_DURING { while (toGo > 0) { diff --git a/sope-core/NGStreams/NGDatagramSocket.m b/sope-core/NGStreams/NGDatagramSocket.m index fd64044a..b60c092e 100644 --- a/sope-core/NGStreams/NGDatagramSocket.m +++ b/sope-core/NGStreams/NGDatagramSocket.m @@ -230,10 +230,10 @@ static const NSTimeInterval NGNoTimeout = 0.0; - (id)primaryReceivePacketWithMaxSize:(int)_maxSize { id remote = nil; id packet = nil; - char buffer[_maxSize]; - size_t size; - int len = [[self domain] addressRepresentationSize]; - char data[len]; + char buffer[_maxSize]; + size_t size; + unsigned int len = [[self domain] addressRepresentationSize]; + char data[len + 2]; size = recvfrom(self->fd, buffer, _maxSize, 0, // flags diff --git a/sope-core/NGStreams/NGFileStream.m b/sope-core/NGStreams/NGFileStream.m index d3c9f629..4b99c152 100644 --- a/sope-core/NGStreams/NGFileStream.m +++ b/sope-core/NGStreams/NGFileStream.m @@ -125,9 +125,12 @@ void NGInitStdio(void) { to = [[NGFileStream alloc] __initWithOutConsole]; te = [to retain]; #else - ti = [[NGFileStream alloc] __initWithDescriptor:0 mode:NGStreamMode_readOnly]; - to = [[NGFileStream alloc] __initWithDescriptor:1 mode:NGStreamMode_writeOnly]; - te = [[NGFileStream alloc] __initWithDescriptor:2 mode:NGStreamMode_writeOnly]; + ti = [[NGFileStream alloc] __initWithDescriptor:0 + mode:NGStreamMode_readOnly]; + to = [[NGFileStream alloc] __initWithDescriptor:1 + mode:NGStreamMode_writeOnly]; + te = [[NGFileStream alloc] __initWithDescriptor:2 + mode:NGStreamMode_writeOnly]; #endif NGIn = [[NGBufferedStream alloc] initWithSource:(id)ti]; @@ -145,20 +148,23 @@ void NGInitStdio(void) { if ([NGIn isKindOfClass:[NGLockingStream class]]) return; - - li = [[NGLockingStream alloc] initWithSource:NGIn]; [NGIn release]; NGIn = li; - lo = [[NGLockingStream alloc] initWithSource:NGOut]; [NGOut release]; NGOut = lo; - le = [[NGLockingStream alloc] initWithSource:NGErr]; [NGErr release]; NGErr = le; + + li = [[NGLockingStream alloc] initWithSource:(id)NGIn]; + [NGIn release]; NGIn = li; + lo = [[NGLockingStream alloc] initWithSource:(id)NGOut]; + [NGOut release]; NGOut = lo; + le = [[NGLockingStream alloc] initWithSource:(id)NGErr]; + [NGErr release]; NGErr = le; } + (void)_flushForExit:(NSNotification *)_notification { - [NGIn flush]; + //[NGIn flush]; [NGOut flush]; [NGErr flush]; } static void _flushForExit(void) { - [NGIn flush]; + //[NGIn flush]; [NGOut flush]; [NGErr flush]; } diff --git a/sope-core/NGStreams/NGInternetSocketAddress.m b/sope-core/NGStreams/NGInternetSocketAddress.m index d106cdfe..d50abdc4 100644 --- a/sope-core/NGStreams/NGInternetSocketAddress.m +++ b/sope-core/NGStreams/NGInternetSocketAddress.m @@ -262,10 +262,10 @@ static inline NSString *_nameOfLocalhost(void) { else { const unsigned char *chost; - chost = [[self hostName] cString]; + chost = (unsigned char *)[[self hostName] cString]; // try to interpret hostname as INET dotted address (eg 122.133.44.87) - *ia = inet_addr(chost); + *ia = inet_addr((char *)chost); if ((int)*ia != -1) { // succeeded self->isAddressFilled = YES; @@ -297,7 +297,7 @@ static inline NSString *_nameOfLocalhost(void) { #else [systemLock lock]; { - if ((hostEntity = gethostbyname(chost)) == NULL) { + if ((hostEntity = gethostbyname((char *)chost)) == NULL) { didFail = YES; #if defined(WIN32) && !defined(__CYGWIN32__) errorCode = WSAGetLastError(); diff --git a/sope-core/NGStreams/NGNetUtilities.m b/sope-core/NGStreams/NGNetUtilities.m index f0c41d46..a421b3e5 100644 --- a/sope-core/NGStreams/NGNetUtilities.m +++ b/sope-core/NGStreams/NGNetUtilities.m @@ -25,40 +25,44 @@ #include "common.h" id NGSocketAddressFromString(NSString *_string) { - const unsigned char *cstr = [_string cString]; + const unsigned char *cstr = (unsigned char *)[_string cString]; if (cstr == NULL) return nil; if ([_string length] < 1) return nil; { - const unsigned char *tmp = index(cstr, ':'); + const unsigned char *tmp = (unsigned char *)index((char *)cstr, ':'); if (tmp) { // INET socket NSString *hostName = nil; if (((tmp - cstr) == 1) && (*cstr == '*')) hostName = nil; // wildcard host - else - hostName = [NSString stringWithCString:cstr length:(tmp - cstr)]; + else { + hostName = [NSString stringWithCString:(char *)cstr + length:(tmp - cstr)]; + } // check what comes after colon if (isdigit(tmp[1])) { // a port - int port = atoi(tmp + 1); + int port = atoi((char *)tmp + 1); return [NGInternetSocketAddress addressWithPort:port onHost:hostName]; } else { // a service or 'auto' for auto-assigned ports - const unsigned char *tmp2 = index((tmp + 1), '/'); + const unsigned char *tmp2; NSString *protocol = @"tcp"; NSString *service; - + + tmp2 = (unsigned char *)index((char *)(tmp + 1), '/'); tmp++; if (tmp2 == NULL) - service = [NSString stringWithCString:tmp]; + service = [NSString stringWithCString:(char *)tmp]; else { - service = [NSString stringWithCString:tmp length:(tmp2 - tmp)]; - protocol = [NSString stringWithCString:(tmp2 + 1)]; + service = [NSString stringWithCString:(char *)tmp + length:(tmp2 - tmp)]; + protocol = [NSString stringWithCString:(char *)(tmp2 + 1)]; } if ([service isEqualToString:@"auto"]) diff --git a/sope-core/NGStreams/NGPassiveSocket.m b/sope-core/NGStreams/NGPassiveSocket.m index 57da080f..8c4a6fc3 100644 --- a/sope-core/NGStreams/NGPassiveSocket.m +++ b/sope-core/NGStreams/NGPassiveSocket.m @@ -203,7 +203,7 @@ SYNCHRONIZED(self->acceptLock) { id local = nil; id remote = nil; - int len; + socklen_t len; char *data; int newFd = NGInvalidSocketDescriptor; @@ -215,7 +215,7 @@ NSString *reason = nil; reason = [self reasonForLastError]; reason = [@"Could not accept: " stringByAppendingString:reason]; - + [[[NGCouldNotAcceptException alloc] initWithReason:reason socket:self] raise]; } diff --git a/sope-core/NGStreams/NGSocket.m b/sope-core/NGStreams/NGSocket.m index 4641897a..51af5131 100644 --- a/sope-core/NGStreams/NGSocket.m +++ b/sope-core/NGStreams/NGSocket.m @@ -462,9 +462,14 @@ static void _killWinSock(void) { } - (void)getOption:(int)_option level:(int)_level value:(void *)_value - len:(int *)_len { + len:(int *)_len +{ + int rc; + socklen_t tlen; - if (getsockopt(fd, _level, _option, _value, _len) != 0) { + rc = getsockopt(fd, _level, _option, _value, &tlen); + if (_len) *_len = tlen; + if (rc != 0) { NSString *reason = nil; #if defined(WIN32) && !defined(__CYGWIN32__) int e = WSAGetLastError(); diff --git a/sope-core/NGStreams/Version b/sope-core/NGStreams/Version index 3e648f95..25b5b300 100644 --- a/sope-core/NGStreams/Version +++ b/sope-core/NGStreams/Version @@ -1,3 +1,3 @@ # version file -SUBMINOR_VERSION:=46 +SUBMINOR_VERSION:=47 -- 2.39.5