aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2025-02-26 14:02:14 -0800
committerGopher Robot <gobot@golang.org>2025-02-26 14:39:37 -0800
commit2e71ae33ca3339cc2f7554ec6a8a39c5938f1001 (patch)
tree70e441a116b0ca62826421fe11506c9c702742e1 /src/runtime
parentc55c1cbd04ca42c70adadc86e1f48f3678be10cc (diff)
downloadgo-2e71ae33ca3339cc2f7554ec6a8a39c5938f1001.tar.xz
runtime/cgo: avoid errors from -Wdeclaration-after-statement
CL 652181 accidentally missed this iPhone only code. For #71961 Change-Id: I567f8bb38958907442e69494da330d5199d11f54 Reviewed-on: https://go-review.googlesource.com/c/go/+/653135 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/cgo/gcc_darwin_arm64.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/runtime/cgo/gcc_darwin_arm64.c b/src/runtime/cgo/gcc_darwin_arm64.c
index 4b34692957..e800e9303c 100644
--- a/src/runtime/cgo/gcc_darwin_arm64.c
+++ b/src/runtime/cgo/gcc_darwin_arm64.c
@@ -76,19 +76,27 @@ threadentry(void *v)
static void
init_working_dir()
{
- CFBundleRef bundle = CFBundleGetMainBundle();
+ CFBundleRef bundle;
+ CFURLRef url_ref;
+ CFStringRef url_str_ref;
+ char buf[MAXPATHLEN];
+ Boolean res;
+ int url_len;
+ char *dir;
+ CFStringRef wd_ref;
+
+ bundle = CFBundleGetMainBundle();
if (bundle == NULL) {
fprintf(stderr, "runtime/cgo: no main bundle\n");
return;
}
- CFURLRef url_ref = CFBundleCopyResourceURL(bundle, CFSTR("Info"), CFSTR("plist"), NULL);
+ url_ref = CFBundleCopyResourceURL(bundle, CFSTR("Info"), CFSTR("plist"), NULL);
if (url_ref == NULL) {
// No Info.plist found. It can happen on Corellium virtual devices.
return;
}
- CFStringRef url_str_ref = CFURLGetString(url_ref);
- char buf[MAXPATHLEN];
- Boolean res = CFStringGetCString(url_str_ref, buf, sizeof(buf), kCFStringEncodingUTF8);
+ url_str_ref = CFURLGetString(url_ref);
+ res = CFStringGetCString(url_str_ref, buf, sizeof(buf), kCFStringEncodingUTF8);
CFRelease(url_ref);
if (!res) {
fprintf(stderr, "runtime/cgo: cannot get URL string\n");
@@ -97,13 +105,13 @@ init_working_dir()
// url is of the form "file:///path/to/Info.plist".
// strip it down to the working directory "/path/to".
- int url_len = strlen(buf);
+ url_len = strlen(buf);
if (url_len < sizeof("file://")+sizeof("/Info.plist")) {
fprintf(stderr, "runtime/cgo: bad URL: %s\n", buf);
return;
}
buf[url_len-sizeof("/Info.plist")+1] = 0;
- char *dir = &buf[0] + sizeof("file://")-1;
+ dir = &buf[0] + sizeof("file://")-1;
if (chdir(dir) != 0) {
fprintf(stderr, "runtime/cgo: chdir(%s) failed\n", dir);
@@ -111,7 +119,7 @@ init_working_dir()
// The test harness in go_ios_exec passes the relative working directory
// in the GoExecWrapperWorkingDirectory property of the app bundle.
- CFStringRef wd_ref = CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("GoExecWrapperWorkingDirectory"));
+ wd_ref = CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("GoExecWrapperWorkingDirectory"));
if (wd_ref != NULL) {
if (!CFStringGetCString(wd_ref, buf, sizeof(buf), kCFStringEncodingUTF8)) {
fprintf(stderr, "runtime/cgo: cannot get GoExecWrapperWorkingDirectory string\n");