Add a "strict" build config in //printing/BUILD.gn.
The strict config currently just enables -Wexit-time-destructors, just like in //pdf/BUILD.gn. The strict config is not applied to test code, where static initializers and exit-time destructors have traditionally been tolerated. Then fix code that triggers the new warning. Bug: 101600 Change-Id: Ief6002062c5c49744792d2adff417843b4f3b7c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4179674 Reviewed-by: Sparik Hayrapetyan <ust@google.com> Commit-Queue: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/main@{#1094535}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
04b4f43445
commit
d2dc378fc5
printing
@ -25,6 +25,10 @@ if (is_win || enable_print_preview) {
|
||||
"set enable_pdf=true.")
|
||||
}
|
||||
|
||||
config("strict") {
|
||||
configs = [ "//build/config/compiler:wexit_time_destructors" ]
|
||||
}
|
||||
|
||||
# Lower-dependency base printing files which are needed by both :printing and
|
||||
# //printing/backend without incurring deeper UI dependencies (e.g.,
|
||||
# //ui/accessibility). New files should normally be added to :printing, and
|
||||
@ -40,6 +44,9 @@ component("printing_base") {
|
||||
"units.cc",
|
||||
"units.h",
|
||||
]
|
||||
|
||||
configs += [ ":strict" ]
|
||||
|
||||
if (use_cups_ipp || is_chromeos) {
|
||||
sources += [
|
||||
"printer_query_result.h",
|
||||
@ -77,6 +84,9 @@ if (enable_oop_printing && (is_linux || is_chromeos)) {
|
||||
"sandbox/print_backend_sandbox_hook_linux.cc",
|
||||
"sandbox/print_backend_sandbox_hook_linux.h",
|
||||
]
|
||||
|
||||
configs += [ ":strict" ]
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//printing/buildflags",
|
||||
@ -98,6 +108,8 @@ if (enable_oop_printing && (is_linux || is_chromeos)) {
|
||||
source_set("native_drawing_context") {
|
||||
sources = [ "native_drawing_context.h" ]
|
||||
|
||||
configs += [ ":strict" ]
|
||||
|
||||
deps = [ "//base" ]
|
||||
}
|
||||
|
||||
@ -111,6 +123,8 @@ component("metafile") {
|
||||
"metafile_skia.h",
|
||||
]
|
||||
|
||||
configs += [ ":strict" ]
|
||||
|
||||
defines = [ "IS_PRINTING_METAFILE_IMPL" ]
|
||||
public_deps = [
|
||||
":native_drawing_context",
|
||||
@ -166,6 +180,8 @@ component("printing") {
|
||||
"pwg_raster_settings.h",
|
||||
]
|
||||
|
||||
configs += [ ":strict" ]
|
||||
|
||||
cflags = []
|
||||
defines = [ "IS_PRINTING_IMPL" ]
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "printing/client_info_helpers.h"
|
||||
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/types/optional_util.h"
|
||||
@ -20,9 +21,9 @@ bool ValidateClientType(mojom::IppClientInfo::ClientType type) {
|
||||
}
|
||||
|
||||
bool ValidateStringMember(const std::string* value, size_t max_length) {
|
||||
static const RE2 kStringRegex = "[a-zA-Z0-9_.-]*";
|
||||
static const base::NoDestructor<RE2> kStringRegex("[a-zA-Z0-9_.-]*");
|
||||
return value == nullptr ||
|
||||
(value->size() <= max_length && RE2::FullMatch(*value, kStringRegex));
|
||||
(value->size() <= max_length && RE2::FullMatch(*value, *kStringRegex));
|
||||
}
|
||||
|
||||
// Returns true if all members of `client_info` are valid.
|
||||
|
Reference in New Issue
Block a user