mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-10 21:20:07 +00:00
Fix Coverity warnings
This commit is contained in:
parent
0eac037416
commit
c4d0bc1ac9
@ -34,6 +34,7 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <climits>
|
||||
#include <memory>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <io.h>
|
||||
@ -247,11 +248,11 @@ TEST(FileTest, OpenRetry) {
|
||||
TEST(FileTest, CloseNoRetryInDtor) {
|
||||
File read_end, write_end;
|
||||
File::pipe(read_end, write_end);
|
||||
File *f = new File(std::move(read_end));
|
||||
std::auto_ptr<File> f(new File(std::move(read_end)));
|
||||
int saved_close_count = 0;
|
||||
EXPECT_WRITE(stderr, {
|
||||
close_count = 1;
|
||||
delete f;
|
||||
f.reset();
|
||||
saved_close_count = close_count;
|
||||
close_count = 0;
|
||||
}, format_system_error(EINTR, "cannot close file") + "\n");
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#include "gtest-extra.h"
|
||||
#include "posix.h"
|
||||
@ -136,14 +137,14 @@ TEST(BufferedFileTest, CloseFileInDtor) {
|
||||
}
|
||||
|
||||
TEST(BufferedFileTest, CloseErrorInDtor) {
|
||||
BufferedFile *f = new BufferedFile(open_buffered_file());
|
||||
std::auto_ptr<BufferedFile> f(new BufferedFile(open_buffered_file()));
|
||||
EXPECT_WRITE(stderr, {
|
||||
// The close function must be called inside EXPECT_WRITE, otherwise
|
||||
// the system may recycle closed file descriptor when redirecting the
|
||||
// output in EXPECT_STDERR and the second close will break output
|
||||
// redirection.
|
||||
FMT_POSIX(close(f->fileno()));
|
||||
SUPPRESS_ASSERT(delete f);
|
||||
SUPPRESS_ASSERT(f.reset());
|
||||
}, format_system_error(EBADF, "cannot close file") + "\n");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user