From b0ca976470dad8d2280168f778034bfbb5c15796 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 20 Apr 2020 23:59:44 +0200 Subject: Use uint64_t and appropriate standard PRI* format specifiers everywhere --- src/common.h | 4 ---- src/idevicerestore.c | 20 ++++++++++---------- src/idevicerestore.h | 2 +- src/ipsw.c | 4 ++-- src/restore.c | 4 ++-- src/tss.c | 2 +- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/common.h b/src/common.h index 0a6e48c..215d18a 100644 --- a/src/common.h +++ b/src/common.h @@ -137,8 +137,6 @@ char *generate_guid(void); #include #include #define __mkdir(path, mode) mkdir(path) -#define FMT_qu "%I64u" -#define FMT_016llx "%016I64x" #ifndef sleep #define sleep(x) Sleep(x*1000) #endif @@ -146,8 +144,6 @@ char *generate_guid(void); #else #include #define __mkdir(path, mode) mkdir(path, mode) -#define FMT_qu "%qu" -#define FMT_016llx "%016" PRIx64 #define __usleep(x) usleep(x) #endif diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 1ce642b..100d945 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -220,13 +220,13 @@ static void idevice_event_cb(const idevice_event_t *event, void *userdata) if (normal_check_mode(client) == 0) { mutex_lock(&client->device_event_mutex); client->mode = &idevicerestore_modes[MODE_NORMAL]; - debug("%s: device " FMT_016llx " (udid: %s) connected in normal mode\n", __func__, client->ecid, client->udid); + debug("%s: device %016" PRIx64 " (udid: %s) connected in normal mode\n", __func__, client->ecid, client->udid); cond_signal(&client->device_event_cond); mutex_unlock(&client->device_event_mutex); } else if (client->ecid && restore_check_mode(client) == 0) { mutex_lock(&client->device_event_mutex); client->mode = &idevicerestore_modes[MODE_RESTORE]; - debug("%s: device " FMT_016llx " (udid: %s) connected in restore mode\n", __func__, client->ecid, client->udid); + debug("%s: device %016" PRIx64 " (udid: %s) connected in restore mode\n", __func__, client->ecid, client->udid); cond_signal(&client->device_event_cond); mutex_unlock(&client->device_event_mutex); } @@ -234,7 +234,7 @@ static void idevice_event_cb(const idevice_event_t *event, void *userdata) if (client->udid && !strcmp(event->udid, client->udid)) { mutex_lock(&client->device_event_mutex); client->mode = &idevicerestore_modes[MODE_UNKNOWN]; - debug("%s: device " FMT_016llx " (udid: %s) disconnected\n", __func__, client->ecid, client->udid); + debug("%s: device %016" PRIx64 " (udid: %s) disconnected\n", __func__, client->ecid, client->udid); client->ignore_device_add_events = 0; cond_signal(&client->device_event_cond); mutex_unlock(&client->device_event_mutex); @@ -267,7 +267,7 @@ static void irecv_event_cb(const irecv_device_event_t* event, void *userdata) default: client->mode = &idevicerestore_modes[MODE_UNKNOWN]; } - debug("%s: device " FMT_016llx " (udid: %s) connected in %s mode\n", __func__, client->ecid, (client->udid) ? client->udid : "N/A", client->mode->string); + debug("%s: device %016" PRIx64 " (udid: %s) connected in %s mode\n", __func__, client->ecid, (client->udid) ? client->udid : "N/A", client->mode->string); cond_signal(&client->device_event_cond); mutex_unlock(&client->device_event_mutex); } @@ -275,7 +275,7 @@ static void irecv_event_cb(const irecv_device_event_t* event, void *userdata) if (client->ecid && event->device_info->ecid == client->ecid) { mutex_lock(&client->device_event_mutex); client->mode = &idevicerestore_modes[MODE_UNKNOWN]; - debug("%s: device " FMT_016llx " (udid: %s) disconnected\n", __func__, client->ecid, (client->udid) ? client->udid : "N/A"); + debug("%s: device %016" PRIx64 " (udid: %s) disconnected\n", __func__, client->ecid, (client->udid) ? client->udid : "N/A"); cond_signal(&client->device_event_cond); mutex_unlock(&client->device_event_mutex); } @@ -1000,7 +1000,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client) error("ERROR: Unable to find device ECID\n"); return -1; } - info("Found ECID " FMT_qu "\n", (long long unsigned int)client->ecid); + info("Found ECID %" PRIu64 "\n", client->ecid); if (client->mode->index == MODE_NORMAL && !(client->flags & FLAG_ERASE) && !(client->flags & FLAG_SHSHONLY)) { plist_t node = normal_get_lockdown_value(client, NULL, "HasSiDP"); @@ -1099,7 +1099,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client) strcpy(zfn, "shsh"); } mkdir_with_parents(zfn, 0755); - sprintf(zfn+strlen(zfn), "/" FMT_qu "-%s-%s.shsh", (long long int)client->ecid, client->device->product_type, client->version); + sprintf(zfn+strlen(zfn), "/%" PRIu64 "-%s-%s.shsh", client->ecid, client->device->product_type, client->version); struct stat fst; if (stat(zfn, &fst) != 0) { gzFile zf = gzopen(zfn, "wb"); @@ -1440,7 +1440,7 @@ void idevicerestore_client_free(struct idevicerestore_client_t* client) free(client); } -void idevicerestore_set_ecid(struct idevicerestore_client_t* client, unsigned long long ecid) +void idevicerestore_set_ecid(struct idevicerestore_client_t* client, uint64_t ecid) { if (!client) return; @@ -2034,9 +2034,9 @@ int get_tss_response(struct idevicerestore_client_t* client, plist_t build_ident char zfn[1024]; if (client->version) { if (client->cache_dir) { - sprintf(zfn, "%s/shsh/" FMT_qu "-%s-%s.shsh", client->cache_dir, (long long int)client->ecid, client->device->product_type, client->version); + sprintf(zfn, "%s/shsh/%" PRIu64 "-%s-%s.shsh", client->cache_dir, client->ecid, client->device->product_type, client->version); } else { - sprintf(zfn, "shsh/" FMT_qu "-%s-%s.shsh", (long long int)client->ecid, client->device->product_type, client->version); + sprintf(zfn, "shsh/%" PRIu64 "-%s-%s.shsh", client->ecid, client->device->product_type, client->version); } struct stat fst; if (stat(zfn, &fst) == 0) { diff --git a/src/idevicerestore.h b/src/idevicerestore.h index 7d7fa53..f6b1cb0 100644 --- a/src/idevicerestore.h +++ b/src/idevicerestore.h @@ -63,7 +63,7 @@ typedef void (*idevicerestore_progress_cb_t)(int step, double step_progress, voi struct idevicerestore_client_t* idevicerestore_client_new(void); void idevicerestore_client_free(struct idevicerestore_client_t* client); -void idevicerestore_set_ecid(struct idevicerestore_client_t* client, unsigned long long ecid); +void idevicerestore_set_ecid(struct idevicerestore_client_t* client, uint64_t ecid); void idevicerestore_set_udid(struct idevicerestore_client_t* client, const char* udid); void idevicerestore_set_flags(struct idevicerestore_client_t* client, int flags); void idevicerestore_set_ipsw(struct idevicerestore_client_t* client, const char* path); diff --git a/src/ipsw.c b/src/ipsw.c index e56afa2..c8659e3 100644 --- a/src/ipsw.c +++ b/src/ipsw.c @@ -576,7 +576,7 @@ int ipsw_get_latest_fw(plist_t version_data, const char* product, char** fwurl, return -1; } char* key = NULL; - long long unsigned int major = 0; + uint64_t major = 0; plist_t val = NULL; do { plist_dict_next_item(n1, iter, &key, &val); @@ -598,7 +598,7 @@ int ipsw_get_latest_fw(plist_t version_data, const char* product, char** fwurl, } char majstr[32]; // should be enough for a uint64_t value - sprintf(majstr, FMT_qu, (long long unsigned int)major); + sprintf(majstr, "%"PRIu64, (uint64_t)major); n1 = plist_access_path(version_data, 7, "MobileDeviceSoftwareVersionsByVersion", majstr, "MobileDeviceSoftwareVersions", product, "Unknown", "Universal", "Restore"); if (!n1) { error("%s: ERROR: Can't get Unknown/Universal/Restore node?!\n", __func__); diff --git a/src/restore.c b/src/restore.c index ecedb63..d6b0fc2 100644 --- a/src/restore.c +++ b/src/restore.c @@ -735,7 +735,7 @@ int restore_handle_status_msg(restored_client_t client, plist_t msg) info("Status: X-Gold Baseband Update Failed. Defective Unit?\n"); break; default: - info("Unhandled status message (" FMT_qu ")\n", (long long unsigned int)value); + info("Unhandled status message (%" PRIu64 ")\n", value); debug_plist(msg); break; } @@ -2677,7 +2677,7 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit node = plist_dict_get_item(hwinfo, "UniqueChipID"); if (node && plist_get_node_type(node) == PLIST_UINT) { plist_get_uint_val(node, &i); - info("UniqueChipID: " FMT_qu "\n", (long long unsigned int)i); + info("UniqueChipID: %" PRIu64 "\n", i); } node = plist_dict_get_item(hwinfo, "ProductionMode"); diff --git a/src/tss.c b/src/tss.c index 05535d9..a309e18 100644 --- a/src/tss.c +++ b/src/tss.c @@ -50,7 +50,7 @@ char* ecid_to_string(uint64_t ecid) { error("ERROR: Invalid ECID passed.\n"); return NULL; } - snprintf(ecid_string, ECID_STRSIZE, FMT_qu, (long long unsigned int)ecid); + snprintf(ecid_string, ECID_STRSIZE, "%"PRIu64, ecid); return ecid_string; } -- cgit v1.1-32-gdbae