blob: e5c84ebd498042e62bf9dbcce11e869cebcd889e [file] [log] [blame]
Patrick Williamse760df82023-05-26 11:10:49 -05001From b960c0b43a080287a7c13533eeb2d9f288db1414 Mon Sep 17 00:00:00 2001
2From: Florian Festi <ffesti@redhat.com>
3Date: Thu, 16 Mar 2023 19:05:04 +0100
4Subject: [PATCH] Fix compiler error on clang
5
6Turns out variable declarations are not allowed after a label, even in
7C99. And while some compilers don't seem to care others do.
8
9Moving the declaration of mayopen to the start of the function to avoid
10this problem.
11
12Resolves: #2435
13Upstream-Status: Backport [https://github.com/rpm-software-management/rpm/commit/b960c0b43a080287a7c13533eeb2d9f288db1414]
14Signed-off-by: Alexander Kanavin <alex@linutronix.de>
15---
16 lib/fsm.c | 3 ++-
17 1 file changed, 2 insertions(+), 1 deletion(-)
18
19diff --git a/lib/fsm.c b/lib/fsm.c
20index 5671ac642d..183293edb0 100644
21--- a/lib/fsm.c
22+++ b/lib/fsm.c
23@@ -879,6 +879,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
24 int nodigest = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOFILEDIGEST) ? 1 : 0;
25 int nofcaps = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCAPS) ? 1 : 0;
26 int firstlinkfile = -1;
27+ int mayopen = 0;
28 char *tid = NULL;
29 struct filedata_s *fdata = xcalloc(fc, sizeof(*fdata));
30 struct filedata_s *firstlink = NULL;
31@@ -1016,7 +1017,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
32
33 setmeta:
34 /* Special files require path-based ops */
35- int mayopen = S_ISREG(fp->sb.st_mode) || S_ISDIR(fp->sb.st_mode);
36+ mayopen = S_ISREG(fp->sb.st_mode) || S_ISDIR(fp->sb.st_mode);
37 if (!rc && fd == -1 && mayopen) {
38 int flags = O_RDONLY;
39 /* Only follow safe symlinks, and never on temporary files */