Skip to content

fix enum-compare-switch warning #1832

@flier

Description

@flier

Steps to reproduce
Build with clang-13 @ macosx

clang -v
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

What is the expected behavior?
no compile warning

What is the actual behavior?
a lot of enum-compare-switch warning

$ ninja
[1/2] Building CXX object exporters/otlp/CMakeFiles/opentelemetry_exporter_otlp_grpc_client.dir/src/otlp_grpc_utils.cc.o
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:53:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_DATA_LOSS:
         ^~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:51:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_UNAVAILABLE:
         ^~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:49:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_INTERNAL:
         ^~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:47:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_UNIMPLEMENTED:
         ^~~~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:45:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_OUT_OF_RANGE:
         ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:43:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_ABORTED:
         ^~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:41:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_FAILED_PRECONDITION:
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:39:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_RESOURCE_EXHAUSTED:
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:37:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_UNAUTHENTICATED:
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:35:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_PERMISSION_DENIED:
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:33:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_ALREADY_EXISTS:
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:31:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_NOT_FOUND:
         ^~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:29:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_DEADLINE_EXCEEDED:
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:27:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_INVALID_ARGUMENT:
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:25:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_UNKNOWN:
         ^~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:23:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_CANCELLED:
         ^~~~~~~~~~~~~~~~~~~~~
/Users/flier/github/opentelemetry-cpp/exporters/otlp/src/otlp_grpc_utils.cc:21:10: warning: comparison of different enumeration types in switch statement ('::grpc::StatusCode' and 'grpc_status_code') [-Wenum-compare-switch]
    case GRPC_STATUS_OK:
         ^~~~~~~~~~~~~~
17 warnings generated.
[2/2] Linking CXX static library exporters/otlp/libopentelemetry_exporter_otlp_grpc_client.a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions