You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2024/01/09 02:35:45 UTC
(arrow) branch main updated: GH-39385: [C++] Use more permissable return code for rename (#39481)
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new b101c014d7 GH-39385: [C++] Use more permissable return code for rename (#39481)
b101c014d7 is described below
commit b101c014d7d332760cddc323df7d084fbd497006
Author: Anja Kefala <an...@voltrondata.com>
AuthorDate: Mon Jan 8 18:35:32 2024 -0800
GH-39385: [C++] Use more permissable return code for rename (#39481)
### Rationale for this change
While the `rename` [system call](https://man7.org/linux/man-pages/man2/rename.2.html) and [Posix standard](https://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html) do specify that a return value of -1 is expected for error calls, the [C++ reference](https://en.cppreference.com/w/cpp/io/c/rename) specifies that a "non-zero" is returned upon error.
This PR proposes changing to the more encompassing "non-zero" check for `std::rename`.
### Are these changes tested?
There are existing tests: https://github.com/apache/arrow/blob/afb40a9f5a33802897e1d5bae8305c81da7beee1/cpp/src/arrow/filesystem/filesystem_test.cc#L701C3-L701C3
* Closes: #39385
Authored-by: anjakefala <an...@voltrondata.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
cpp/src/arrow/filesystem/localfs.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cpp/src/arrow/filesystem/localfs.cc b/cpp/src/arrow/filesystem/localfs.cc
index d440629a02..01ac946379 100644
--- a/cpp/src/arrow/filesystem/localfs.cc
+++ b/cpp/src/arrow/filesystem/localfs.cc
@@ -595,7 +595,7 @@ Status LocalFileSystem::Move(const std::string& src, const std::string& dest) {
"' to '", dfn.ToString(), "'");
}
#else
- if (rename(sfn.ToNative().c_str(), dfn.ToNative().c_str()) == -1) {
+ if (rename(sfn.ToNative().c_str(), dfn.ToNative().c_str()) != 0) {
return IOErrorFromErrno(errno, "Failed renaming '", sfn.ToString(), "' to '",
dfn.ToString(), "'");
}