diff options
author | Oliver Smith <osmith@sysmocom.de> | 2022-11-11 15:44:52 +0100 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2022-11-14 09:52:14 +0100 |
commit | 48c038d3992a41ac96e43feae27be8a454506634 (patch) | |
tree | 1d3693842da85de5ec448bf80978f8bd1b56b40c /asn1 | |
parent | 0c04a7e03f2c757cc0d5eebeb5ea501835712cc3 (diff) |
asn1: fix visibility warnings from generated code
Fix warnings from generated asn1 code in order to build osmo-iuh with
werror in a future patch:
../../include/osmocom/hnbap/HNBAP_CriticalityDiagnostics-IE-List.h:29:23: error: ‘struct HNBAP_CriticalityDiagnostics_IE_List__Member’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
These visibility warnings come from "SEQUENCE … OF SEQUENCE" definitions
in the asn1 source files, as described in detail here:
https://github.com/vlm/asn1c/issues/430
It is not possible to tell gcc to just ignore these warnings since they
don't have their own type (unlike e.g. -Wuninitialized). Also it seems
like a huge effort to patch this in asn1c.
So work around the problem the same way the author of the issue worked
around it by rewriting the lines to "SEQUENCE … OF …-Value" and adding
a "…-Value ::= SEQUENCE" line below. Add a script in
asn1/utils/asn1_restructure_sequence_of_sequence.py for the
transformation and apply it.
Related: OS#4462
Change-Id: If84445ed2e0df604b581684dcf83f8520b7da84c
Diffstat (limited to 'asn1')
-rw-r--r-- | asn1/hnbap/HNBAP-IEs.asn | 3 | ||||
-rw-r--r-- | asn1/ranap/RANAP-IEs.asn | 27 | ||||
-rw-r--r-- | asn1/ranap/RANAP-PDU-Contents.asn | 12 | ||||
-rw-r--r-- | asn1/ranap/RANAP-PDU.asn | 12 | ||||
-rw-r--r-- | asn1/rua/RUA-IEs.asn | 3 | ||||
-rw-r--r-- | asn1/sabp/SABP-IEs.asn | 6 | ||||
-rwxr-xr-x | asn1/utils/asn1_restructure_sequence_of_sequence.py | 57 |
7 files changed, 99 insertions, 21 deletions
diff --git a/asn1/hnbap/HNBAP-IEs.asn b/asn1/hnbap/HNBAP-IEs.asn index 775d25b..2500379 100644 --- a/asn1/hnbap/HNBAP-IEs.asn +++ b/asn1/hnbap/HNBAP-IEs.asn @@ -127,7 +127,8 @@ CriticalityDiagnostics ::= SEQUENCE { ... } -CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF +CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF CriticalityDiagnostics-IE-List-Value +CriticalityDiagnostics-IE-List-Value ::= SEQUENCE { iECriticality Criticality, iE-ID ProtocolIE-ID, diff --git a/asn1/ranap/RANAP-IEs.asn b/asn1/ranap/RANAP-IEs.asn index 843ec8d..595e6b6 100644 --- a/asn1/ranap/RANAP-IEs.asn +++ b/asn1/ranap/RANAP-IEs.asn @@ -265,7 +265,8 @@ Ass-RAB-Parameter-GuaranteedBitrateList ::= SEQUENCE (SIZE (1..maxNrOfSeparateTr Ass-RAB-Parameter-MaxBitrateList ::= SEQUENCE (SIZE (1..maxNrOfSeparateTrafficDirections)) OF MaxBitrate -AuthorisedPLMNs ::= SEQUENCE (SIZE (1..maxNrOfPLMNsSN)) OF +AuthorisedPLMNs ::= SEQUENCE (SIZE (1..maxNrOfPLMNsSN)) OF AuthorisedPLMNs-Value +AuthorisedPLMNs-Value ::= SEQUENCE { pLMNidentity PLMNidentity, authorisedSNAsList AuthorisedSNAs OPTIONAL, @@ -479,7 +480,8 @@ CriticalityDiagnostics ::= SEQUENCE { ... } -CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF +CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF CriticalityDiagnostics-IE-List-Value +CriticalityDiagnostics-IE-List-Value ::= SEQUENCE { iECriticality Criticality, iE-ID ProtocolIE-ID, @@ -488,7 +490,8 @@ CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF ... } -MessageStructure ::= SEQUENCE (SIZE (1..maxNrOfLevels)) OF +MessageStructure ::= SEQUENCE (SIZE (1..maxNrOfLevels)) OF MessageStructure-Value +MessageStructure-Value ::= SEQUENCE { iE-ID ProtocolIE-ID, repetitionNumber RepetitionNumber1 OPTIONAL, @@ -753,7 +756,8 @@ GA-PointWithUnCertaintyEllipse ::= SEQUENCE { ... } -GA-Polygon ::= SEQUENCE (SIZE (1..maxNrOfPoints)) OF +GA-Polygon ::= SEQUENCE (SIZE (1..maxNrOfPoints)) OF GA-Polygon-Value +GA-Polygon-Value ::= SEQUENCE { geographicalCoordinates GeographicalCoordinates, iE-Extensions IE-Extensions OPTIONAL, @@ -923,7 +927,8 @@ KeyStatus ::= ENUMERATED { } -- L -LA-LIST ::= SEQUENCE (SIZE (1..maxNrOfLAs)) OF +LA-LIST ::= SEQUENCE (SIZE (1..maxNrOfLAs)) OF LA-LIST-Value +LA-LIST-Value ::= SEQUENCE { lAC LAC, listOF-SNAs ListOF-SNAs, @@ -1336,7 +1341,8 @@ LoggingDuration ::= ENUMERATED { PLMNidentity ::= OCTET STRING (SIZE (3)) -PLMNs-in-shared-network ::= SEQUENCE (SIZE (1..maxNrOfPLMNsSN)) OF +PLMNs-in-shared-network ::= SEQUENCE (SIZE (1..maxNrOfPLMNsSN)) OF PLMNs-in-shared-network-Value +PLMNs-in-shared-network-Value ::= SEQUENCE { pLMNidentity PLMNidentity, lA-LIST LA-LIST, @@ -1414,7 +1420,8 @@ RABased ::= SEQUENCE { RAI-List ::= SEQUENCE (SIZE (1..maxNrOfRAIs)) OF RAI -RABDataVolumeReport ::= SEQUENCE (SIZE (1..maxNrOfVol)) OF +RABDataVolumeReport ::= SEQUENCE (SIZE (1..maxNrOfVol)) OF RABDataVolumeReport-Value +RABDataVolumeReport-Value ::= SEQUENCE { dl-UnsuccessfullyTransmittedDataVolume UnsuccessfullyTransmittedDataVolume, dataVolumeReference DataVolumeReference OPTIONAL, @@ -1456,7 +1463,8 @@ RAB-Parameters ::= SEQUENCE { ... } -RABParametersList ::= SEQUENCE (SIZE (1.. maxNrOfRABs)) OF SEQUENCE { +RABParametersList ::= SEQUENCE (SIZE (1.. maxNrOfRABs)) OF RABParametersList-Value +RABParametersList-Value ::= SEQUENCE { rab-Id RAB-ID, cn-domain CN-DomainIndicator, rabDataVolumeReport RABDataVolumeReport OPTIONAL, @@ -1848,7 +1856,8 @@ RSRQ-Type ::= SEQUENCE { RSRQ-Extension ::= INTEGER (-30..46, ...) -EUTRANFrequencies ::= SEQUENCE (SIZE (1..maxNrOfEUTRAFreqs)) OF SEQUENCE { +EUTRANFrequencies ::= SEQUENCE (SIZE (1..maxNrOfEUTRAFreqs)) OF EUTRANFrequencies-Value +EUTRANFrequencies-Value ::= SEQUENCE { earfcn INTEGER (0..65535), measBand MeasBand OPTIONAL, iE-Extensions IE-Extensions OPTIONAL} diff --git a/asn1/ranap/RANAP-PDU-Contents.asn b/asn1/ranap/RANAP-PDU-Contents.asn index 75aeaeb..199f6b1 100644 --- a/asn1/ranap/RANAP-PDU-Contents.asn +++ b/asn1/ranap/RANAP-PDU-Contents.asn @@ -780,7 +780,8 @@ CNMBMSLinkingInformation-ExtIEs RANAP-PROTOCOL-EXTENSION ::= { ... } -JoinedMBMSBearerService-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF +JoinedMBMSBearerService-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF JoinedMBMSBearerService-IEs-Value +JoinedMBMSBearerService-IEs-Value ::= SEQUENCE { tMGI TMGI, mBMS-PTP-RAB-ID MBMS-PTP-RAB-ID, @@ -2301,7 +2302,8 @@ RAB-ReleasedItem-ExtIEs RANAP-PROTOCOL-EXTENSION ::= { ... } -DataVolumeList ::= SEQUENCE (SIZE (1..maxNrOfVol)) OF +DataVolumeList ::= SEQUENCE (SIZE (1..maxNrOfVol)) OF DataVolumeList-Value +DataVolumeList-Value ::= SEQUENCE { dl-UnsuccessfullyTransmittedDataVolume UnsuccessfullyTransmittedDataVolume, dataVolumeReference DataVolumeReference OPTIONAL, @@ -3210,7 +3212,8 @@ MBMSUELinkingRequestIEs RANAP-PROTOCOL-IES ::= { ... } -LeftMBMSBearerService-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF +LeftMBMSBearerService-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF LeftMBMSBearerService-IEs-Value +LeftMBMSBearerService-IEs-Value ::= SEQUENCE { tMGI TMGI, iE-Extensions ProtocolExtensionContainer { {LeftMBMSBearerService-ExtIEs} } OPTIONAL, @@ -3243,7 +3246,8 @@ MBMSUELinkingResponseIEs RANAP-PROTOCOL-IES ::= { ... } -UnsuccessfulLinking-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF +UnsuccessfulLinking-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF UnsuccessfulLinking-IEs-Value +UnsuccessfulLinking-IEs-Value ::= SEQUENCE { tMGI TMGI, cause Cause, diff --git a/asn1/ranap/RANAP-PDU.asn b/asn1/ranap/RANAP-PDU.asn index cce2689..b8de7a8 100644 --- a/asn1/ranap/RANAP-PDU.asn +++ b/asn1/ranap/RANAP-PDU.asn @@ -735,7 +735,8 @@ CNMBMSLinkingInformation ::= SEQUENCE { ... } -JoinedMBMSBearerService-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF +JoinedMBMSBearerService-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF JoinedMBMSBearerService-IEs-Value +JoinedMBMSBearerService-IEs-Value ::= SEQUENCE { tMGI TMGI, mBMS-PTP-RAB-ID MBMS-PTP-RAB-ID, @@ -885,7 +886,8 @@ RAB-ReleasedItem ::= SEQUENCE { ... } -DataVolumeList ::= SEQUENCE (SIZE (1..maxNrOfVol)) OF +DataVolumeList ::= SEQUENCE (SIZE (1..maxNrOfVol)) OF DataVolumeList-Value +DataVolumeList-Value ::= SEQUENCE { dl-UnsuccessfullyTransmittedDataVolume UnsuccessfullyTransmittedDataVolume, dataVolumeReference DataVolumeReference OPTIONAL, @@ -1004,14 +1006,16 @@ MBMSSynchronisationInformation ::= SEQUENCE { ... } -LeftMBMSBearerService-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF +LeftMBMSBearerService-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF LeftMBMSBearerService-IEs-Value +LeftMBMSBearerService-IEs-Value ::= SEQUENCE { tMGI TMGI, iE-Extensions ProtocolExtensionContainer OPTIONAL, ... } -UnsuccessfulLinking-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF +UnsuccessfulLinking-IEs ::= SEQUENCE (SIZE (1.. maxnoofMulticastServicesPerUE)) OF UnsuccessfulLinking-IEs-Value +UnsuccessfulLinking-IEs-Value ::= SEQUENCE { tMGI TMGI, cause Cause, diff --git a/asn1/rua/RUA-IEs.asn b/asn1/rua/RUA-IEs.asn index 1e43580..6a16d2d 100644 --- a/asn1/rua/RUA-IEs.asn +++ b/asn1/rua/RUA-IEs.asn @@ -165,7 +165,8 @@ CriticalityDiagnostics ::= SEQUENCE { ... } -CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF +CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF CriticalityDiagnostics-IE-List-Value +CriticalityDiagnostics-IE-List-Value ::= SEQUENCE { iECriticality Criticality, iE-ID ProtocolIE-ID, diff --git a/asn1/sabp/SABP-IEs.asn b/asn1/sabp/SABP-IEs.asn index 0efd14e..0aff040 100644 --- a/asn1/sabp/SABP-IEs.asn +++ b/asn1/sabp/SABP-IEs.asn @@ -75,7 +75,8 @@ Criticality-Diagnostics ::= SEQUENCE { CriticalityDiagnostics-ExtIEs SABP-PROTOCOL-EXTENSION ::= { ... } -CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF +CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF CriticalityDiagnostics-IE-List-Value +CriticalityDiagnostics-IE-List-Value ::= SEQUENCE { iECriticality Criticality, iE-ID ProtocolIE-ID, @@ -88,7 +89,8 @@ CriticalityDiagnostics-IE-List-ExtIEs SABP-PROTOCOL-EXTENSION ::= { -- { ID id-TypeOfError CRITICALITY ignore EXTENSION TypeOfError PRESENCE mandatory }, ... } -MessageStructure ::= SEQUENCE (SIZE (1..maxNrOfLevels)) OF +MessageStructure ::= SEQUENCE (SIZE (1..maxNrOfLevels)) OF MessageStructure-Value +MessageStructure-Value ::= SEQUENCE { iE-ID ProtocolIE-ID, repetitionNumber RepetitionNumber1 OPTIONAL, diff --git a/asn1/utils/asn1_restructure_sequence_of_sequence.py b/asn1/utils/asn1_restructure_sequence_of_sequence.py new file mode 100755 index 0000000..85b2e6a --- /dev/null +++ b/asn1/utils/asn1_restructure_sequence_of_sequence.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: AGPL-3.0-or-later +# Copyright 2022 sysmocom - s.f.m.c. GmbH <info@sysmocom.de> +""" +Avoid compiler warnings like "‘struct HNBAP_CriticalityDiagnostics_IE_List__Member’ +declared inside parameter list will not be visible outside of this definition +or declaration", which break compiling the sources with -Werror and can't be +ignored with diagnostics as they don't have their own type (unlike e.g. +-Wuninitialized). + +This problem is explained further in: +https://github.com/vlm/asn1c/issues/430 + +To avoid this, convert "SQUENCE … OF SEQUENCE" like here: + + CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF + SEQUENCE { + … +to "SEQUENCE … OF …-Value" and below that "…-Value ::= SEQUENCE": + + CriticalityDiagnostics-IE-List ::= SEQUENCE (SIZE (1..maxNrOfErrors)) OF CriticalityDiagnostics-IE-List-Value + CriticalityDiagnostics-IE-List-Value ::= + SEQUENCE { + … +""" +import glob +import re + +re_seq_of = re.compile("([A-Za-z0-0-]*)\s*::=\s*SEQUENCE .* OF$") +re_seq_of2 = re.compile("([A-Za-z0-0-]*)\s*::=\s*SEQUENCE .* OF SEQUENCE\s*{$") + +for file in glob.glob("asn1/*/*.asn"): + print(f"{file}:") + with open(file) as handle: + lines = handle.readlines() + + for i, line in enumerate(lines): + match = re_seq_of.search(line) + if match and "SEQUENCE" in lines[i + 1]: + name_value = f"{match.group(1)}-Value" + print(f" {name_value}") + lines[i] = f"{line.rstrip()} {name_value}\n{name_value} ::=\n" + continue + + match = re_seq_of2.search(line) + if match: + name_value = f"{match.group(1)}-Value" + print(f" {name_value}") + line = line.split(" OF SEQUENCE")[0] + lines[i] = f"{line} OF {name_value}\n{name_value} ::= SEQUENCE {{\n" + continue + + with open(file, "w") as handle: + handle.writelines(lines) + + +print("Done") |