Skip to content

Commit

Permalink
Fix compiler error on clang
Browse files Browse the repository at this point in the history
Turns out variable declarations are not allowed after a label, even in
C99. And while some compilers don't seem to care others do.

Moving the declaration of mayopen to the start of the function to avoid
this problem.

Resolves: #2435
  • Loading branch information
ffesti authored and pmatilai committed Mar 17, 2023
1 parent 1525b2d commit b960c0b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/fsm.c
Expand Up @@ -879,6 +879,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
int nodigest = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOFILEDIGEST) ? 1 : 0;
int nofcaps = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCAPS) ? 1 : 0;
int firstlinkfile = -1;
int mayopen = 0;
char *tid = NULL;
struct filedata_s *fdata = xcalloc(fc, sizeof(*fdata));
struct filedata_s *firstlink = NULL;
Expand Down Expand Up @@ -1016,7 +1017,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,

setmeta:
/* Special files require path-based ops */
int mayopen = S_ISREG(fp->sb.st_mode) || S_ISDIR(fp->sb.st_mode);
mayopen = S_ISREG(fp->sb.st_mode) || S_ISDIR(fp->sb.st_mode);
if (!rc && fd == -1 && mayopen) {
int flags = O_RDONLY;
/* Only follow safe symlinks, and never on temporary files */
Expand Down

0 comments on commit b960c0b

Please sign in to comment.