diff options
author | Nikias Bassen | 2018-01-03 02:42:25 +0100 |
---|---|---|
committer | Nikias Bassen | 2018-01-03 02:42:25 +0100 |
commit | f78fc4a11b81bcb2aacf93a2060f15fa2f99b66a (patch) | |
tree | 0b5bddb32069dbcad0a6a52715220c7e12c569b9 | |
parent | f06b60e5c1f0ea3ebfdf5684cb884be5c49acee7 (diff) | |
download | libirecovery-f78fc4a11b81bcb2aacf93a2060f15fa2f99b66a.tar.gz libirecovery-f78fc4a11b81bcb2aacf93a2060f15fa2f99b66a.tar.bz2 |
Remove some unnecessary null pointer checks
-rw-r--r-- | src/libirecovery.c | 44 | ||||
-rw-r--r-- | tools/irecovery.c | 3 |
2 files changed, 15 insertions, 32 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c index 69b430c..ae4e3c7 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c @@ -527,10 +527,8 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec memset(¤tInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA)); currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); for(i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_DFU, i, ¤tInterface); i++) { - if (_client->DfuPath) { - free(_client->DfuPath); - _client->DfuPath = NULL; - } + free(_client->DfuPath); + _client->DfuPath = NULL; _client->handle = NULL; DWORD requiredSize = 0; PSP_DEVICE_INTERFACE_DETAIL_DATA details; @@ -614,10 +612,8 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec memset(¤tInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA)); currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); for(i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_IBOOT, i, ¤tInterface); i++) { - if (_client->iBootPath) { - free(_client->iBootPath); - _client->iBootPath = NULL; - } + free(_client->iBootPath); + _client->iBootPath = NULL; _client->handle = NULL; DWORD requiredSize = 0; PSP_DEVICE_INTERFACE_DETAIL_DATA details; @@ -1550,28 +1546,17 @@ IRECV_API irecv_error_t irecv_close(irecv_client_t client) { } #endif #else - if (client->iBootPath!=NULL) { - free(client->iBootPath); - client->iBootPath = NULL; - } - if (client->DfuPath!=NULL) { - free(client->DfuPath); - client->DfuPath = NULL; - } + free(client->iBootPath); + client->iBootPath = NULL; + free(client->DfuPath); + client->DfuPath = NULL; mobiledevice_closepipes(client); #endif - if (client->device_info.srnm) { - free(client->device_info.srnm); - } - if (client->device_info.imei) { - free(client->device_info.imei); - } - if (client->device_info.ap_nonce) { - free(client->device_info.ap_nonce); - } - if (client->device_info.sep_nonce) { - free(client->device_info.sep_nonce); - } + free(client->device_info.srnm); + free(client->device_info.imei); + free(client->device_info.ap_nonce); + free(client->device_info.sep_nonce); + free(client); client = NULL; } @@ -2040,8 +2025,7 @@ IRECV_API irecv_error_t irecv_execute_script(irecv_client_t client, const char* line = strtok(NULL, "\n"); } - if (body) - free(body); + free(body); return error; } diff --git a/tools/irecovery.c b/tools/irecovery.c index 0db60e4..f250dc5 100644 --- a/tools/irecovery.c +++ b/tools/irecovery.c @@ -299,8 +299,7 @@ int postcommand_cb(irecv_client_t client, const irecv_event_t* event) { } } - if (command) - free(command); + free(command); return 0; } |