Create a common wrapper function for stat(2) - #3030
Open
Databean wants to merge 2 commits into
Open
Conversation
3405691582
approved these changes
Aug 15, 2026
|
|
||
| Result<struct stat> Stat(const char* path) { | ||
| struct stat ret; | ||
| int success = TEMP_FAILURE_RETRY(stat(path, &ret)); |
Collaborator
There was a problem hiding this comment.
Optionally: TEMP_FAILURE_RETRY is a glibcism. Consider stuffing an ifndef define (x) for this somewhere for now?
Member
Author
There was a problem hiding this comment.
I tried making a dedicated header for this, i.e.
// temp_failure_retry.h
#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY(exp) ...
#endif(yeah not actually posix as you point out, location is arbitrary)
But the include-cleaner lint rejects it at the including file
error: included header temp_failure_retry.h is not used directly [misc-include-cleaner,-warnings-as-errors]
27 | #include "cuttlefish/posix/temp_failure_retry.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 | #include "cuttlefish/result/expect.h"
This can be worked around either at the include site
#include "cuttlefish/posix/temp_failure_retry.h" // IWYU pragma: keepor once within the header
#include <unistd.h> // IWYU pragma: exportGetting all the <unistd.h> symbols for temp_failure_retry.h is misleading, so I think the best I can do is putting a "cuttlefish unistd.h" somewhere, if you think that is an improvement. I've added this as a second commit.
This guarantees that TEMP_FAILURE_RETRY is called, and puts the error formatting text in a common place. Bug: b/546692445
This guarantees TEMP_FAILURE_RETRY is present, even without glibc. Bug: b/546692445
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This guarantees that TEMP_FAILURE_RETRY is called, and puts the error formatting text in a common place.
Bug: b/546692445