bcc/bcc-0.25.0-clang-Fix-file_exists_and_ownedby-return-value-4935.patch

34 lines
1.3 KiB
Diff
Raw Permalink Normal View History

From 509b05f2790fd1f9e725e353521a5a555ca57aaf Mon Sep 17 00:00:00 2001
From: Chunsheng Luo <48231204+luochenglcs@users.noreply.github.com>
Date: Mon, 18 Mar 2024 00:09:21 +0800
Subject: [PATCH] clang: Fix file_exists_and_ownedby return value (#4935)
commit 008ea09 (clang: check header ownership) updates file_exists()
to file_exists_and_ownedby(), add verifies onwer, but the return value
is different from before, causing problems with the original code.
Signed-off-by: Chunsheng Luo <luochunsheng@ustc.edu>
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
src/cc/frontends/clang/kbuild_helper.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cc/frontends/clang/kbuild_helper.cc b/src/cc/frontends/clang/kbuild_helper.cc
index 1b291469..0387f872 100644
--- a/src/cc/frontends/clang/kbuild_helper.cc
+++ b/src/cc/frontends/clang/kbuild_helper.cc
@@ -143,8 +143,8 @@ int KBuildHelper::get_flags(const char *uname_machine, vector<string> *cflags) {
static inline int file_exists_and_ownedby(const char *f, uid_t uid)
{
struct stat buffer;
- int ret;
- if ((ret = stat(f, &buffer)) == 0) {
+ int ret = stat(f, &buffer) == 0;
+ if (ret) {
if (buffer.st_uid != uid) {
std::cout << "ERROR: header file ownership unexpected: " << std::string(f) << "\n";
return -1;
--
2.44.0