ObjFW  Check-in [6d4dfb5bc7]

Overview
Comment:Add -Wshorten-64-to-32.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6d4dfb5bc7db6d3e6827981088ee5d7407c019790b3f5b5cb489715f067ac21e
User & Date: js on 2011-03-22 00:55:09
Other Links: manifest | tags
Context
2011-03-22
01:03
Clang is a bit more pedantic with -Wshorten-64-to-32. check-in: b2c9efebcf user: js tags: trunk
00:55
Add -Wshorten-64-to-32. check-in: 6d4dfb5bc7 user: js tags: trunk
2011-03-21
23:19
Add a real Xcode project which is not only using make. check-in: accfa586da user: js tags: trunk
Changes

Modified ObjFW.xcodeproj/project.pbxproj from [1134b7d4e3] to [688ffd4e1c].

913
914
915
916
917
918
919
920
921
922
923
924
925
926
927






928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949






950
951
952
953
954
955
956
957
958
959
960
/* Begin XCBuildConfiguration section */
		1DEB919408733D9F0010E9CD /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				GCC_OPTIMIZATION_LEVEL = 2;
				GCC_VERSION = 4.2;
				OTHER_CFLAGS = (
					"-Wall",
					"-fexceptions",
					"-fobjc-exceptions",
					"-fconstant-string-class=OFConstantString",
					"-pipe",
					"-fno-common",
					"-fno-constant-cfstrings",
					"-fblocks",






					"-Wwrite-strings",
					"-Wcast-align",
					"-Wpointer-arith",
					"-Werror",
				);
			};
			name = Debug;
		};
		1DEB919508733D9F0010E9CD /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				GCC_OPTIMIZATION_LEVEL = 2;
				GCC_VERSION = 4.2;
				OTHER_CFLAGS = (
					"-Wall",
					"-fexceptions",
					"-fobjc-exceptions",
					"-fconstant-string-class=OFConstantString",
					"-pipe",
					"-fno-common",
					"-fno-constant-cfstrings",
					"-fblocks",






					"-Wwrite-strings",
					"-Wcast-align",
					"-Wpointer-arith",
					"-Werror",
				);
			};
			name = Release;
		};
		4B23CA8C133811610047A1D9 /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {







<



<
|
|

>
>
>
>
>
>



<










<



<
|
|

>
>
>
>
>
>



<







913
914
915
916
917
918
919

920
921
922

923
924
925
926
927
928
929
930
931
932
933
934

935
936
937
938
939
940
941
942
943
944

945
946
947

948
949
950
951
952
953
954
955
956
957
958
959

960
961
962
963
964
965
966
/* Begin XCBuildConfiguration section */
		1DEB919408733D9F0010E9CD /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				GCC_OPTIMIZATION_LEVEL = 2;
				GCC_VERSION = 4.2;
				OTHER_CFLAGS = (

					"-fexceptions",
					"-fobjc-exceptions",
					"-fconstant-string-class=OFConstantString",

					"-fno-constant-cfstrings",
					"-fno-common",
					"-fblocks",
					"-pipe",
				);
				WARNING_CFLAGS = (
					"-Wall",
					"-Werror",
					"-Wshorten-64-to-32",
					"-Wwrite-strings",
					"-Wcast-align",
					"-Wpointer-arith",

				);
			};
			name = Debug;
		};
		1DEB919508733D9F0010E9CD /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				GCC_OPTIMIZATION_LEVEL = 2;
				GCC_VERSION = 4.2;
				OTHER_CFLAGS = (

					"-fexceptions",
					"-fobjc-exceptions",
					"-fconstant-string-class=OFConstantString",

					"-fno-constant-cfstrings",
					"-fno-common",
					"-fblocks",
					"-pipe",
				);
				WARNING_CFLAGS = (
					"-Wall",
					"-Werror",
					"-Wshorten-64-to-32",
					"-Wwrite-strings",
					"-Wcast-align",
					"-Wpointer-arith",

				);
			};
			name = Release;
		};
		4B23CA8C133811610047A1D9 /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {

Modified configure.ac from [0003f7755e] to [cf9accb9d4].

473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
AS_IF([test x"$objc_runtime" = x"Apple"], [
	AC_CHECK_HEADER(Foundation/NSObject.h, [
		AC_SUBST(FOUNDATION_COMPAT_M, "foundation-compat.m")
	])
])

AS_IF([test x"$GOBJC" = x"yes"], [
	OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wcast-align -Wpointer-arith"
	OBJCFLAGS="$OBJCFLAGS -Werror"

	AC_MSG_CHECKING(whether gcc has bug objc/27438)
	AC_TRY_COMPILE([
		@interface OFConstantString
		{
			struct objc_class *isa;
			const char *string;







|
|







473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
AS_IF([test x"$objc_runtime" = x"Apple"], [
	AC_CHECK_HEADER(Foundation/NSObject.h, [
		AC_SUBST(FOUNDATION_COMPAT_M, "foundation-compat.m")
	])
])

AS_IF([test x"$GOBJC" = x"yes"], [
	OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wshorten-64-to-32 -Wcast-align"
       	OBJCFLAGS="$OBJCFLAGS -Wpointer-arith -Werror"

	AC_MSG_CHECKING(whether gcc has bug objc/27438)
	AC_TRY_COMPILE([
		@interface OFConstantString
		{
			struct objc_class *isa;
			const char *string;

Modified src/OFArray.m from [bcf0037752] to [526194f8ce].

420
421
422
423
424
425
426



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	size_t count = [array count];




	if (state->state >= count)
		return 0;

	state->state = count;
	state->itemsPtr = [array cArray];
	state->mutationsPtr = (unsigned long*)self;

	return count;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFArrayEnumerator alloc]
	    initWithDataArray: array
	     mutationsPointer: NULL] autorelease];







>
>
>







|







420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	size_t count = [array count];

	if (count > INT_MAX)
		@throw [OFOutOfRangeException newWithClass: isa];

	if (state->state >= count)
		return 0;

	state->state = count;
	state->itemsPtr = [array cArray];
	state->mutationsPtr = (unsigned long*)self;

	return (int)count;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFArrayEnumerator alloc]
	    initWithDataArray: array
	     mutationsPointer: NULL] autorelease];

Modified src/OFDictionary.m from [5163795b89] to [36f0db5679].

180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
- initWithObjects: (OFArray*)objs
	  forKeys: (OFArray*)keys
{
	self = [super init];

	@try {
		id *objs_carray, *keys_carray;
		size_t i, nsize;
		uint32_t j;

		keys_carray = [keys cArray];
		objs_carray = [objs cArray];
		count = [keys count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException newWithClass: isa];







<
|







180
181
182
183
184
185
186

187
188
189
190
191
192
193
194
- initWithObjects: (OFArray*)objs
	  forKeys: (OFArray*)keys
{
	self = [super init];

	@try {
		id *objs_carray, *keys_carray;

		uint32_t i, j, nsize;

		keys_carray = [keys cArray];
		objs_carray = [objs cArray];
		count = [keys count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException newWithClass: isa];
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
- initWithKey: (id <OFCopying>)key
      argList: (va_list)args
{
	self = [super init];

	@try {
		id obj;
		size_t i, nsize;
		uint32_t j, hash;
		va_list args2;
		BUCKET *b;

		va_copy(args2, args);

		if (key == nil)
			@throw [OFInvalidArgumentException newWithClass: isa







<
|







310
311
312
313
314
315
316

317
318
319
320
321
322
323
324
- initWithKey: (id <OFCopying>)key
      argList: (va_list)args
{
	self = [super init];

	@try {
		id obj;

		uint32_t i, j, hash, nsize;
		va_list args2;
		BUCKET *b;

		va_copy(args2, args);

		if (key == nil)
			@throw [OFInvalidArgumentException newWithClass: isa

Modified src/OFHTTPRequest.m from [1e129050da] to [e7e3c34220].

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
		 */
		line = [sock readLine];
		if (![line hasPrefix: @"HTTP/1.0 "] &&
		    ![line hasPrefix: @"HTTP/1.1 "])
			@throw [OFInvalidServerReplyException
			    newWithClass: isa];

		status = [[line substringFromIndex: 9
					   toIndex: 12] decimalValue];

		if (status != 200 && status != 301 && status != 302 &&
		    status != 303)
			@throw [OFHTTPRequestFailedException
			    newWithClass: isa
			     HTTPRequest: self
			      statusCode: status];







|
|







196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
		 */
		line = [sock readLine];
		if (![line hasPrefix: @"HTTP/1.0 "] &&
		    ![line hasPrefix: @"HTTP/1.1 "])
			@throw [OFInvalidServerReplyException
			    newWithClass: isa];

		status = (int)[[line substringFromIndex: 9
						toIndex: 12] decimalValue];

		if (status != 200 && status != 301 && status != 302 &&
		    status != 303)
			@throw [OFHTTPRequestFailedException
			    newWithClass: isa
			     HTTPRequest: self
			      statusCode: status];

Modified src/OFMD5Hash.m from [239cec3ca7] to [7a4ccf5697].

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
		@throw [OFHashAlreadyCalculatedException newWithClass: isa];

	/* Update bitcount */
	t = bits[0];
	if ((bits[0] = t + ((uint32_t)size << 3)) < t)
		/* Carry from low to high */
		bits[1]++;
	bits[1] += size >> 29;

	/* Bytes already in shsInfo->data */
	t = (t >> 3) & 0x3F;

	/* Handle any leading odd-sized chunks */
	if (t) {
		uint8_t *p = in.u8 + t;







|







156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
		@throw [OFHashAlreadyCalculatedException newWithClass: isa];

	/* Update bitcount */
	t = bits[0];
	if ((bits[0] = t + ((uint32_t)size << 3)) < t)
		/* Carry from low to high */
		bits[1]++;
	bits[1] += (uint32_t)size >> 29;

	/* Bytes already in shsInfo->data */
	t = (t >> 3) & 0x3F;

	/* Handle any leading odd-sized chunks */
	if (t) {
		uint8_t *p = in.u8 + t;

Modified src/OFMutableArray.m from [bb6cf54c6a] to [9898b58347].

203
204
205
206
207
208
209



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	size_t count = [array count];




	if (state->state >= count)
		return 0;

	state->state = count;
	state->itemsPtr = [array cArray];
	state->mutationsPtr = &mutations;

	return count;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFArrayEnumerator alloc]
	    initWithDataArray: array
	     mutationsPointer: &mutations] autorelease];







>
>
>







|







203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	size_t count = [array count];

	if (count > INT_MAX)
		@throw [OFOutOfRangeException newWithClass: isa];

	if (state->state >= count)
		return 0;

	state->state = count;
	state->itemsPtr = [array cArray];
	state->mutationsPtr = &mutations;

	return (int)count;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFArrayEnumerator alloc]
	    initWithDataArray: array
	     mutationsPointer: &mutations] autorelease];

Modified src/OFMutableDictionary.m from [5577794406] to [b37339a1ba].

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#define BUCKET struct of_dictionary_bucket
#define DELETED &of_dictionary_deleted_bucket

@implementation OFMutableDictionary
- (void)_resizeForCount: (size_t)newcount
{
	size_t fill = newcount * 4 / size;
	size_t newsize;
	struct of_dictionary_bucket **newdata;
	uint32_t i;

	if (newcount > UINT32_MAX)
		@throw [OFOutOfRangeException newWithClass: isa];

	if (fill >= 3)
		newsize = size << 1;
	else if (fill <= 1)







<

|







26
27
28
29
30
31
32

33
34
35
36
37
38
39
40
41
#define BUCKET struct of_dictionary_bucket
#define DELETED &of_dictionary_deleted_bucket

@implementation OFMutableDictionary
- (void)_resizeForCount: (size_t)newcount
{
	size_t fill = newcount * 4 / size;

	struct of_dictionary_bucket **newdata;
	uint32_t i, newsize;

	if (newcount > UINT32_MAX)
		@throw [OFOutOfRangeException newWithClass: isa];

	if (fill >= 3)
		newsize = size << 1;
	else if (fill <= 1)

Modified src/OFObject.h from [0bd8b0d360] to [2a5a45e545].

21
22
23
24
25
26
27

28
29
30
31
32
33
34
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif

#include <stddef.h>
#include <stdint.h>


#ifdef OF_OBJFW_RUNTIME
# import <objfw-rt.h>
#else
# import <objc/objc.h>
#endif








>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif

#include <stddef.h>
#include <stdint.h>
#include <limits.h>

#ifdef OF_OBJFW_RUNTIME
# import <objfw-rt.h>
#else
# import <objc/objc.h>
#endif

Modified src/OFObject.m from [83c3cca2e3] to [73e373ae9d].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <assert.h>

#import "OFObject.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"








<







16
17
18
19
20
21
22

23
24
25
26
27
28
29

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <assert.h>

#import "OFObject.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

Modified src/OFStreamObserver.h from [5875ec6cd6] to [8d506e5d4b].

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifdef OF_HAVE_POLL
	OFDataArray *fds;
	OFMutableDictionary *fdToStream;
#else
	fd_set readfds;
	fd_set writefds;
	fd_set exceptfds;
	int nfds;
#endif
}

#ifdef OF_HAVE_PROPERTIES
@property (retain) id <OFStreamObserverDelegate> delegate;
#endif








|







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifdef OF_HAVE_POLL
	OFDataArray *fds;
	OFMutableDictionary *fdToStream;
#else
	fd_set readfds;
	fd_set writefds;
	fd_set exceptfds;
	nfds_t nfds;
#endif
}

#ifdef OF_HAVE_PROPERTIES
@property (retain) id <OFStreamObserverDelegate> delegate;
#endif

Modified src/OFStreamObserver.m from [3ce8ac4b7d] to [624d0c1dc4].

235
236
237
238
239
240
241




242
243
244
245
246
247
248
249
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	BOOL foundInCache = NO;
	OFStream **cArray;
	size_t i, count;
#ifdef OF_HAVE_POLL
	struct pollfd *fds_c = [fds cArray];




	size_t nfds = [fds count];
#else
	fd_set readfds_;
	fd_set writefds_;
	fd_set exceptfds_;
	struct timeval tv;
#endif








>
>
>
>
|







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	BOOL foundInCache = NO;
	OFStream **cArray;
	size_t i, count;
#ifdef OF_HAVE_POLL
	struct pollfd *fds_c = [fds cArray];
	/*
	 * There is no way to find out the maximum number of fds, so we just
	 * cast.
	 */
	nfds_t nfds = (nfds_t)[fds count];
#else
	fd_set readfds_;
	fd_set writefds_;
	fd_set exceptfds_;
	struct timeval tv;
#endif

Modified src/OFString.h from [71d6e95663] to [9b66ad1a81].

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@class OFURL;

/**
 * \brief A class for handling strings.
 */
@interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing>
{
	char	     *string;
	unsigned int length;
#if defined(OF_APPLE_RUNTIME) && __LP64__
	int	     _unused;
#endif
	BOOL	     isUTF8;
}

/**
 * \return A new autoreleased OFString
 */
+ string;








|
|
<
<
<
|







48
49
50
51
52
53
54
55
56



57
58
59
60
61
62
63
64
@class OFURL;

/**
 * \brief A class for handling strings.
 */
@interface OFString: OFObject <OFCopying, OFMutableCopying, OFComparing>
{
	char   *string;
	size_t length;



	BOOL   isUTF8;
}

/**
 * \return A new autoreleased OFString
 */
+ string;

Modified src/OFThread.m from [e6a6c3857f] to [022999c179].

103
104
105
106
107
108
109



110
111
112



113
114
115
116
117
118
119
120
121
122
123
124
125
126



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144



145
146
147



148
149
150
151
152
153
154

+ (void)sleepForTimeInterval: (int64_t)sec
{
	if (sec < 0)
		@throw [OFOutOfRangeException newWithClass: self];

#ifndef _WIN32



	sleep(sec);
#else
	Sleep(sec * 1000);



#endif
}

+ (void)sleepForTimeInterval: (int64_t)sec
		microseconds: (uint32_t)usec
{
	if (sec < 0)
		@throw [OFOutOfRangeException newWithClass: self];

#ifndef _WIN32
	sleep(sec);
	usleep(usec);
#else
	Sleep(sec * 1000 + usec / 1000);



#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDate *now = [OFDate date];
	int64_t sec;
	uint32_t usec;

	if ((sec = [date timeIntervalSinceDate: now]) < 0)
		@throw [OFOutOfRangeException newWithClass: self];

	usec = [date microsecondsOfTimeIntervalSinceDate: now];

	[pool release];

#ifndef _WIN32



	sleep(sec);
	usleep(usec);
#else



	Sleep(sec * 1000 + usec / 1000);
#endif
}

+ (void)yield
{
#ifdef OF_HAVE_SCHED_YIELD







>
>
>
|

|
>
>
>










|


|
>
>
>


















>
>
>
|


>
>
>







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169

+ (void)sleepForTimeInterval: (int64_t)sec
{
	if (sec < 0)
		@throw [OFOutOfRangeException newWithClass: self];

#ifndef _WIN32
	if (sec > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	sleep((unsigned int)sec);
#else
	if (sec * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	Sleep((unsigned int)sec * 1000);
#endif
}

+ (void)sleepForTimeInterval: (int64_t)sec
		microseconds: (uint32_t)usec
{
	if (sec < 0)
		@throw [OFOutOfRangeException newWithClass: self];

#ifndef _WIN32
	sleep((unsigned int)sec);
	usleep(usec);
#else
	if (sec * 1000 + usec / 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	Sleep((unsigned int)sec * 1000 + usec / 1000);
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDate *now = [OFDate date];
	int64_t sec;
	uint32_t usec;

	if ((sec = [date timeIntervalSinceDate: now]) < 0)
		@throw [OFOutOfRangeException newWithClass: self];

	usec = [date microsecondsOfTimeIntervalSinceDate: now];

	[pool release];

#ifndef _WIN32
	if (sec > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	sleep((unsigned int)sec);
	usleep(usec);
#else
	if (sec * 1000 + usec / 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	Sleep(sec * 1000 + usec / 1000);
#endif
}

+ (void)yield
{
#ifdef OF_HAVE_SCHED_YIELD

Modified src/of_asprintf.m from [7a9c826b78] to [983a2f4cc6].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "config.h"

#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdbool.h>
#include <limits.h>
#include <wchar.h>

#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "asprintf.h"

#define MAX_SUBFMT_LEN 64







<







17
18
19
20
21
22
23

24
25
26
27
28
29
30
#include "config.h"

#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdbool.h>

#include <wchar.h>

#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "asprintf.h"

#define MAX_SUBFMT_LEN 64
393
394
395
396
397
398
399
400
401
402
403

404
405
406
407
408
409
410
411
412

413
414
415
416
417
418
419
420
421

422
423
424
425
426
427
428

		tmp_len = asprintf(&tmp, ctx->subfmt, va_arg(ctx->args, void*));

		break;
	case 'n':
		switch (ctx->len_mod) {
		case LENGTH_MODIFIER_NONE:
			*va_arg(ctx->args, int*) = ctx->buf_len;
			break;
		case LENGTH_MODIFIER_HH:
			*va_arg(ctx->args, signed char*) = ctx->buf_len;

			break;
		case LENGTH_MODIFIER_H:
			*va_arg(ctx->args, short*) = ctx->buf_len;
			break;
		case LENGTH_MODIFIER_L:
			*va_arg(ctx->args, long*) = ctx->buf_len;
			break;
		case LENGTH_MODIFIER_LL:
			*va_arg(ctx->args, long long*) = ctx->buf_len;

			break;
		case LENGTH_MODIFIER_J:
			*va_arg(ctx->args, intmax_t*) = ctx->buf_len;
			break;
		case LENGTH_MODIFIER_Z:
			*va_arg(ctx->args, size_t*) = ctx->buf_len;
			break;
		case LENGTH_MODIFIER_T:
			*va_arg(ctx->args, ptrdiff_t*) = ctx->buf_len;

			break;
		default:
			return false;
		}

		break;
	case '%':







|


|
>


|


|


|
>


|





|
>







392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430

		tmp_len = asprintf(&tmp, ctx->subfmt, va_arg(ctx->args, void*));

		break;
	case 'n':
		switch (ctx->len_mod) {
		case LENGTH_MODIFIER_NONE:
			*va_arg(ctx->args, int*) = (int)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_HH:
			*va_arg(ctx->args, signed char*) =
			    (signed char)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_H:
			*va_arg(ctx->args, short*) = (short)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_L:
			*va_arg(ctx->args, long*) = (long)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_LL:
			*va_arg(ctx->args, long long*) =
			    (long long)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_J:
			*va_arg(ctx->args, intmax_t*) = (intmax_t)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_Z:
			*va_arg(ctx->args, size_t*) = ctx->buf_len;
			break;
		case LENGTH_MODIFIER_T:
			*va_arg(ctx->args, ptrdiff_t*) =
			    (ptrdiff_t)ctx->buf_len;
			break;
		default:
			return false;
		}

		break;
	case '%':
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
		free(ctx.buf);
		return -1;
	}

	ctx.buf[ctx.buf_len] = 0;

	*ret = ctx.buf;
	return ctx.buf_len;
}

int
of_asprintf(char **ret, const char *fmt, ...)
{
	va_list args;
	int r;







|







503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
		free(ctx.buf);
		return -1;
	}

	ctx.buf[ctx.buf_len] = 0;

	*ret = ctx.buf;
	return (ctx.buf_len <= INT_MAX ? (int)ctx.buf_len : INT_MAX);
}

int
of_asprintf(char **ret, const char *fmt, ...)
{
	va_list args;
	int r;

Modified tests/OFTCPSocketTests.m from [3cdfedaa43] to [5f759947be].

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFTCPSocket *server, *client = nil, *accepted;
	OFString *msg;
	uint16_t port;
	char buf[6];

	srand(time(NULL));
	port = (uint16_t)rand();
	if (port < 1024)
		port += 1024;

	TEST(@"+[socket]", (server = [OFTCPSocket socket]) &&
	    (client = [OFTCPSocket socket]))








|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFTCPSocket *server, *client = nil, *accepted;
	OFString *msg;
	uint16_t port;
	char buf[6];

	srand((unsigned)time(NULL));
	port = (uint16_t)rand();
	if (port < 1024)
		port += 1024;

	TEST(@"+[socket]", (server = [OFTCPSocket socket]) &&
	    (client = [OFTCPSocket socket]))