Skip to content

Commit

Permalink
Fixed casting warnings on macOS arm.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz committed Jun 27, 2023
1 parent bab0ce3 commit 224e42e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions config_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ char *proxy_config_mac_get_proxy(const char *scheme) {
// Append the proxy port to the proxy url
int64_t port_number = 0;
CFNumberGetValue(port, kCFNumberSInt64Type, &port_number);
int32_t proxy_len = strlen(proxy);
size_t proxy_len = strlen(proxy);
snprintf(proxy + proxy_len, max_proxy - proxy_len, ":%" PRId64 "", port_number);
}
}
Expand All @@ -137,9 +137,9 @@ char *proxy_config_mac_get_proxy(const char *scheme) {

char *proxy_config_mac_get_bypass_list(void) {
char *bypass_list = NULL;
int32_t bypass_list_len = 0;
int32_t bypass_list_count = 0;
int32_t exception_count = 0;
size_t bypass_list_len = 0;
size_t bypass_list_count = 0;
size_t exception_count = 0;
size_t max_bypass_list = 0;

CFDictionaryRef proxy_settings = CFNetworkCopySystemProxySettings();
Expand Down Expand Up @@ -175,7 +175,7 @@ char *proxy_config_mac_get_bypass_list(void) {
}

// Enumerate exception array and copy to comma delimited string
for (int32_t i = 0; exceptions_list && i < exception_count; ++i) {
for (size_t i = 0; exceptions_list && i < exception_count; ++i) {
CFStringRef exception = CFArrayGetValueAtIndex(exceptions_list, i);
if (exception) {
const char *exception_utf8 = CFStringGetCStringPtr(exception, kCFStringEncodingUTF8);
Expand Down
18 changes: 9 additions & 9 deletions resolver_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ g_proxy_resolver_mac_s g_proxy_resolver_mac;

typedef struct proxy_resolver_mac_s {
// Last system error
int32_t error;
int64_t error;
// Complete event
void *complete;
// Proxy list
Expand All @@ -40,14 +40,14 @@ static void proxy_resolver_mac_auto_config_result_callback(void *client, CFArray
proxy_resolver->error = CFErrorGetCode(error);
} else {
// Convert proxy array into PAC file return format
int32_t proxy_count = CFArrayGetCount(proxy_array);
int32_t max_list = proxy_count * MAX_PROXY_URL + 1;
int32_t list_len = 0;
size_t proxy_count = CFArrayGetCount(proxy_array);
size_t max_list = proxy_count * MAX_PROXY_URL + 1;
size_t list_len = 0;

proxy_resolver->list = (char *)calloc(max_list, sizeof(char));

// Enumerate through each proxy in the array
for (int32_t i = 0; proxy_resolver->list && i < proxy_count; i++) {
for (size_t i = 0; proxy_resolver->list && i < proxy_count; i++) {
CFDictionaryRef proxy = CFArrayGetValueAtIndex(proxy_array, i);
CFStringRef proxy_type = (CFStringRef)CFDictionaryGetValue(proxy, kCFProxyTypeKey);

Expand Down Expand Up @@ -131,15 +131,15 @@ bool proxy_resolver_mac_get_proxies_for_url(void *ctx, const char *url) {

if (!url_ref) {
proxy_resolver->error = ENOMEM;
LOG_ERROR("Unable to allocate memory for %s (%" PRId32 ")\n", "auto config url reference",
LOG_ERROR("Unable to allocate memory for %s (%" PRId64 ")\n", "auto config url reference",
proxy_resolver->error);
goto mac_done;
}

target_url_ref = CFURLCreateWithBytes(NULL, (const UInt8 *)url, strlen(url), kCFStringEncodingUTF8, NULL);
if (!target_url_ref) {
proxy_resolver->error = ENOMEM;
LOG_ERROR("Unable to allocate memory for %s (%" PRId32 ")\n", "target url reference",
LOG_ERROR("Unable to allocate memory for %s (%" PRId64 ")\n", "target url reference",
proxy_resolver->error);
goto mac_done;
}
Expand All @@ -150,7 +150,7 @@ bool proxy_resolver_mac_get_proxies_for_url(void *ctx, const char *url) {
url_ref, target_url_ref, proxy_resolver_mac_auto_config_result_callback, &context);
if (!run_loop) {
proxy_resolver->error = ELOOP;
LOG_ERROR("Failed to execute pac url (%" PRId32 ")\n", proxy_resolver->error);
LOG_ERROR("Failed to execute pac url (%" PRId64 ")\n", proxy_resolver->error);
goto mac_done;
}

Expand Down Expand Up @@ -200,7 +200,7 @@ const char *proxy_resolver_mac_get_list(void *ctx) {

int32_t proxy_resolver_mac_get_error(void *ctx) {
proxy_resolver_mac_s *proxy_resolver = (proxy_resolver_mac_s *)ctx;
return proxy_resolver->error;
return (int32_t)proxy_resolver->error;
}

bool proxy_resolver_mac_wait(void *ctx, int32_t timeout_ms) {
Expand Down

0 comments on commit 224e42e

Please sign in to comment.