Commit a9256ded authored by Cedric Roux's avatar Cedric Roux

Fix asn1c warnings.

The strategy is rather basic. Files with warnings are replaced
by an edited copy that triggers no warning.

We take care to check that the replaced file is the same as the
one that was analyzed at the time of warning removal (through
checking its SHA1).

There is a new bash script "fix_asn1" in cmake_targets/tools
and the files replacing the existing ones are in
cmake_targets/tools/fix_asn1.data.
parent f65b478c
......@@ -247,6 +247,7 @@ endif (${RTAI})
# New C code source file, cmake must be re-run (instead of re-running make only)
#############
set(asn1c_call "${OPENAIR_CMAKE}/tools/generate_asn1")
set(fix_asn1c_call "${OPENAIR_CMAKE}/tools/fix_asn1")
set(asn1_generated_dir ${OPENAIR_BIN_DIR})
set(protoc_call "${OPENAIR_CMAKE}/tools/generate_protobuf")
......@@ -269,6 +270,15 @@ if(NOT EXISTS ${asn1c_call})
message( FATAL_ERROR "The script ${asn1c_call} must be present" )
endif(NOT EXISTS ${asn1c_call})
execute_process(COMMAND ${asn1c_call} ${RRC_FULL_DIR} ${RRC_GRAMMAR})
if(NOT EXISTS ${fix_asn1c_call})
message( FATAL_ERROR "The script ${fix_asn1c_call} must be present" )
endif(NOT EXISTS ${fix_asn1c_call})
execute_process(
COMMAND ${fix_asn1c_call} ${RRC_FULL_DIR} RRC ${RRC_ASN1_VERSION}
RESULT_VARIABLE ret)
if (NOT ${ret} STREQUAL 0)
message(FATAL_ERROR "${fix_asn1c_call}: error")
endif (NOT ${ret} STREQUAL 0)
file(GLOB rrc_source ${RRC_FULL_DIR}/*.c)
set(rrc_source ${rrc_source} ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1_msg.c)
file(GLOB rrc_h ${RRC_FULL_DIR}/*.h)
......@@ -282,6 +292,7 @@ include_directories ("${RRC_FULL_DIR}")
add_custom_command (
OUTPUT ${RRC_FULL_DIR}/asn1_constants.h
COMMAND ${asn1c_call} ${RRC_FULL_DIR} ${RRC_GRAMMAR}
COMMAND ${fix_asn1c_call} ${RRC_FULL_DIR} RRC ${RRC_ASN1_VERSION}
DEPENDS ${RRC_GRAMMAR}
)
......@@ -311,6 +322,12 @@ set(S1AP_ASN_FILES
set(S1AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR})
#message("calling ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}")
execute_process(COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES})
execute_process(
COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION}
RESULT_VARIABLE ret)
if (NOT ${ret} STREQUAL 0)
message(FATAL_ERROR "${fix_asn1c_call}: error")
endif (NOT ${ret} STREQUAL 0)
file(GLOB S1AP_source ${S1AP_C_DIR}/*.c)
set(S1AP_OAI_generated
......@@ -326,6 +343,7 @@ add_custom_command (
OUTPUT ${S1AP_OAI_generated}
COMMAND ${asn1c_call} ${S1AP_C_DIR} ${S1AP_ASN_FILES}
COMMAND python ${S1AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f${S1AP_ASN_DIR}/S1AP-PDU-Contents.asn -o${S1AP_C_DIR}
COMMAND ${fix_asn1c_call} ${S1AP_C_DIR} S1AP ${S1AP_VERSION}
DEPENDS ${S1AP_ASN_FILES}
)
add_library(S1AP_LIB
......@@ -378,6 +396,12 @@ set(X2AP_ASN_FILES
set(X2AP_C_DIR ${asn1_generated_dir}/${ASN1RELDIR})
#message("calling ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}")
execute_process(COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES})
execute_process(
COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION}
RESULT_VARIABLE ret)
if (NOT ${ret} STREQUAL 0)
message(FATAL_ERROR "${fix_asn1c_call}: error")
endif (NOT ${ret} STREQUAL 0)
file(GLOB X2AP_source ${X2AP_C_DIR}/*.c)
set(X2AP_OAI_generated
......@@ -394,6 +418,7 @@ add_custom_command (
OUTPUT ${X2AP_OAI_generated}
COMMAND ${asn1c_call} ${X2AP_C_DIR} ${X2AP_ASN_FILES}
COMMAND python ${X2AP_DIR}/MESSAGES/ASN1/asn1tostruct.py -f ${X2AP_ASN_DIR}/X2AP-PDU-Contents.asn -o ${X2AP_C_DIR}
COMMAND ${fix_asn1c_call} ${X2AP_C_DIR} X2AP ${X2AP_VERSION}
DEPENDS ${X2AP_ASN_FILES}
)
......
#!/bin/bash
# in those arrays, each line is:
# <file> <sha1sum of file> <replacement file>
RRC_Rel10=(
"SystemInformation-r8-IEs.h" 819eda3db27516f7c6780d832fb3c462e2264ea7 "fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h"
)
X2AP_Rel11_2=(
"X2ap-CriticalityDiagnostics-IE-List.h" f0e2414992bfacfbc4b9fd15c977241d6d7fabeb "fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h"
"NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/X2AP.rel11.2/NativeInteger.c"
"constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/X2AP.rel11.2/constr_SET_OF.c"
)
S1AP_Rel10_5=(
"NativeInteger.c" e23034083a0fb9d4a2e523e2a64286161e621f27 "fix_asn1.data/S1AP.rel10.5/NativeInteger.c"
"constr_SET_OF.c" 5fb65da648a57ea61f008fa226b707cf343c1c0c "fix_asn1.data/S1AP.rel10.5/constr_SET_OF.c"
)
red_color="\x1b[31m"
green_color="\x1b[32m"
reset_color="\x1b[0m"
function error()
{
echo -e "$red_color"ERROR: "$@""$reset_color"
exit 1
}
function check_sha1()
{
local file="$1"
local target_sha1="$2"
if [ ! -f "$file" ]
then
error "$file: no such file"
fi
local computed_sha1=$(sha1sum "$file" | cut -f 1 -d ' ')
if [ "$target_sha1" != "$computed_sha1" ]
then
error "$file: wrong SHA1"
fi
}
function copy_file()
{
local file="$1"
local destination="$2"
echo -e "$green_color""copy file $OPENAIR_DIR/cmake_targets/tools/$file to $destination""$reset_color"
cp -f "$OPENAIR_DIR/cmake_targets/tools/$file" "$destination"
if [ $? -ne 0 ]
then
error "copy of $file to $destination failed"
fi
}
function patch()
{
local directory="$1"
local array=$2
local len=$3 # the length could be computed locally but the way to do it is not clear to me [CROUX]
local i
local file
local sha1
local replace
local item
for (( i = 0; i < $len; i += 3 ))
do
# special bash syntax to access the array
item=$array[$i]; file=${!item}
item=$array[$((i+1))]; sha1=${!item}
item=$array[$((i+2))]; replace=${!item}
check_sha1 "$directory/$file" "$sha1"
copy_file "$replace" "$directory"
done
}
function patch_rrc()
{
local directory="$1"
local version="$2"
case "$version" in
Rel10 )
echo "patching RRC files release 10"
patch "$directory" RRC_Rel10 ${#RRC_Rel10[*]}
;;
* )
error unknwon/unhandled RRC version \'"$version"\'
;;
esac
}
function patch_x2ap()
{
local directory="$1"
local version="$2"
case "$version" in
R11 )
echo "patching X2AP files release 11.2"
patch "$directory" X2AP_Rel11_2 ${#X2AP_Rel11_2[*]}
;;
* )
error unknwon/unhandled X2AP version \'"$version"\'
;;
esac
}
function patch_s1ap()
{
local directory="$1"
local version="$2"
case "$version" in
R10 )
echo "patching S1AP files release 10.5"
patch "$directory" S1AP_Rel10_5 ${#S1AP_Rel10_5[*]}
;;
* )
error unknwon/unhandled S1AP version \'"$version"\'
;;
esac
}
function main()
{
if [ $# -ne 3 ]
then
echo "ERROR: pass <output directory> <module> <version>"
exit 1
fi
if [ x"$OPENAIR_DIR" = x ]
then
error "the variable OPENAIR_DIR is not set"
fi
local directory="$1"
local module="$2"
local version="$3"
case "$module" in
RRC )
patch_rrc "$directory" "$version"
;;
X2AP )
patch_x2ap "$directory" "$version"
;;
S1AP )
patch_s1ap "$directory" "$version"
;;
* )
error unknown module "$module"
;;
esac
exit 0
}
main "$@"
/*
* Generated by asn1c-0.9.24 (http://lionet.info/asn1c)
* From ASN.1 module "EUTRA-RRC-Definitions"
* found in "fixed_grammar.asn"
* `asn1c -gen-PER`
*/
#ifndef _SystemInformation_r8_IEs_H_
#define _SystemInformation_r8_IEs_H_
#include <asn_application.h>
/* Including external dependencies */
#include <asn_SEQUENCE_OF.h>
#include "SystemInformationBlockType2.h"
#include "SystemInformationBlockType3.h"
#include "SystemInformationBlockType4.h"
#include "SystemInformationBlockType5.h"
#include "SystemInformationBlockType6.h"
#include "SystemInformationBlockType7.h"
#include "SystemInformationBlockType8.h"
#include "SystemInformationBlockType9.h"
#include "SystemInformationBlockType10.h"
#include "SystemInformationBlockType11.h"
#include "SystemInformationBlockType12-r9.h"
#include "SystemInformationBlockType13-r9.h"
#include <constr_CHOICE.h>
#include <constr_SEQUENCE_OF.h>
#include <constr_SEQUENCE.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR {
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_NOTHING, /* No components present */
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11,
/* Extensions may appear below */
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib12_v920,
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib13_v920
} SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR;
/* Forward declarations */
struct SystemInformation_v8a0_IEs;
union SystemInformation_r8_IEs__sib_TypeAndInfo__Member_u {
SystemInformationBlockType2_t sib2;
SystemInformationBlockType3_t sib3;
SystemInformationBlockType4_t sib4;
SystemInformationBlockType5_t sib5;
SystemInformationBlockType6_t sib6;
SystemInformationBlockType7_t sib7;
SystemInformationBlockType8_t sib8;
SystemInformationBlockType9_t sib9;
SystemInformationBlockType10_t sib10;
SystemInformationBlockType11_t sib11;
/*
* This type is extensible,
* possible extensions are below.
*/
SystemInformationBlockType12_r9_t sib12_v920;
SystemInformationBlockType13_r9_t sib13_v920;
};
struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member {
SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR present;
union SystemInformation_r8_IEs__sib_TypeAndInfo__Member_u choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
};
/* SystemInformation-r8-IEs */
typedef struct SystemInformation_r8_IEs {
struct SystemInformation_r8_IEs__sib_TypeAndInfo {
A_SEQUENCE_OF(struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} sib_TypeAndInfo;
struct SystemInformation_v8a0_IEs *nonCriticalExtension /* OPTIONAL */;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} SystemInformation_r8_IEs_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_SystemInformation_r8_IEs;
#ifdef __cplusplus
}
#endif
/* Referred external types */
#include "SystemInformation-v8a0-IEs.h"
#endif /* _SystemInformation_r8_IEs_H_ */
#include <asn_internal.h>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Generated by asn1c-0.9.24 (http://lionet.info/asn1c)
* From ASN.1 module "X2AP-IEs"
* found in "/roux/comments/openairinterface5g/openair2/X2AP/MESSAGES/ASN1/R11.2/X2AP-IEs.asn"
* `asn1c -gen-PER`
*/
#ifndef _X2ap_CriticalityDiagnostics_IE_List_H_
#define _X2ap_CriticalityDiagnostics_IE_List_H_
#include <asn_application.h>
/* Including external dependencies */
#include <asn_SEQUENCE_OF.h>
#include "X2ap-Criticality.h"
#include "X2ap-ProtocolIE-ID.h"
#include "X2ap-TypeOfError.h"
#include <constr_SEQUENCE.h>
#include <constr_SEQUENCE_OF.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Forward declarations */
struct X2ap_IE_Extensions;
struct X2ap_CriticalityDiagnostics_IE_List__Member {
X2ap_Criticality_t iECriticality;
X2ap_ProtocolIE_ID_t iE_ID;
X2ap_TypeOfError_t typeOfError;
struct X2ap_IE_Extensions *iE_Extensions /* OPTIONAL */;
/*
* This type is extensible,
* possible extensions are below.
*/
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
};
/* X2ap-CriticalityDiagnostics-IE-List */
typedef struct X2ap_CriticalityDiagnostics_IE_List {
A_SEQUENCE_OF(struct X2ap_CriticalityDiagnostics_IE_List__Member
) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} X2ap_CriticalityDiagnostics_IE_List_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_X2ap_CriticalityDiagnostics_IE_List;
#ifdef __cplusplus
}
#endif
/* Referred external types */
#include "X2ap-IE-Extensions.h"
#endif /* _X2ap_CriticalityDiagnostics_IE_List_H_ */
#include <asn_internal.h>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment