Benjamin Bannier created MESOS-8865:
---------------------------------------
Summary: Suspicious enum value comparisons in scheduler Java
bindings
Key: MESOS-8865
URL: https://issues.apache.org/jira/browse/MESOS-8865
Project: Mesos
Issue Type: Bug
Components: java api
Reporter: Benjamin Bannier
Clang reports suspicious comparisons of enum values in the scheduler Java
bindings,
{noformat}
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:563:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::SUBSCRIBE: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:576:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::TEARDOWN: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:581:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::ACCEPT: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:601:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::ACCEPT_INVERSE_OFFERS:
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:602:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::DECLINE_INVERSE_OFFERS:
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:603:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::SHUTDOWN: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:609:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::DECLINE: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:621:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::REVIVE: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:626:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::KILL: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:631:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::ACKNOWLEDGE: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:642:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::ACKNOWLEDGE_OPERATION_STATUS:
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:645:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::RECONCILE: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:660:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::RECONCILE_OPERATIONS:
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:663:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::MESSAGE: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:671:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::REQUEST: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:682:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::SUPPRESS: {
^
/home/bbannier/src/mesos/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp:687:10:
warning: comparison of two values with different enumeration types in switch
statement ('::mesos::scheduler::Call_Type' and 'const
mesos::v1::scheduler::Call::Type' (aka 'const
mesos::v1::scheduler::Call_Type')) [clang-diagnostic-enum-compare-switch]
case Call::UNKNOWN: {
^
{noformat}
While the current implementation might just work since the different enum
values might by accident map onto the same integer values (needs to be
confirmed), this seems brittle and against the type safety the languages
offers. We should fix this code.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)