ObjFW  Check-in [c9efebeff9]

Overview
Comment:Work around Clang analyzer false positives
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c9efebeff9cd5091a3c27d09221ce1468ebeda35be1c4f8b707188483cade7c2
User & Date: js on 2017-09-26 22:40:49
Other Links: manifest | tags
Context
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
22:04
ObjFW.xcodeproj: Fix forgotten file rename check-in: 2914211ef9 user: js tags: trunk
Changes

Modified src/OFMutableArray_adjacent.m from [e5a95ab2b1] to [72511012c6].

207
208
209
210
211
212
213

214
215
216
217
218

219
220
221
222
223
224
225
			return;
		}
	}
}

- (void)removeObjectAtIndex: (size_t)index
{

	id object = [self objectAtIndex: index];
	[_array removeItemAtIndex: index];
	[object release];

	_mutations++;

}

- (void)removeAllObjects
{
	id *objects = [_array items];
	size_t count = [_array count];








>





>







207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
			return;
		}
	}
}

- (void)removeObjectAtIndex: (size_t)index
{
#ifndef __clang_analyzer__
	id object = [self objectAtIndex: index];
	[_array removeItemAtIndex: index];
	[object release];

	_mutations++;
#endif
}

- (void)removeAllObjects
{
	id *objects = [_array items];
	size_t count = [_array count];

251
252
253
254
255
256
257

258
259
260
261
262
263
264
265
266
267
268

269
270
271
272
273
274
275
	} @finally {
		[self freeMemory: copy];
	}
}

- (void)removeLastObject
{

	size_t count = [_array count];
	id object;

	if (count == 0)
		return;

	object = [self objectAtIndex: count - 1];
	[_array removeLastItem];
	[object release];

	_mutations++;

}

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
{
	id *objects = [_array items];
	size_t count = [_array count];







>











>







253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
	} @finally {
		[self freeMemory: copy];
	}
}

- (void)removeLastObject
{
#ifndef __clang_analyzer__
	size_t count = [_array count];
	id object;

	if (count == 0)
		return;

	object = [self objectAtIndex: count - 1];
	[_array removeLastItem];
	[object release];

	_mutations++;
#endif
}

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
{
	id *objects = [_array items];
	size_t count = [_array count];

Modified src/OFObject.h from [ad4d018447] to [8cde88e60d].

417
418
419
420
421
422
423

424



425
426
427
428
429
430
431
 *
 * @brief The root class for all other classes inside ObjFW.
 */
OF_ROOT_CLASS
@interface OFObject <OFObject>
{
@private

	Class _isa;



}

/*!
 * @brief A method which is called once when the class is loaded into the
 *	  runtime.
 *
 * Derived classes can override this to execute their own code when the class







>

>
>
>







417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
 *
 * @brief The root class for all other classes inside ObjFW.
 */
OF_ROOT_CLASS
@interface OFObject <OFObject>
{
@private
#ifndef __clang_analyzer__
	Class _isa;
#else
	Class _isa __attribute__((__unused__));
#endif
}

/*!
 * @brief A method which is called once when the class is loaded into the
 *	  runtime.
 *
 * Derived classes can override this to execute their own code when the class

Modified src/OFString+JSONValue.m from [9ab88e7a0f] to [e54b1de1c0].

648
649
650
651
652
653
654




655
656
657
658
659
660
661
- (id)JSONValueWithDepthLimit: (size_t)depthLimit
{
	void *pool = objc_autoreleasePoolPush();
	const char *pointer = [self UTF8String];
	const char *stop = pointer + [self UTF8StringLength];
	id object;
	size_t line = 1;





	object = nextObject(&pointer, stop, &line, depthLimit);
	skipWhitespacesAndComments(&pointer, stop, &line);

	if (pointer < stop || object == nil)
		@throw [OFInvalidJSONException exceptionWithString: self
							      line: line];







>
>
>
>







648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
- (id)JSONValueWithDepthLimit: (size_t)depthLimit
{
	void *pool = objc_autoreleasePoolPush();
	const char *pointer = [self UTF8String];
	const char *stop = pointer + [self UTF8StringLength];
	id object;
	size_t line = 1;

#ifdef __clang_analyzer__
	assert(pointer != NULL);
#endif

	object = nextObject(&pointer, stop, &line, depthLimit);
	skipWhitespacesAndComments(&pointer, stop, &line);

	if (pointer < stop || object == nil)
		@throw [OFInvalidJSONException exceptionWithString: self
							      line: line];

Modified src/OFThread.m from [3ff1e2b592] to [c1e478224c].

369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
- copy
{
	return [self retain];
}

- (OFRunLoop *)runLoop
{
# ifdef OF_HAVE_ATOMIC_OPS
	if (_runLoop == nil) {
		OFRunLoop *tmp = [[OFRunLoop alloc] init];

		if (!of_atomic_ptr_cmpswap((void **)&_runLoop, nil, tmp))
			[tmp release];
	}
# else







|







369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
- copy
{
	return [self retain];
}

- (OFRunLoop *)runLoop
{
# if defined(OF_HAVE_ATOMIC_OPS) && !defined(__clang_analyzer__)
	if (_runLoop == nil) {
		OFRunLoop *tmp = [[OFRunLoop alloc] init];

		if (!of_atomic_ptr_cmpswap((void **)&_runLoop, nil, tmp))
			[tmp release];
	}
# else

Modified tests/OFBlockTests.m from [57afcae22d] to [21cb831e97].

93
94
95
96
97
98
99

100
101

102
103
104
105
106

107

108
109
110
111
	    forwardTest() == 5)

	TEST(@"Copying a stack block and using its copied variable",
	    (v = returnStackBlock()) && v() == 43 && v() == 44 && v() == 45)

	TEST(@"Copying a global block", (id)g == [[g copy] autorelease])


	TEST(@"Copying a malloc block",
	    (id)m == [m copy] && [m retainCount] == 2)


	TEST(@"Autorelease a stack block", R([s autorelease]))

	TEST(@"Autorelease a global block", R([g autorelease]))


	TEST(@"Autorelease a malloc block", R([m autorelease]))


	[pool drain];
}
@end







>


>





>

>




93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
	    forwardTest() == 5)

	TEST(@"Copying a stack block and using its copied variable",
	    (v = returnStackBlock()) && v() == 43 && v() == 44 && v() == 45)

	TEST(@"Copying a global block", (id)g == [[g copy] autorelease])

#ifndef __clang_analyzer__
	TEST(@"Copying a malloc block",
	    (id)m == [m copy] && [m retainCount] == 2)
#endif

	TEST(@"Autorelease a stack block", R([s autorelease]))

	TEST(@"Autorelease a global block", R([g autorelease]))

#ifndef __clang_analyzer__
	TEST(@"Autorelease a malloc block", R([m autorelease]))
#endif

	[pool drain];
}
@end

Modified tests/OFInvocationTests.m from [da1c4d414a] to [1bbbdf67b6].

12
13
14
15
16
17
18

19
20
21
22
23
24
25
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"


#include <string.h>

#ifndef __STDC_NO_COMPLEX__
# include <complex.h>
#endif

#import "OFInvocation.h"







>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <assert.h>
#include <string.h>

#ifndef __STDC_NO_COMPLEX__
# include <complex.h>
#endif

#import "OFInvocation.h"
264
265
266
267
268
269
270




271
272
273
274
275
276
277

	memset(&st, '\xFF', sizeof(st));
	st.c = 0x55;
	st.i = 0xAAAAAAAA;

	TEST(@"+[invocationWithMethodSignature:]",
	    (invocation = [OFInvocation invocationWithMethodSignature: sig]))





	TEST(@"-[setReturnValue]", R([invocation setReturnValue: &st]))

	TEST(@"-[getReturnValue]", R([invocation getReturnValue: &st2]) &&
	    memcmp(&st, &st2, sizeof(st)) == 0)

	memset(&st2, '\0', sizeof(st2));







>
>
>
>







265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282

	memset(&st, '\xFF', sizeof(st));
	st.c = 0x55;
	st.i = 0xAAAAAAAA;

	TEST(@"+[invocationWithMethodSignature:]",
	    (invocation = [OFInvocation invocationWithMethodSignature: sig]))

#ifdef __clang_analyzer__
	assert(invocation != nil);
#endif

	TEST(@"-[setReturnValue]", R([invocation setReturnValue: &st]))

	TEST(@"-[getReturnValue]", R([invocation getReturnValue: &st2]) &&
	    memcmp(&st, &st2, sizeof(st)) == 0)

	memset(&st2, '\0', sizeof(st2));