Skip to content

Commit d11b77d

Browse files
committed
apk: Fix host compilation with C89
This fixes the following build error: ``` ../src/apk.c: In function 'parse_options': ../src/apk.c:584:4: error: a label can only be part of a statement and a declaration is not a statement 584 | char *arg = opt_parse_arg(&st); | ^~~~ ``` Upstream MR: https://gitlab.alpinelinux.org/alpine/apk-tools/-/merge_requests/376 Fixes: b91ebda ("apk: bump to 3.0.1") Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
1 parent 344bb7f commit d11b77d

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
From 54385e6dc02ada9ec827b6b79b9359951197fee5 Mon Sep 17 00:00:00 2001
2+
From: Paul Donald <newtwen+gitlab@gmail.com>
3+
Date: Tue, 9 Dec 2025 00:31:27 +0100
4+
Subject: [PATCH] apk: fix compile when using C89
5+
6+
The older standard is more strict, and gives rise to errors:
7+
8+
../src/apk.c: In function 'parse_options':
9+
../src/apk.c:584:4: error: a label can only be part of a statement and a declaration is not a statement
10+
584 | char *arg = opt_parse_arg(&st);
11+
| ^~~~
12+
13+
So move the *arg declaration to function start.
14+
15+
../src/app_mkpkg.c: In function 'mkpkg_setup_compat':
16+
../src/app_mkpkg.c:423:2: error: label at end of compound statement
17+
423 | default:
18+
| ^~~~~~~
19+
20+
add break;
21+
22+
Signed-off-by: Paul Donald <newtwen+gitlab@gmail.com>
23+
---
24+
src/apk.c | 3 ++-
25+
src/app_mkpkg.c | 1 +
26+
2 files changed, 3 insertions(+), 1 deletion(-)
27+
28+
--- a/src/apk.c
29+
+++ b/src/apk.c
30+
@@ -556,6 +556,7 @@ static int parse_options(int argc, char
31+
struct apk_opt_match m;
32+
bool applet_arg_pending = false;
33+
int r;
34+
+ char *arg;
35+
36+
applet = applet_from_arg0(argv[0]);
37+
if (!applet) {
38+
@@ -581,7 +582,7 @@ static int parse_options(int argc, char
39+
case 0:
40+
break;
41+
case OPT_MATCH_NON_OPTION:
42+
- char *arg = opt_parse_arg(&st);
43+
+ arg = opt_parse_arg(&st);
44+
if (applet_arg_pending && strcmp(arg, applet->name) == 0)
45+
applet_arg_pending = false;
46+
else if (arg[0] || !applet || !applet->remove_empty_arguments)
47+
--- a/src/app_mkpkg.c
48+
+++ b/src/app_mkpkg.c
49+
@@ -421,6 +421,7 @@ static void mkpkg_setup_compat(struct mk
50+
case 0: ctx->compat_rootnode = 1; // fallthrough
51+
case 1: ctx->compat_dirnode = 1; // fallthrough
52+
default:
53+
+ break;
54+
}
55+
}
56+

0 commit comments

Comments
 (0)