ObjFW  Check-in [51833ec7a7]

Overview
Comment:Get rid of 3 more FIXMEs.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 51833ec7a7c7144de11ffd9c7cf15e4daf4ec05637e23f31b5efe30394c83548
User & Date: js on 2009-11-15 14:25:22
Other Links: manifest | tags
Context
2009-11-18
23:11
Remove now unnecessary CFLAGS from Makefile. check-in: 7b1079712b user: js tags: trunk
2009-11-15
14:25
Get rid of 3 more FIXMEs. check-in: 51833ec7a7 user: js tags: trunk
02:10
Improve handling of failed init in OFTLSKey. check-in: 344d7506df user: js tags: trunk
Changes

Modified src/OFExceptions.h from [bb672c63ef] to [03c9f4b0e9].

882
883
884
885
886
887
888






@end

/**
 * An OFException indicating that unlocking a mutex failed.
 */
@interface OFMutexUnlockFailedException: OFException {}
@end













>
>
>
>
>
>
882
883
884
885
886
887
888
889
890
891
892
893
894
@end

/**
 * An OFException indicating that unlocking a mutex failed.
 */
@interface OFMutexUnlockFailedException: OFException {}
@end

/**
 * An OFException indicating that the hash has already been calculated.
 */
@interface OFHashAlreadyCalculatedException: OFException {}
@end

Modified src/OFExceptions.m from [db844d6204] to [ebc97e05f6].

1261
1262
1263
1264
1265
1266
1267














1268
1269
1270
{
	if (string != nil)
		return string;

	string = [[OFString alloc] initWithFormat:
	    @"A mutex could not be unlocked in class %s", [class_ className]];















	return string;
}
@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>



1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
{
	if (string != nil)
		return string;

	string = [[OFString alloc] initWithFormat:
	    @"A mutex could not be unlocked in class %s", [class_ className]];

	return string;
}
@end

@implementation OFHashAlreadyCalculatedException
- (OFString*)string
{
	if (string != nil)
		return string;

	string = [[OFString alloc] initWithFormat:
	    @"The hash has already been calculated in class %s and thus no new "
	    @"data can be added", [class_ className]];

	return string;
}
@end

Modified src/OFHashes.m from [09c2333d11] to [78b7e000bc].

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{
	uint32_t t;

	if (size == 0)
		return self;

	if (calculated)
		/* FIXME: Maybe a new exception would be better */
		@throw [OFInvalidArgumentException 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;







<
|







141
142
143
144
145
146
147

148
149
150
151
152
153
154
155
{
	uint32_t t;

	if (size == 0)
		return self;

	if (calculated)

		@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;
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
- updateWithBuffer: (const char*)buf
	    ofSize: (size_t)size
{
	if (size == 0)
		return self;

	if (calculated)
		/* FIXME: Maybe a new exception would be better */
		@throw [OFInvalidArgumentException newWithClass: isa];

	sha1_update(state, &count, buffer, buf, size);

	return self;
}

- (uint8_t*)digest







<
|







379
380
381
382
383
384
385

386
387
388
389
390
391
392
393
- updateWithBuffer: (const char*)buf
	    ofSize: (size_t)size
{
	if (size == 0)
		return self;

	if (calculated)

		@throw [OFHashAlreadyCalculatedException newWithClass: isa];

	sha1_update(state, &count, buffer, buf, size);

	return self;
}

- (uint8_t*)digest

Modified src/OFThread.m from [12445a3521] to [5453c14532].

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

+ setObject: (id)obj
  forTLSKey: (OFTLSKey*)key
{
	id old = of_tlskey_get(key->key);

	if (!of_tlskey_set(key->key, [obj retain]))
		/* FIXME: Maybe another exception would be better */
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	[old release];

	return self;
}







<







43
44
45
46
47
48
49

50
51
52
53
54
55
56

+ setObject: (id)obj
  forTLSKey: (OFTLSKey*)key
{
	id old = of_tlskey_get(key->key);

	if (!of_tlskey_set(key->key, [obj retain]))

		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	[old release];

	return self;
}

Modified tests/OFHashes.m from [c5020ec5a5] to [9ce9d2717f].

52
53
54
55
56
57
58







59
60
61
				ofSize: len];
	}
	[f close];

	TEST(@"-[digest]",
	    !memcmp([md5 digest], testfile_md5, OF_MD5_DIGEST_SIZE) &&
	    !memcmp([sha1 digest], testfile_sha1, OF_MD5_DIGEST_SIZE))








	[pool release];
}







>
>
>
>
>
>
>



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
				ofSize: len];
	}
	[f close];

	TEST(@"-[digest]",
	    !memcmp([md5 digest], testfile_md5, OF_MD5_DIGEST_SIZE) &&
	    !memcmp([sha1 digest], testfile_sha1, OF_MD5_DIGEST_SIZE))

	EXPECT_EXCEPTION(@"Detect invalid call of -[updateWithBuffer] #1",
	    OFHashAlreadyCalculatedException, [md5 updateWithBuffer: ""
							     ofSize: 1])
	EXPECT_EXCEPTION(@"Detect invalid call of -[updateWithBuffer] #2",
	    OFHashAlreadyCalculatedException, [sha1 updateWithBuffer: ""
							      ofSize: 1])

	[pool release];
}