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.
170 lines
3.5 KiB
Bash
Executable File
170 lines
3.5 KiB
Bash
Executable File
#!/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 "$@"
|