Comment: | More nullability fixes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
697e3ecbf73d70ff64f3e6127a11fa5d |
User & Date: | js on 2017-09-27 22:35:11 |
Other Links: | manifest | tags |
2017-09-28
| ||
23:02 | Enable -Wnullable-to-nonnull-conversion and adjust check-in: 2de9660312 user: js tags: trunk | |
2017-09-27
| ||
22:35 | More nullability fixes check-in: 697e3ecbf7 user: js tags: trunk | |
2017-09-26
| ||
22:40 | Work around Clang analyzer false positives check-in: c9efebeff9 user: js tags: trunk | |
Modified src/OFArray.h from [7dd9c17fc0] to [55496ae50e].
︙ | ︙ | |||
216 217 218 219 220 221 222 | * each object. * * @note A @ref OFNull value is translated to nil! * * @param value The value for the specified key * @param key The key of the value to set */ | | | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | * each object. * * @note A @ref OFNull value is translated to nil! * * @param value The value for the specified key * @param key The key of the value to set */ - (void)setValue: (id)value forKey: (OFString *)key; /*! * @brief Copies the objects at the specified range to the specified buffer. * * @param buffer The buffer to copy the objects to * @param range The range to copy |
︙ | ︙ |
Modified src/OFArray.m from [190702fc68] to [3fb8497b42].
︙ | ︙ | |||
315 316 317 318 319 320 321 | [super setValue: value forKey: key]; objc_autoreleasePoolPop(pool); return; } | < < < | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | [super setValue: value forKey: key]; objc_autoreleasePoolPop(pool); return; } for (id object in self) [object setValue: value forKey: key]; } - (size_t)indexOfObject: (id)object { |
︙ | ︙ | |||
448 449 450 451 452 453 454 | OFMutableString *ret; if (separator == nil) @throw [OFInvalidArgumentException exception]; if ([self count] == 0) return @""; | > | > | > > > > > > > > > > > > > > | | 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | OFMutableString *ret; if (separator == nil) @throw [OFInvalidArgumentException exception]; if ([self count] == 0) return @""; if ([self count] == 1) { OFString *component = [[self firstObject] performSelector: selector]; if (component == nil) @throw [OFInvalidArgumentException exception]; return component; } ret = [OFMutableString string]; if (options & OF_ARRAY_SKIP_EMPTY) { for (id object in self) { void *pool = objc_autoreleasePoolPush(); OFString *component = [object performSelector: selector]; if (component == nil) @throw [OFInvalidArgumentException exception]; if ([component length] > 0) { if ([ret length] > 0) [ret appendString: separator]; [ret appendString: component]; } objc_autoreleasePoolPop(pool); } } else { bool first = true; for (id object in self) { void *pool = objc_autoreleasePoolPush(); OFString *component = [object performSelector: selector]; if (component == nil) @throw [OFInvalidArgumentException exception]; if OF_UNLIKELY (first) first = false; else [ret appendString: separator]; [ret appendString: component]; objc_autoreleasePoolPop(pool); } } [ret makeImmutable]; |
︙ | ︙ |
Modified src/OFData.h from [1f9618a527] to [9086a3be08].
︙ | ︙ | |||
30 31 32 33 34 35 36 | * * For security reasons, serialization and deserialization is only implemented * for OFData with item size 1. */ @interface OFData: OFObject <OFCopying, OFMutableCopying, OFComparing, OFSerialization, OFMessagePackRepresentation> { | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | * * For security reasons, serialization and deserialization is only implemented * for OFData with item size 1. */ @interface OFData: OFObject <OFCopying, OFMutableCopying, OFComparing, OFSerialization, OFMessagePackRepresentation> { unsigned char *_items; size_t _count, _itemSize; bool _freeWhenDone; } /*! * The size of a single item in the OFData in bytes. */ |
︙ | ︙ |
Modified src/OFDate.h from [fcd33a4a3b] to [29c60ccceb].
︙ | ︙ | |||
303 304 305 306 307 308 309 | * @brief Returns the earlier of the two dates. * * If the argument is `nil`, it returns the receiver. * * @param otherDate Another date * @return The earlier date of the two dates */ | | | | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | * @brief Returns the earlier of the two dates. * * If the argument is `nil`, it returns the receiver. * * @param otherDate Another date * @return The earlier date of the two dates */ - (OFDate *)earlierDate: (nullable OFDate *)otherDate; /*! * @brief Returns the later of the two dates. * * If the argument is `nil`, it returns the receiver. * * @param otherDate Another date * @return The later date of the two dates */ - (OFDate *)laterDate: (nullable OFDate *)otherDate; /*! * @brief Returns the seconds since 1970-01-01T00:00:00Z. * * @return The seconds since 1970-01-01T00:00:00Z */ - (of_time_interval_t)timeIntervalSince1970; |
︙ | ︙ |
Modified src/OFDictionary.h from [cf57ae790d] to [4699be28c7].
︙ | ︙ | |||
217 218 219 220 221 222 223 | * If the key does not start with an `@`, this is equivalent to * @ref setObject:forKey:. In this case, if the dictionary is immutable, an * @ref OFUndefinedKeyException is thrown. * * @param key The key to set * @param value The value to set the key to */ | | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | * If the key does not start with an `@`, this is equivalent to * @ref setObject:forKey:. In this case, if the dictionary is immutable, an * @ref OFUndefinedKeyException is thrown. * * @param key The key to set * @param value The value to set the key to */ - (void)setValue: (id)value forKey: (OFString *)key; /*! * @brief Checks whether the dictionary contains an object equal to the * specified object. * * @param object The object which is checked for being in the dictionary |
︙ | ︙ |
Modified src/OFKeyValueCoding.h from [f12732c01d] to [b40de73f7d].
︙ | ︙ | |||
50 51 52 53 54 55 56 | /*! * @brief Set the value for the specified key * * @param value The value for the specified key * @param key The key of the value to set */ | | | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | /*! * @brief Set the value for the specified key * * @param value The value for the specified key * @param key The key of the value to set */ - (void)setValue: (id)value forKey: (OFString *)key; /*! * @brief This is called by @ref setValue:forKey: if the specified key does not * exist. * * By default, this throws an @ref OFUndefinedKeyException. |
︙ | ︙ |
Modified src/OFMapTable.h from [840bb3bdb2] to [59f43aca32].
︙ | ︙ | |||
24 25 26 27 28 29 30 | /*! * @struct of_map_table_functions_t OFMapTable.h ObjFW/OFMapTable.h * * @brief A struct describing the functions to be used by the map table. */ typedef struct { /*! The function to retain keys / objects */ | | | | | > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /*! * @struct of_map_table_functions_t OFMapTable.h ObjFW/OFMapTable.h * * @brief A struct describing the functions to be used by the map table. */ typedef struct { /*! The function to retain keys / objects */ void *_Nullable (*_Nullable retain)(void *_Nullable object); /*! The function to release keys / objects */ void (*_Nullable release)(void *_Nullable object); /*! The function to hash keys */ uint32_t (*_Nullable hash)(void *_Nullable object); /*! The function to compare keys / objects */ bool (*_Nullable equal)(void *_Nullable object1, void *_Nullable object2); } of_map_table_functions_t; #ifdef OF_HAVE_BLOCKS /*! * @brief A block for enumerating an OFMapTable. * * @param key The current key |
︙ | ︙ |
Modified src/OFObject.h from [8cde88e60d] to [09a592a800].
︙ | ︙ | |||
673 674 675 676 677 678 679 | * * It will be freed automatically when the object is deallocated. * * @param size The size of the memory to allocate * @return A pointer to the allocated memory. May return NULL if the specified * size is 0. */ | | | | | 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | * * It will be freed automatically when the object is deallocated. * * @param size The size of the memory to allocate * @return A pointer to the allocated memory. May return NULL if the specified * size is 0. */ - (void *)allocMemoryWithSize: (size_t)size; /*! * @brief Allocates memory for the specified number of items and stores it in * the object's memory pool. * * It will be freed automatically when the object is deallocated. * * @param size The size of each item to allocate * @param count The number of items to allocate * @return A pointer to the allocated memory. May return NULL if the specified * size or count is 0. */ - (void *)allocMemoryWithSize: (size_t)size count: (size_t)count; /*! * @brief Resizes memory in the object's memory pool to the specified size. * * If the pointer is NULL, this is equivalent to allocating memory. * If the size is 0, this is equivalent to freeing memory. * |
︙ | ︙ |
Modified src/OFObject.m from [34872d52d4] to [d351e409b9].
︙ | ︙ | |||
1015 1016 1017 1018 1019 1020 1021 | - (void *)allocMemoryWithSize: (size_t)size { void *pointer; struct pre_mem *preMem; if OF_UNLIKELY (size == 0) | | | 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 | - (void *)allocMemoryWithSize: (size_t)size { void *pointer; struct pre_mem *preMem; if OF_UNLIKELY (size == 0) return (void *_Nonnull)NULL; if OF_UNLIKELY (size > SIZE_MAX - PRE_IVARS_ALIGN) @throw [OFOutOfRangeException exception]; if OF_UNLIKELY ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: size]; |
︙ | ︙ |
Modified src/OFSet.h from [b570ea6601] to [c9d70b7eb7].
︙ | ︙ | |||
241 242 243 244 245 246 247 | * each object. * * @note A @ref OFNull value is translated to nil! * * @param value The value for the specified key * @param key The key of the value to set */ | | | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | * each object. * * @note A @ref OFNull value is translated to nil! * * @param value The value for the specified key * @param key The key of the value to set */ - (void)setValue: (id)value forKey: (OFString *)key; /*! * @brief Returns an OFEnumerator to enumerate through all objects of the set. * * @returns An OFEnumerator to enumerate through all objects of the set */ |
︙ | ︙ |
Modified src/OFSet.m from [62db370766] to [876ac85821].
︙ | ︙ | |||
251 252 253 254 255 256 257 | [super setValue: value forKey: key]; objc_autoreleasePoolPop(pool); return; } | < < < | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | [super setValue: value forKey: key]; objc_autoreleasePoolPop(pool); return; } for (id object in self) [object setValue: value forKey: key]; } - (bool)containsObject: (id)object { |
︙ | ︙ |
Modified src/exceptions/OFMemoryNotPartOfObjectException.h from [aaf3eabd13] to [ebaae357da].
︙ | ︙ | |||
23 24 25 26 27 28 29 | * OFMemoryNotPartOfObjectException.h \ * ObjFW/OFMemoryNotPartOfObjectException.h * * @brief An exception indicating the given memory is not part of the object. */ @interface OFMemoryNotPartOfObjectException: OFException { | | | | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | * OFMemoryNotPartOfObjectException.h \ * ObjFW/OFMemoryNotPartOfObjectException.h * * @brief An exception indicating the given memory is not part of the object. */ @interface OFMemoryNotPartOfObjectException: OFException { void *_Nullable _pointer; id _object; } /*! * A pointer to the memory which is not part of the object. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *pointer; /*! * The object which the memory is not part of. */ @property (readonly, nonatomic) id object; + (instancetype)exception OF_UNAVAILABLE; /*! * @brief Creates a new, autoreleased memory not part of object exception. * * @param pointer A pointer to the memory that is not part of the object * @param object The object which the memory is not part of * @return A new, autoreleased memory not part of object exception */ + (instancetype)exceptionWithPointer: (nullable void *)pointer object: (id)object; - init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated memory not part of object exception. * * @param pointer A pointer to the memory that is not part of the object * @param object The object which the memory is not part of * @return An initialized memory not part of object exception */ - initWithPointer: (nullable void *)pointer object: (id)object OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Modified tests/OFObjectTests.m from [bb532d1546] to [ba866e7637].
︙ | ︙ | |||
251 252 253 254 255 256 257 | [m unsignedIntValue] == 80 && [m unsignedLongValue] == 90 && [m unsignedLongLongValue] == 100 && [m floatValue] == 110 && [m doubleValue] == 120) EXPECT_EXCEPTION(@"Catch -[setValue:forKey:] with nil key for scalar", | | | 251 252 253 254 255 256 257 258 259 260 261 262 263 | [m unsignedIntValue] == 80 && [m unsignedLongValue] == 90 && [m unsignedLongLongValue] == 100 && [m floatValue] == 110 && [m doubleValue] == 120) EXPECT_EXCEPTION(@"Catch -[setValue:forKey:] with nil key for scalar", OFInvalidArgumentException, [m setValue: (id _Nonnull)nil forKey: @"intValue"]) [pool drain]; } @end |