Skip to content

Commit dadab25

Browse files
Fix a few unused variable warnings. (#463)
Change out asserts for if statements + on_sys_error and fix a few unused variable warnings.
1 parent 55b011d commit dadab25

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/ios-deploy/ios-deploy.m

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,14 @@ void mount_developer_image(AMDeviceRef device) {
596596
NSLogVerbose(@"Developer disk image: %@", image_path);
597597

598598
FILE* sig = fopen(CFStringGetCStringPtr(sig_path, kCFStringEncodingMacRoman), "rb");
599-
void *sig_buf = malloc(128);
600-
size_t bytes_read = fread(sig_buf, 1, 128, sig);
601-
assert( bytes_read == 128);
599+
size_t buf_size = 128;
600+
void *sig_buf = malloc(buf_size);
601+
size_t bytes_read = fread(sig_buf, 1, buf_size, sig);
602+
if (bytes_read != buf_size) {
603+
on_sys_error(@"fread read %d bytes but expected %d bytes.", bytes_read, buf_size);
604+
}
602605
fclose(sig);
603-
CFDataRef sig_data = CFDataCreateWithBytesNoCopy(NULL, sig_buf, 128, NULL);
606+
CFDataRef sig_data = CFDataCreateWithBytesNoCopy(NULL, sig_buf, buf_size, NULL);
604607
CFRelease(sig_path);
605608

606609
CFTypeRef keys[] = { CFSTR("ImageSignature"), CFSTR("ImageType") };
@@ -987,7 +990,9 @@ void fdvendor_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataR
987990
lldb_socket = CFSocketCreateWithNative(NULL, socket, kCFSocketDataCallBack, &lldb_callback, NULL);
988991
int flag = 1;
989992
int res = setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(flag));
990-
assert(res == 0);
993+
if (res == -1) {
994+
on_sys_error(@"Setting socket option failed.");
995+
}
991996
if (lldb_socket_runloop) {
992997
CFRelease(lldb_socket_runloop);
993998
}
@@ -1067,7 +1072,9 @@ void start_remote_debug_server(AMDeviceRef device) {
10671072
CFRelease(address_data);
10681073
socklen_t addrlen = sizeof(addr4);
10691074
int res = getsockname(CFSocketGetNative(fdvendor),(struct sockaddr *)&addr4,&addrlen);
1070-
assert(res == 0);
1075+
if (res == -1) {
1076+
on_sys_error(@"Getting socket name failed.");
1077+
}
10711078
port = ntohs(addr4.sin_port);
10721079

10731080
if (fdvendor_runloop) {

0 commit comments

Comments
 (0)