Overview
Comment: | Cast return of sizeof() to socklen_t
It caused a warning about an implicit cast on OS X/PPC64. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3fa37632f9d21edf5c641421b91ce311 |
User & Date: | js on 2014-02-21 17:17:04 |
Other Links: | manifest | tags |
Context
2014-02-21
| ||
17:19 | Don't use objc_initializeClassPair on OS X/PPC64 check-in: 3204ceeca0 user: js tags: trunk | |
17:17 | Cast return of sizeof() to socklen_t check-in: 3fa37632f9 user: js tags: trunk | |
17:16 | atomic.h: Fix OSAtomic on PPC64 check-in: 2b00b3cec8 user: js tags: trunk | |
Changes
Modified src/OFTCPSocket.m from [2de1fb049a] to [3b9e3e0a34].
︙ | ︙ | |||
381 382 383 384 385 386 387 | if ((_socket = socket(results[0]->family, results[0]->type, results[0]->protocol)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self]; if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, | | | | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | if ((_socket = socket(results[0]->family, results[0]->type, results[0]->protocol)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithHost: host port: port socket: self]; if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one, (socklen_t)sizeof(one))) @throw [OFSetOptionFailedException exceptionWithStream: self]; if (bind(_socket, results[0]->address, results[0]->addressLength) == -1) { close(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self]; } } @finally { of_resolver_free(results); } if (port > 0) return port; #ifndef __wii__ addrLen = (socklen_t)sizeof(addr.storage); if (getsockname(_socket, (struct sockaddr*)&addr.storage, &addrLen)) { close(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self]; } |
︙ | ︙ | |||
448 449 450 451 452 453 454 | - (instancetype)accept { OFTCPSocket *client = [[[[self class] alloc] init] autorelease]; client->_address = [client allocMemoryWithSize: sizeof(struct sockaddr_storage)]; | | | 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | - (instancetype)accept { OFTCPSocket *client = [[[[self class] alloc] init] autorelease]; client->_address = [client allocMemoryWithSize: sizeof(struct sockaddr_storage)]; client->_addressLength = (socklen_t)sizeof(struct sockaddr_storage); if ((client->_socket = accept(_socket, client->_address, &client->_addressLength)) == INVALID_SOCKET) @throw [OFAcceptFailedException exceptionWithSocket: self]; assert(client->_addressLength <= sizeof(struct sockaddr_storage)); |
︙ | ︙ | |||
489 490 491 492 493 494 495 | } #endif - (void)setKeepAlivesEnabled: (bool)enable { int v = enable; | | > | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | } #endif - (void)setKeepAlivesEnabled: (bool)enable { int v = enable; if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, (socklen_t)sizeof(v))) @throw [OFSetOptionFailedException exceptionWithStream: self]; } - (OFString*)remoteAddress { OFString *ret; |
︙ | ︙ |
Modified src/OFUDPSocket.m from [19a4211bbd] to [aca7fe3ad4].
︙ | ︙ | |||
414 415 416 417 418 419 420 | of_resolver_free(results); } if (port > 0) return port; #ifndef __wii__ | | | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | of_resolver_free(results); } if (port > 0) return port; #ifndef __wii__ addrLen = (socklen_t)sizeof(addr.storage); if (getsockname(_socket, (struct sockaddr*)&addr.storage, &addrLen)) { close(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self]; } |
︙ | ︙ | |||
447 448 449 450 451 452 453 | sender: (of_udp_socket_address_t*)sender { ssize_t ret; if (_socket == INVALID_SOCKET) @throw [OFNotConnectedException exceptionWithSocket: self]; | | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | sender: (of_udp_socket_address_t*)sender { ssize_t ret; if (_socket == INVALID_SOCKET) @throw [OFNotConnectedException exceptionWithSocket: self]; sender->length = (socklen_t)sizeof(sender->address); if ((ret = recvfrom(_socket, buffer, length, 0, (struct sockaddr*)&sender->address, &sender->length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length]; return ret; |
︙ | ︙ |