Suppress null-dereference warning temporarily
There's one more occurance of this warning.
In file included from hardware/google/av/codec2/tests/C2SampleComponent_test.cpp:23:
In file included from frameworks/av/media/codec2/core/include/C2Component.h:29:
In file included from frameworks/av/media/codec2/core/include/C2Enum.h:20:
frameworks/av/media/codec2/core/include/C2Param.h:1612:92: error: binding dereferenced null pointer to reference has undefined behavior [-Werror,-Wnull-dereference]
C2FieldDescriptor::NamedValuesType named = C2FieldDescriptor::namedValuesFor(*(T*)0);
^~~~~~
Also modernised the code to use nullptr instead of 0.
Bug: 122154294
Test: m checkbuild
Exempt-From-Owner-Approval: No functionality change, similar CL already reviewed by owner
Change-Id: Ieec3335d2f52f0c6f07be1e7c99e4f36c882dabf
diff --git a/media/codec2/core/include/C2Param.h b/media/codec2/core/include/C2Param.h
index bedd01b..efc5c89 100644
--- a/media/codec2/core/include/C2Param.h
+++ b/media/codec2/core/include/C2Param.h
@@ -1605,11 +1605,13 @@
/// \internal
/// \todo: create separate values vs. flags initializer as for flags we want
/// to list both allowed and required flags
- template<typename T, typename E=decltype(C2FieldDescriptor::namedValuesFor(*(T*)0))>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnull-dereference"
+ template<typename T, typename E=decltype(C2FieldDescriptor::namedValuesFor(*(T*)nullptr))>
C2FieldSupportedValues(bool flags, const T*)
: type(flags ? FLAGS : VALUES),
range{(T)0, (T)0, (T)0, (T)0, (T)0} {
- C2FieldDescriptor::NamedValuesType named = C2FieldDescriptor::namedValuesFor(*(T*)0);
+ C2FieldDescriptor::NamedValuesType named = C2FieldDescriptor::namedValuesFor(*(T*)nullptr);
if (flags) {
values.emplace_back(0); // min-mask defaults to 0
}
@@ -1618,6 +1620,7 @@
}
}
};
+#pragma GCC diagnostic pop
/**
* Supported values for a specific field.