mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[1/N] Enable Wunused-result and Wunused-variable in torch targets (#110722)
They are useful for checking results of function calls. Pull Request resolved: https://github.com/pytorch/pytorch/pull/110722 Approved by: https://github.com/Skylion007
This commit is contained in:
@ -38,7 +38,8 @@ void start_manager() {
|
||||
std::string msg("ERROR: execl failed: ");
|
||||
msg += std::strerror(errno);
|
||||
msg += '\n';
|
||||
write(1, msg.c_str(), msg.size());
|
||||
auto res = write(1, msg.c_str(), msg.size());
|
||||
(void)res;
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
@ -54,9 +54,19 @@ void unregister_fd(int fd) {
|
||||
client_sessions.erase(fd);
|
||||
}
|
||||
|
||||
void print_init_message(const char* message) {
|
||||
write(1, message, strlen(message));
|
||||
write(1, "\n", 1);
|
||||
void print_init_message(std::string_view message) {
|
||||
ssize_t written_bytes = -1;
|
||||
while (!message.empty()) {
|
||||
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
|
||||
SYSCHECK_ERR_RETURN_NEG1(
|
||||
written_bytes = write(1, message.data(), message.size()));
|
||||
message.remove_prefix(written_bytes);
|
||||
}
|
||||
written_bytes = 0;
|
||||
while (written_bytes != 1) {
|
||||
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
|
||||
SYSCHECK_ERR_RETURN_NEG1(written_bytes = write(1, "\n", 1));
|
||||
}
|
||||
}
|
||||
|
||||
bool object_exists(const char* name) {
|
||||
@ -111,10 +121,10 @@ int main(int argc, char* argv[]) {
|
||||
std::vector<int> to_add;
|
||||
std::vector<int> to_remove;
|
||||
for (;;) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
||||
int nevents;
|
||||
int nevents = -1;
|
||||
if (client_sessions.empty())
|
||||
timeout = SHUTDOWN_TIMEOUT;
|
||||
// NOLINTNEXTLINE(bugprone-assignment-in-if-condition)
|
||||
SYSCHECK_ERR_RETURN_NEG1(
|
||||
nevents = poll(pollfds.data(), pollfds.size(), timeout));
|
||||
timeout = -1;
|
||||
|
Reference in New Issue
Block a user