Patrick Williams | e760df8 | 2023-05-26 11:10:49 -0500 | [diff] [blame] | 1 | From b960c0b43a080287a7c13533eeb2d9f288db1414 Mon Sep 17 00:00:00 2001 |
| 2 | From: Florian Festi <ffesti@redhat.com> |
| 3 | Date: Thu, 16 Mar 2023 19:05:04 +0100 |
| 4 | Subject: [PATCH] Fix compiler error on clang |
| 5 | |
| 6 | Turns out variable declarations are not allowed after a label, even in |
| 7 | C99. And while some compilers don't seem to care others do. |
| 8 | |
| 9 | Moving the declaration of mayopen to the start of the function to avoid |
| 10 | this problem. |
| 11 | |
| 12 | Resolves: #2435 |
| 13 | Upstream-Status: Backport [https://github.com/rpm-software-management/rpm/commit/b960c0b43a080287a7c13533eeb2d9f288db1414] |
| 14 | Signed-off-by: Alexander Kanavin <alex@linutronix.de> |
| 15 | --- |
| 16 | lib/fsm.c | 3 ++- |
| 17 | 1 file changed, 2 insertions(+), 1 deletion(-) |
| 18 | |
| 19 | diff --git a/lib/fsm.c b/lib/fsm.c |
| 20 | index 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 */ |