diff --git a/frontend/drivers/platform_apple.c b/frontend/drivers/platform_apple.c index 409c6dc2cc..e746706361 100644 --- a/frontend/drivers/platform_apple.c +++ b/frontend/drivers/platform_apple.c @@ -30,100 +30,100 @@ static bool CopyModel(char** model, uint32_t *majorRev, uint32_t *minorRev) { #ifdef OSX - int mib[2]; - int count; - unsigned long modelLen; - char *revStr; + int mib[2]; + int count; + unsigned long modelLen; + char *revStr; #endif - char *machineModel; - bool success = true; - size_t length = 1024; - - if (!model || !majorRev || !minorRev) - { - RARCH_ERR("CopyModel: Passing NULL arguments\n"); - return false; - } - + char *machineModel; + bool success = true; + size_t length = 1024; + + if (!model || !majorRev || !minorRev) + { + RARCH_ERR("CopyModel: Passing NULL arguments\n"); + return false; + } + #ifdef IOS - sysctlbyname("hw.machine", NULL, &length, NULL, 0); + sysctlbyname("hw.machine", NULL, &length, NULL, 0); #endif - - machineModel = malloc(length); - - if (!machineModel) - { - success = false; - goto exit; - } + + machineModel = malloc(length); + + if (!machineModel) + { + success = false; + goto exit; + } #ifdef IOS - sysctlbyname("hw.machine", machineModel, &length, NULL, 0); - *model = strndup(machineModel, length); + sysctlbyname("hw.machine", machineModel, &length, NULL, 0); + *model = strndup(machineModel, length); #else - mib[0] = CTL_HW; - mib[1] = HW_MODEL; - - if (sysctl(mib, 2, machineModel, &length, NULL, 0)) - { - printf("CopyModel: sysctl (error %d)\n", errno); - success = false; - goto exit; - } - - modelLen = strcspn(machineModel, "0123456789"); - - if (modelLen == 0) - { - RARCH_ERR("CopyModel: Could not find machine model name\n"); - success = false; - goto exit; - } - - *model = strndup(machineModel, modelLen); - - if (*model == NULL) - { - RARCH_ERR("CopyModel: Could not find machine model name\n"); - success = false; - goto exit; - } - - *majorRev = 0; - *minorRev = 0; - revStr = strpbrk(machineModel, "0123456789"); - - if (!revStr) - { - RARCH_ERR("CopyModel: Could not find machine version number, inferred value is 0,0\n"); - success = true; - goto exit; - } - - count = sscanf(revStr, "%d,%d", majorRev, minorRev); - - if (count < 2) - { - RARCH_ERR("CopyModel: Could not find machine version number\n"); - if (count < 1) - *majorRev = 0; - *minorRev = 0; - success = true; - goto exit; - } + mib[0] = CTL_HW; + mib[1] = HW_MODEL; + + if (sysctl(mib, 2, machineModel, &length, NULL, 0)) + { + printf("CopyModel: sysctl (error %d)\n", errno); + success = false; + goto exit; + } + + modelLen = strcspn(machineModel, "0123456789"); + + if (modelLen == 0) + { + RARCH_ERR("CopyModel: Could not find machine model name\n"); + success = false; + goto exit; + } + + *model = strndup(machineModel, modelLen); + + if (*model == NULL) + { + RARCH_ERR("CopyModel: Could not find machine model name\n"); + success = false; + goto exit; + } + + *majorRev = 0; + *minorRev = 0; + revStr = strpbrk(machineModel, "0123456789"); + + if (!revStr) + { + RARCH_ERR("CopyModel: Could not find machine version number, inferred value is 0,0\n"); + success = true; + goto exit; + } + + count = sscanf(revStr, "%d,%d", majorRev, minorRev); + + if (count < 2) + { + RARCH_ERR("CopyModel: Could not find machine version number\n"); + if (count < 1) + *majorRev = 0; + *minorRev = 0; + success = true; + goto exit; + } #endif - + exit: - if (machineModel) - free(machineModel); - if (!success) - { - if (*model) - free(*model); - *model = NULL; - *majorRev = 0; - *minorRev = 0; - } - return success; + if (machineModel) + free(machineModel); + if (!success) + { + if (*model) + free(*model); + *model = NULL; + *majorRev = 0; + *minorRev = 0; + } + return success; } static void frontend_apple_get_name(char *name, size_t sizeof_name)