@@ -1037,14 +1037,28 @@ int pack_complex_type(struct cmt_prometheus_remote_write_context *context,
10371037 add_metadata = CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_ADD_METADATA ;
10381038 result = CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS ;
10391039
1040- if (map -> type == CMT_SUMMARY ) {
1041- additional_label .name = (cfl_sds_t ) "quantile" ;
1042- }
1043- else if (map -> type == CMT_HISTOGRAM ) {
1044- additional_label .name = (cfl_sds_t ) "le" ;
1045- }
1040+ if (map -> type == CMT_SUMMARY || map -> type == CMT_HISTOGRAM ) {
1041+ if (map -> type == CMT_SUMMARY ) {
1042+ additional_label .name = (cfl_sds_t ) "quantile" ;
1043+ }
1044+ else if (map -> type == CMT_HISTOGRAM ) {
1045+ additional_label .name = (cfl_sds_t ) "le" ;
1046+ }
1047+
1048+ /*
1049+ * Suppress GCC/Clang warning for storing the address of a stack-allocated label in a list. We are
1050+ * safe here because the label is removed before function exit.
1051+ *
1052+ * This avoids a -Wdangling-pointer false positive.
1053+ */
1054+ #pragma GCC diagnostic push
1055+ #pragma GCC diagnostic ignored "-Wdangling-pointer"
1056+
10461057
1047- cfl_list_add (& additional_label ._head , & map -> label_keys );
1058+ cfl_list_add (& additional_label ._head , & map -> label_keys );
1059+
1060+ #pragma GCC diagnostic pop
1061+ }
10481062
10491063 if (map -> metric_static_set == CMT_TRUE ) {
10501064 result = pack_complex_metric_sample (context , map , & map -> metric , add_metadata );
@@ -1064,8 +1078,7 @@ int pack_complex_type(struct cmt_prometheus_remote_write_context *context,
10641078 }
10651079 }
10661080
1067- if (map -> type == CMT_SUMMARY ||
1068- map -> type == CMT_HISTOGRAM ) {
1081+ if (map -> type == CMT_SUMMARY || map -> type == CMT_HISTOGRAM ) {
10691082 cfl_list_del (& additional_label ._head );
10701083 }
10711084
0 commit comments