diff options
author | Gabriela Moldovan <gabi@torproject.org> | 2023-06-05 15:03:39 +0100 |
---|---|---|
committer | Gabriela Moldovan <gabi@torproject.org> | 2023-06-05 15:03:39 +0100 |
commit | 45ee8a10e292510a22b37a2adac1426cfe339350 (patch) | |
tree | bb621a044333cf2f52a4eb45611778b0db6bf474 | |
parent | d4f4fb6088cee8e577e28b52f0bd07b87d379ddc (diff) | |
download | tor-45ee8a10e292510a22b37a2adac1426cfe339350.tar.gz tor-45ee8a10e292510a22b37a2adac1426cfe339350.zip |
Fix compilation error on older gcc versions and MSVC.
This fixes an "initializer is not a constant" compilation error that manifests
itself on gcc versions < 8.1 and MSVC (see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69960#c18).
Fixes bug #40773
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
-rw-r--r-- | changes/ticket40773 | 4 | ||||
-rw-r--r-- | src/feature/hs/hs_metrics_entry.c | 16 |
2 files changed, 16 insertions, 4 deletions
diff --git a/changes/ticket40773 b/changes/ticket40773 new file mode 100644 index 0000000000..0f344220ea --- /dev/null +++ b/changes/ticket40773 @@ -0,0 +1,4 @@ + o Minor bugfixes (compilation): + - Fix "initializer is not a constant" compilation error that manifests + itself on gcc versions < 8.1 and MSVC. Fixes bug 40773; bugfix on + 0.4.8.1-alpha diff --git a/src/feature/hs/hs_metrics_entry.c b/src/feature/hs/hs_metrics_entry.c index 2268ba4c59..d862d0adec 100644 --- a/src/feature/hs/hs_metrics_entry.c +++ b/src/feature/hs/hs_metrics_entry.c @@ -28,8 +28,16 @@ static const int64_t hs_metrics_circ_build_time_buckets[] = 60000 /* 60s */ }; -static const size_t hs_metrics_circ_build_time_buckets_size = - ARRAY_LENGTH(hs_metrics_circ_build_time_buckets); +// TODO: Define a constant for ARRAY_LENGTH(hs_metrics_circ_build_time_buckets) +// and use where it applicable. +// +// This is commented out because it doesn't compile with gcc versions < 8.1 +// or with MSVC ("initializer element is not constant"). +// +// See ticket#40773 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69960#c18 +// +/*static const size_t hs_metrics_circ_build_time_buckets_size =*/ +/*ARRAY_LENGTH(hs_metrics_circ_build_time_buckets);*/ /** The base metrics that is a static array of metrics that are added to every * single new stores. @@ -93,7 +101,7 @@ const hs_metrics_entry_t base_metrics[] = .type = METRICS_TYPE_HISTOGRAM, .name = METRICS_NAME(hs_intro_circ_build_time), .buckets = hs_metrics_circ_build_time_buckets, - .bucket_count = hs_metrics_circ_build_time_buckets_size, + .bucket_count = ARRAY_LENGTH(hs_metrics_circ_build_time_buckets), .help = "The introduction circuit build time in milliseconds", }, { @@ -101,7 +109,7 @@ const hs_metrics_entry_t base_metrics[] = .type = METRICS_TYPE_HISTOGRAM, .name = METRICS_NAME(hs_rend_circ_build_time), .buckets = hs_metrics_circ_build_time_buckets, - .bucket_count = hs_metrics_circ_build_time_buckets_size, + .bucket_count = ARRAY_LENGTH(hs_metrics_circ_build_time_buckets), .help = "The rendezvous circuit build time in milliseconds", }, { |