Use a callable type for ScopedFILE in settings_writer.cc
Newer glibc have an attribute((nonnull(1))) on fclose. Attributes aren't
part of the language, so decltype(fclose) lose the attribute. It seems
this causes std::unique_ptr<FILE, decltype(fclose)> to trip
-Wignored-attributes in GCC.
This is a bit aggressive of a warning, but work around this with a
custom deleter, which makes the unique_ptr object smaller anyway.
(Though the compiler can, I hope, dissolve all of this anyway.)
Fixed: 642
Change-Id: I9a0206a8c5675f856e80c5266c90be42d66a5606
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/62465
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/ssl/test/settings_writer.cc b/ssl/test/settings_writer.cc
index 8605222..78598a8 100644
--- a/ssl/test/settings_writer.cc
+++ b/ssl/test/settings_writer.cc
@@ -75,8 +75,11 @@
}
bssl::UniquePtr<uint8_t> free_settings(settings);
- using ScopedFILE = std::unique_ptr<FILE, decltype(&fclose)>;
- ScopedFILE file(fopen(path_.c_str(), "w"), fclose);
+ struct FileCloser {
+ void operator()(FILE *f) const { fclose(f); }
+ };
+ using ScopedFILE = std::unique_ptr<FILE, FileCloser>;
+ ScopedFILE file(fopen(path_.c_str(), "w"));
if (!file) {
return false;
}