Developer Area

Changeset 673

Show
Ignore:
Timestamp:
01/20/10 08:24:28 (8 weeks ago)
Author:
henri
Message:

Fixed some compile warnings

Location:
apps/iphone
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • apps/iphone/my.tel/trunk/Classes/JSON/SBJSON.m

    r130 r673  
    11/* 
    2 Copyright (C) 2008 Stig Brautaset. All rights reserved. 
    3  
    4 Redistribution and use in source and binary forms, with or without 
    5 modification, are permitted provided that the following conditions are met: 
    6  
    7   Redistributions of source code must retain the above copyright notice, this 
    8   list of conditions and the following disclaimer. 
    9  
    10   Redistributions in binary form must reproduce the above copyright notice, 
    11   this list of conditions and the following disclaimer in the documentation 
    12   and/or other materials provided with the distribution. 
    13  
    14   Neither the name of the author nor the names of its contributors may be used 
    15   to endorse or promote products derived from this software without specific 
    16   prior written permission. 
    17  
    18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
    19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
    20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
    21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
    22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
    23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
    24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
    25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
    26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    28 */ 
     2 Copyright (C) 2008 Stig Brautaset. All rights reserved. 
     3  
     4 Redistribution and use in source and binary forms, with or without 
     5 modification, are permitted provided that the following conditions are met: 
     6  
     7 Redistributions of source code must retain the above copyright notice, this 
     8 list of conditions and the following disclaimer. 
     9  
     10 Redistributions in binary form must reproduce the above copyright notice, 
     11 this list of conditions and the following disclaimer in the documentation 
     12 and/or other materials provided with the distribution. 
     13  
     14 Neither the name of the author nor the names of its contributors may be used 
     15 to endorse or promote products derived from this software without specific 
     16 prior written permission. 
     17  
     18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
     19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
     21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
     22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
     23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
     24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
     25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
     26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     28 */ 
    2929 
    3030#import "SBJSON.h" 
     
    169169        if (![self appendArray:fragment into:json error:error]) 
    170170            return NO; 
    171  
     171                 
    172172    } else if ([fragment isKindOfClass:[NSString class]]) { 
    173173        if (![self appendString:fragment into:json error:error]) 
    174174            return NO; 
    175  
     175                 
    176176    } else if ([fragment isKindOfClass:[NSNumber class]]) { 
    177177        if ('c' == *[fragment objCType]) 
     
    179179        else 
    180180            [json appendString:[fragment stringValue]]; 
    181  
     181                 
    182182    } else if ([fragment isKindOfClass:[NSNull class]]) { 
    183183        [json appendString:@"null"]; 
    184184         
    185185    } else { 
    186         *error = err(EUNSUPPORTED, [NSString stringWithFormat:@"JSON serialisation not supported for %@", [fragment class]]); 
     186                if (error) 
     187                        *error = err(EUNSUPPORTED, [NSString stringWithFormat:@"JSON serialisation not supported for %@", [fragment class]]); 
    187188        return NO; 
    188189    } 
     
    200201        else 
    201202            addComma = YES; 
    202  
     203                 
    203204        if ([self humanReadable]) 
    204205            [json appendString:[self indent]]; 
     
    208209        } 
    209210    } 
    210  
     211         
    211212    depth--; 
    212213    if ([self humanReadable] && [fragment count]) 
     
    219220    [json appendString:@"{"]; 
    220221    depth++; 
    221  
     222         
    222223    NSString *colon = [self humanReadable] ? @" : " : @":"; 
    223224    BOOL addComma = NO; 
     
    231232        else 
    232233            addComma = YES; 
    233  
     234                 
    234235        if ([self humanReadable]) 
    235236            [json appendString:[self indent]]; 
    236237         
    237238        if (![value isKindOfClass:[NSString class]]) { 
    238             *error = err(EUNSUPPORTED, @"JSON object key must be string"); 
     239                        if (error) 
     240                                *error = err(EUNSUPPORTED, @"JSON object key must be string"); 
    239241            return NO; 
    240242        } 
     
    242244        if (![self appendString:value into:json error:error]) 
    243245            return NO; 
    244  
     246                 
    245247        [json appendString:colon]; 
    246248        if (![self appendValue:[fragment objectForKey:value] into:json error:error]) { 
    247             *error = err(EUNSUPPORTED, [NSString stringWithFormat:@"Unsupported value for key %@ in object", value]); 
    248             return NO; 
    249         } 
    250     } 
    251  
     249                        if (error) 
     250                                *error = err(EUNSUPPORTED, [NSString stringWithFormat:@"Unsupported value for key %@ in object", value]); 
     251            return NO; 
     252        } 
     253    } 
     254         
    252255    depth--; 
    253256    if ([self humanReadable] && [fragment count]) 
     
    258261 
    259262- (BOOL)appendString:(NSString*)fragment into:(NSMutableString*)json error:(NSError**)error { 
    260  
     263         
    261264    static NSMutableCharacterSet *kEscapeChars; 
    262265    if( ! kEscapeChars ) { 
     
    295298        } 
    296299    } 
    297  
     300         
    298301    [json appendString:@"\""]; 
    299302    return YES; 
     
    311314 */ 
    312315- (id)objectWithString:(id)repr allowScalar:(BOOL)allowScalar error:(NSError**)error { 
    313  
     316         
    314317    if (!repr) { 
    315318        if (error) 
     
    328331        return nil; 
    329332    } 
    330          
     333         
    331334    // We found some valid JSON. But did it also contain something else? 
    332335    if (![self scanIsAtEnd]) { 
     
    335338        return nil; 
    336339    } 
    337  
     340         
    338341    // If we don't allow scalars, check that the object we've found is a valid JSON container. 
    339342    if (!allowScalar && ![o isKindOfClass:[NSDictionary class]] && ![o isKindOfClass:[NSArray class]]) { 
     
    342345        return nil; 
    343346    } 
    344  
     347         
    345348    NSAssert1(o, @"Should have a valid object from %@", repr); 
    346349    return o; 
     
    401404            break; 
    402405        case '+': 
    403             *error = err(EPARSENUM, @"Leading + disallowed in number"); 
     406                        if (error) 
     407                                *error = err(EPARSENUM, @"Leading + disallowed in number"); 
    404408            return NO; 
    405409            break; 
    406410        case 0x0: 
    407             *error = err(EEOF, @"Unexpected end of string"); 
     411                        if (error) 
     412                                *error = err(EEOF, @"Unexpected end of string"); 
    408413            return NO; 
    409414            break; 
    410415        default: 
    411             *error = err(EPARSE, @"Unrecognised leading character"); 
     416                        if (error) 
     417                                *error = err(EPARSE, @"Unrecognised leading character"); 
    412418            return NO; 
    413419            break; 
     
    425431        return YES; 
    426432    } 
    427     *error = err(EPARSE, @"Expected 'true'"); 
     433        if (error) 
     434                *error = err(EPARSE, @"Expected 'true'"); 
    428435    return NO; 
    429436} 
     
    436443        return YES; 
    437444    } 
    438     *error = err(EPARSE, @"Expected 'false'"); 
     445        if (error) 
     446                *error = err(EPARSE, @"Expected 'false'"); 
    439447    return NO; 
    440448} 
     
    447455        return YES; 
    448456    } 
    449     *error = err(EPARSE, @"Expected 'null'"); 
     457        if (error) 
     458                *error = err(EPARSE, @"Expected 'null'"); 
    450459    return NO; 
    451460} 
     
    454463{ 
    455464    if (maxDepth && ++depth > maxDepth) { 
    456         *error = err(EDEPTH, @"Nested too deep"); 
     465                if (error) 
     466                        *error = err(EDEPTH, @"Nested too deep"); 
    457467        return NO; 
    458468    } 
     
    470480         
    471481        if (![self scanValue:&v error:error]) { 
    472             *error = errWithUnderlier(EPARSE, error, @"Expected value while parsing array"); 
     482                        if (error) 
     483                                *error = errWithUnderlier(EPARSE, error, @"Expected value while parsing array"); 
    473484            return NO; 
    474485        } 
     
    480491            skipWhitespace(c); 
    481492            if (*c == ']') { 
    482                 *error = err(ETRAILCOMMA, @"Trailing comma disallowed in array"); 
     493                                if (error) 
     494                                        *error = err(ETRAILCOMMA, @"Trailing comma disallowed in array"); 
    483495                return NO; 
    484496            } 
     
    486498    } 
    487499     
    488     *error = err(EEOF, @"End of input while parsing array"); 
     500        if (error) 
     501                *error = err(EEOF, @"End of input while parsing array"); 
    489502    return NO; 
    490503} 
     
    493506{ 
    494507    if (maxDepth && ++depth > maxDepth) { 
    495         *error = err(EDEPTH, @"Nested too deep"); 
     508                if (error) 
     509                        *error = err(EDEPTH, @"Nested too deep"); 
    496510        return NO; 
    497511    } 
     
    509523         
    510524        if (!(*c == '\"' && c++ && [self scanRestOfString:&k error:error])) { 
    511             *error = errWithUnderlier(EPARSE, error, @"Object key string expected"); 
     525                        if (error) 
     526                                *error = errWithUnderlier(EPARSE, error, @"Object key string expected"); 
    512527            return NO; 
    513528        } 
     
    515530        skipWhitespace(c); 
    516531        if (*c != ':') { 
    517             *error = err(EPARSE, @"Expected ':' separating key and value"); 
     532                        if (error) 
     533                                *error = err(EPARSE, @"Expected ':' separating key and value"); 
    518534            return NO; 
    519535        } 
     
    522538        if (![self scanValue:&v error:error]) { 
    523539            NSString *string = [NSString stringWithFormat:@"Object value expected for key: %@", k]; 
    524             *error = errWithUnderlier(EPARSE, error, string); 
     540                        if (error) 
     541                                *error = errWithUnderlier(EPARSE, error, string); 
    525542            return NO; 
    526543        } 
     
    532549            skipWhitespace(c); 
    533550            if (*c == '}') { 
    534                 *error = err(ETRAILCOMMA, @"Trailing comma disallowed in object"); 
     551                                if (error) 
     552                                        *error = err(ETRAILCOMMA, @"Trailing comma disallowed in object"); 
    535553                return NO; 
    536554            } 
     
    538556    } 
    539557     
    540     *error = err(EEOF, @"End of input while parsing object"); 
     558        if (error) 
     559                *error = err(EEOF, @"End of input while parsing object"); 
    541560    return NO; 
    542561} 
     
    583602                    c++; 
    584603                    if (![self scanUnicodeChar:&uc error:error]) { 
    585                         *error = errWithUnderlier(EUNICODE, error, @"Broken unicode character"); 
     604                                                if (error) 
     605                                                        *error = errWithUnderlier(EUNICODE, error, @"Broken unicode character"); 
    586606                        return NO; 
    587607                    } 
     
    589609                    break; 
    590610                default: 
    591                     *error = err(EESCAPE, [NSString stringWithFormat:@"Illegal escape sequence '0x%x'", uc]); 
     611                                        if (error) 
     612                                                *error = err(EESCAPE, [NSString stringWithFormat:@"Illegal escape sequence '0x%x'", uc]); 
    592613                    return NO; 
    593614                    break; 
     
    597618             
    598619        } else if (*c < 0x20) { 
    599             *error = err(ECTRL, [NSString stringWithFormat:@"Unescaped control character '0x%x'", *c]); 
     620                        if (error) 
     621                                *error = err(ECTRL, [NSString stringWithFormat:@"Unescaped control character '0x%x'", *c]); 
    600622            return NO; 
    601623             
     
    605627    } while (*c); 
    606628     
    607     *error = err(EEOF, @"Unexpected EOF while parsing string"); 
     629        if (error) 
     630                *error = err(EEOF, @"Unexpected EOF while parsing string"); 
    608631    return NO; 
    609632} 
     
    614637     
    615638    if (![self scanHexQuad:&hi error:error]) { 
    616         *error = err(EUNICODE, @"Missing hex quad"); 
     639                if (error) 
     640                        *error = err(EUNICODE, @"Missing hex quad"); 
    617641        return NO;         
    618642    } 
     
    622646             
    623647            if (!(*c == '\\' && ++c && *c == 'u' && ++c && [self scanHexQuad:&lo error:error])) { 
    624                 *error = errWithUnderlier(EUNICODE, error, @"Missing low character in surrogate pair"); 
     648                                if (error) 
     649                                        *error = errWithUnderlier(EUNICODE, error, @"Missing low character in surrogate pair"); 
    625650                return NO; 
    626651            } 
    627652             
    628653            if (lo < 0xdc00 || lo >= 0xdfff) { 
    629                 *error = err(EUNICODE, @"Invalid low surrogate char"); 
     654                                if (error) 
     655                                        *error = err(EUNICODE, @"Invalid low surrogate char"); 
    630656                return NO; 
    631657            } 
     
    634660             
    635661        } else if (hi < 0xe000) { 
    636             *error = err(EUNICODE, @"Invalid high character in surrogate pair"); 
     662                        if (error) 
     663                                *error = err(EUNICODE, @"Invalid high character in surrogate pair"); 
    637664            return NO; 
    638665        } 
     
    654681        ? (uc - 'A' + 10) : -1; 
    655682        if (d == -1) { 
    656             *error = err(EUNICODE, @"Missing hex digit in quad"); 
     683                        if (error) 
     684                                *error = err(EUNICODE, @"Missing hex digit in quad"); 
    657685            return NO; 
    658686        } 
     
    676704    if ('0' == *c && c++) {         
    677705        if (isdigit(*c)) { 
    678             *error = err(EPARSENUM, @"Leading 0 disallowed in number"); 
     706                        if (error) 
     707                                *error = err(EPARSENUM, @"Leading 0 disallowed in number"); 
    679708            return NO; 
    680709        } 
    681710         
    682711    } else if (!isdigit(*c) && c != ns) { 
    683         *error = err(EPARSENUM, @"No digits after initial minus"); 
     712                if (error) 
     713                        *error = err(EPARSENUM, @"No digits after initial minus"); 
    684714        return NO; 
    685715         
     
    692722         
    693723        if (!isdigit(*c)) { 
    694             *error = err(EPARSENUM, @"No digits after decimal point"); 
     724                        if (error) 
     725                                *error = err(EPARSENUM, @"No digits after decimal point"); 
    695726            return NO; 
    696727        }         
     
    706737         
    707738        if (!isdigit(*c)) { 
    708             *error = err(EPARSENUM, @"No digits after exponent"); 
     739                        if (error) 
     740                                *error = err(EPARSENUM, @"No digits after exponent"); 
    709741            return NO; 
    710742        } 
     
    720752        return YES; 
    721753     
    722     *error = err(EPARSENUM, @"Failed creating decimal instance"); 
     754        if (error) 
     755                *error = err(EPARSENUM, @"Failed creating decimal instance"); 
    723756    return NO; 
    724757} 
  • apps/iphone/my.tel/trunk/VIP.tel.xcodeproj/project.pbxproj

    r656 r673  
    10051005                                GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 
    10061006                                GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 
    1007                                 GCC_WARN_ABOUT_MISSING_NEWLINE = YES; 
    10081007                                GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 
    10091008                                GCC_WARN_ABOUT_RETURN_TYPE = YES; 
     
    10161015                                GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; 
    10171016                                GCC_WARN_SHADOW = YES; 
    1018                                 GCC_WARN_SIGN_COMPARE = YES; 
    10191017                                GCC_WARN_UNDECLARED_SELECTOR = YES; 
    10201018                                GCC_WARN_UNINITIALIZED_AUTOS = YES; 
  • apps/iphone/superbook/trunk/DotTel_SDK/Classes/Reachability.h

    r357 r673  
    9696- (NetworkStatus)localWiFiConnectionStatus; 
    9797 
    98 /* 
    99  When reachability change notifications are posted, the callback method 'ReachabilityCallback' is called 
    100  and posts a notification that the client application can observe to learn about changes. 
    101  */ 
    102 static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info); 
    10398 
    10499@end 
  • apps/iphone/superbook/trunk/DotTel_SDK/Classes/Reachability.m

    r357 r673  
    7070- (BOOL)addressFromString:(NSString *)IPAddress address:(struct sockaddr_in *)outAddress; 
    7171- (void)stopListeningForReachabilityChanges; 
     72/* 
     73 When reachability change notifications are posted, the callback method 'ReachabilityCallback' is called 
     74 and posts a notification that the client application can observe to learn about changes. 
     75 */ 
     76static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info); 
    7277@end 
    7378 
     
    154159         
    155160        // Build a sockaddr_in that we can pass to the address reachability query. 
    156         struct sockaddr_in sin; 
    157          
    158         bzero(&sin, sizeof(sin)); 
    159         sin.sin_len = sizeof(sin); 
    160         sin.sin_family = AF_INET; 
     161        struct sockaddr_in soin; 
     162         
     163        bzero(&soin, sizeof(soin)); 
     164        soin.sin_len = sizeof(soin); 
     165        soin.sin_family = AF_INET; 
    161166        // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0 
    162         sin.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM); 
    163          
    164         adHocWiFiNetworkReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&sin); 
     167        soin.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM); 
     168         
     169        adHocWiFiNetworkReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&soin); 
    165170                 
    166171                query = [[[ReachabilityQuery alloc] init] autorelease]; 
     
    225230        defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&zeroAddress); 
    226231                 
    227                 ReachabilityQuery *query = [[[ReachabilityQuery alloc] init] autorelease]; 
    228                 query.hostNameOrAddress = kDefaultRouteKey; 
    229                 query.reachabilityRef = defaultRouteReachability; 
    230                  
    231                 [self.reachabilityQueries setObject:query forKey:kDefaultRouteKey]; 
     232                ReachabilityQuery *query2 = [[[ReachabilityQuery alloc] init] autorelease]; 
     233                query2.hostNameOrAddress = kDefaultRouteKey; 
     234                query2.reachabilityRef = defaultRouteReachability; 
     235                 
     236                [self.reachabilityQueries setObject:query2 forKey:kDefaultRouteKey]; 
    232237    } 
    233238         
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us