mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-19 23:53:55 +00:00
ada/spark: all warnings, warn strict, style checks
* enable all common warnings through default value of CC_ADA_WARN * treat warnings like errors through default value of CC_ADA_WARN_STRICT * enable almost all style checks through default value of CC_ADA_WARN_STRICT * style fixes for aes_cbc_4k * disable strict warnings and style checks for libsparkcrypto and spark lib Ref #3848
This commit is contained in:
committed by
Norman Feske
parent
3f97269988
commit
f3eaeb08ef
@ -82,6 +82,16 @@ CUSTOM_ADA_FLAGS ?= --RTS=$(ADA_RTS)
|
|||||||
CUSTOM_ADA_OPT ?= $(CC_ADA_OPT) -gnatef
|
CUSTOM_ADA_OPT ?= $(CC_ADA_OPT) -gnatef
|
||||||
CUSTOM_ADA_INCLUDE ?= -I- $(INCLUDES)
|
CUSTOM_ADA_INCLUDE ?= -I- $(INCLUDES)
|
||||||
|
|
||||||
|
#
|
||||||
|
# The files generated by the binder would not pass our GNAT style checks
|
||||||
|
# thus we handle them separately and disable style checks via compiler option
|
||||||
|
# '-gnatyN'
|
||||||
|
#
|
||||||
|
b~%.ali b~%.o: b~%.adb
|
||||||
|
$(MSG_COMP)$@
|
||||||
|
$(VERBOSE)$(CUSTOM_ADA_CC) $(CUSTOM_ADA_FLAGS) $(CUSTOM_ADA_OPT) -gnatyN $(CUSTOM_ADA_INCLUDE) -c $<
|
||||||
|
$(VERBOSE)$(ALI2DEP) $(dir $<) $(ALL_INC_DIR) b~$*.ali
|
||||||
|
|
||||||
%.ali %.o: %.adb
|
%.ali %.o: %.adb
|
||||||
$(MSG_COMP)$@
|
$(MSG_COMP)$@
|
||||||
$(VERBOSE)$(CUSTOM_ADA_CC) $(CUSTOM_ADA_FLAGS) $(CUSTOM_ADA_OPT) $(CUSTOM_ADA_INCLUDE) -c $<
|
$(VERBOSE)$(CUSTOM_ADA_CC) $(CUSTOM_ADA_FLAGS) $(CUSTOM_ADA_OPT) $(CUSTOM_ADA_INCLUDE) -c $<
|
||||||
|
@ -146,6 +146,12 @@ CC_WARN += -Wno-error=implicit-fallthrough
|
|||||||
CC_CXX_WARN_STRICT ?= -Wextra -Weffc++ -Werror -Wsuggest-override
|
CC_CXX_WARN_STRICT ?= -Wextra -Weffc++ -Werror -Wsuggest-override
|
||||||
CC_CXX_WARN ?= $(CC_WARN) $(CC_CXX_WARN_STRICT)
|
CC_CXX_WARN ?= $(CC_WARN) $(CC_CXX_WARN_STRICT)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Additional warnings for Ada/SPARK
|
||||||
|
#
|
||||||
|
CC_ADA_WARN_STRICT ?= -gnatwe -gnatyyBdSux
|
||||||
|
CC_ADA_WARN ?= -gnatwa $(CC_ADA_WARN_STRICT)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Aggregate compiler options that are common for C and C++
|
# Aggregate compiler options that are common for C and C++
|
||||||
#
|
#
|
||||||
@ -174,7 +180,9 @@ CC_OPT += $(CC_OPT_PIC)
|
|||||||
#
|
#
|
||||||
CC_CXX_OPT += $(CC_OPT) $(CC_CXX_WARN)
|
CC_CXX_OPT += $(CC_OPT) $(CC_CXX_WARN)
|
||||||
CC_C_OPT += $(CC_OPT)
|
CC_C_OPT += $(CC_OPT)
|
||||||
CC_ADA_OPT += $(filter-out -fno-builtin-cos -fno-builtin-sin -fno-builtin-cosf -fno-builtin-sinf ,$(CC_OPT)) -fexceptions
|
CC_ADA_OPT += $(CC_ADA_WARN) -fexceptions
|
||||||
|
CC_ADA_OPT += $(filter-out -fno-builtin-cos -fno-builtin-sin \
|
||||||
|
-fno-builtin-cosf -fno-builtin-sinf ,$(CC_OPT))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Enable C++11 by default
|
# Enable C++11 by default
|
||||||
|
@ -31,9 +31,13 @@ is
|
|||||||
Block_Number_Text : constant Block_Number_Text_Type :=
|
Block_Number_Text : constant Block_Number_Text_Type :=
|
||||||
(Block_Number => Block_Number, Padding => (others => 0));
|
(Block_Number => Block_Number, Padding => (others => 0));
|
||||||
|
|
||||||
type Block_Number_Plaintext_Base_Type is array (Natural range <>) of Byte;
|
type Block_Number_Plaintext_Base_Type
|
||||||
|
is array (Natural range <>) of Byte;
|
||||||
|
|
||||||
subtype Block_Number_Plaintext_Index_Type is Natural range 1 .. 16;
|
subtype Block_Number_Plaintext_Index_Type is Natural range 1 .. 16;
|
||||||
subtype Block_Number_Plaintext_Type is Block_Number_Plaintext_Base_Type (Block_Number_Plaintext_Index_Type);
|
|
||||||
|
subtype Block_Number_Plaintext_Type
|
||||||
|
is Block_Number_Plaintext_Base_Type (Block_Number_Plaintext_Index_Type);
|
||||||
|
|
||||||
function Convert is new Ada.Unchecked_Conversion
|
function Convert is new Ada.Unchecked_Conversion
|
||||||
(Block_Number_Text_Type, Block_Number_Plaintext_Type);
|
(Block_Number_Text_Type, Block_Number_Plaintext_Type);
|
||||||
@ -42,11 +46,15 @@ is
|
|||||||
(Natural, Byte, IV_Key_Base_Type);
|
(Natural, Byte, IV_Key_Base_Type);
|
||||||
|
|
||||||
function Encrypt is new LSC.AES_Generic.Encrypt
|
function Encrypt is new LSC.AES_Generic.Encrypt
|
||||||
(Natural, Byte, Block_Number_Plaintext_Base_Type, Natural, Byte, Ciphertext_Base_Type);
|
(Natural, Byte, Block_Number_Plaintext_Base_Type, Natural, Byte,
|
||||||
|
Ciphertext_Base_Type);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
return Encrypt (Plaintext => Convert(Block_Number_Text),
|
return
|
||||||
Key => Enc_Key(Hash(Key), LSC.AES_Generic.L256)) (Natural'First .. Natural'First + 15);
|
Encrypt (
|
||||||
|
Plaintext => Convert (Block_Number_Text),
|
||||||
|
Key => Enc_Key (Hash (Key), LSC.AES_Generic.L256))
|
||||||
|
(Natural'First .. Natural'First + 15);
|
||||||
end Init_IV;
|
end Init_IV;
|
||||||
|
|
||||||
procedure Encrypt (Key : Key_Type;
|
procedure Encrypt (Key : Key_Type;
|
||||||
@ -58,7 +66,8 @@ is
|
|||||||
(Natural, Byte, Key_Base_Type);
|
(Natural, Byte, Key_Base_Type);
|
||||||
|
|
||||||
procedure Encrypt is new LSC.AES_Generic.CBC.Encrypt
|
procedure Encrypt is new LSC.AES_Generic.CBC.Encrypt
|
||||||
(Natural, Byte, Plaintext_Base_Type, Natural, Byte, Ciphertext_Base_Type);
|
(Natural, Byte, Plaintext_Base_Type, Natural, Byte,
|
||||||
|
Ciphertext_Base_Type);
|
||||||
|
|
||||||
IV : constant Ciphertext_Base_Type := Init_IV (Key, Block_Number);
|
IV : constant Ciphertext_Base_Type := Init_IV (Key, Block_Number);
|
||||||
begin
|
begin
|
||||||
@ -69,7 +78,6 @@ is
|
|||||||
Ciphertext => Ciphertext);
|
Ciphertext => Ciphertext);
|
||||||
end Encrypt;
|
end Encrypt;
|
||||||
|
|
||||||
|
|
||||||
procedure Decrypt (Key : Key_Type;
|
procedure Decrypt (Key : Key_Type;
|
||||||
Block_Number : Block_Number_Type;
|
Block_Number : Block_Number_Type;
|
||||||
Ciphertext : Ciphertext_Type;
|
Ciphertext : Ciphertext_Type;
|
||||||
@ -79,7 +87,8 @@ is
|
|||||||
(Natural, Byte, Key_Base_Type);
|
(Natural, Byte, Key_Base_Type);
|
||||||
|
|
||||||
procedure Decrypt is new LSC.AES_Generic.CBC.Decrypt
|
procedure Decrypt is new LSC.AES_Generic.CBC.Decrypt
|
||||||
(Natural, Byte, Plaintext_Base_Type, Natural, Byte, Ciphertext_Base_Type);
|
(Natural, Byte, Plaintext_Base_Type, Natural, Byte,
|
||||||
|
Ciphertext_Base_Type);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Decrypt (Ciphertext => Ciphertext,
|
Decrypt (Ciphertext => Ciphertext,
|
||||||
|
@ -4,8 +4,8 @@ is
|
|||||||
-- pragma Pure; -- not possible because libsparkcrypto is not known as pure
|
-- pragma Pure; -- not possible because libsparkcrypto is not known as pure
|
||||||
|
|
||||||
type Byte is mod 2**8 with Size => 8;
|
type Byte is mod 2**8 with Size => 8;
|
||||||
type Key_Base_type is array (Natural range <>) of Byte;
|
type Key_Base_Type is array (Natural range <>) of Byte;
|
||||||
subtype Key_Type is Key_Base_type (1 .. 32);
|
subtype Key_Type is Key_Base_Type (1 .. 32);
|
||||||
type Block_Number_Type is mod 2**64 with Size => 64;
|
type Block_Number_Type is mod 2**64 with Size => 64;
|
||||||
|
|
||||||
type Plaintext_Base_Type is array (Natural range <>) of Byte;
|
type Plaintext_Base_Type is array (Natural range <>) of Byte;
|
||||||
@ -22,7 +22,9 @@ is
|
|||||||
Ciphertext : out Ciphertext_Type)
|
Ciphertext : out Ciphertext_Type)
|
||||||
with Export,
|
with Export,
|
||||||
Convention => C,
|
Convention => C,
|
||||||
External_Name => "_ZN10Aes_cbc_4k7encryptERKNS_3KeyENS_12Block_numberERKNS_9PlaintextERNS_10CiphertextE";
|
External_Name =>
|
||||||
|
"_ZN10Aes_cbc_4k7encryptERKNS_3KeyENS_12Block_numberERKNS_" &
|
||||||
|
"9PlaintextERNS_10CiphertextE";
|
||||||
|
|
||||||
procedure Decrypt (Key : Key_Type;
|
procedure Decrypt (Key : Key_Type;
|
||||||
Block_Number : Block_Number_Type;
|
Block_Number : Block_Number_Type;
|
||||||
@ -30,6 +32,8 @@ is
|
|||||||
Plaintext : out Plaintext_Type)
|
Plaintext : out Plaintext_Type)
|
||||||
with Export,
|
with Export,
|
||||||
Convention => C,
|
Convention => C,
|
||||||
External_Name => "_ZN10Aes_cbc_4k7decryptERKNS_3KeyENS_12Block_numberERKNS_10CiphertextERNS_9PlaintextE";
|
External_Name =>
|
||||||
|
"_ZN10Aes_cbc_4k7decryptERKNS_3KeyENS_12Block_numberERKNS_" &
|
||||||
|
"10CiphertextERNS_9PlaintextE";
|
||||||
|
|
||||||
end Aes_Cbc_4k;
|
end Aes_Cbc_4k;
|
||||||
|
@ -78,3 +78,5 @@ vpath %.ads $(LSC_DIR)/shared/generic
|
|||||||
|
|
||||||
SHARED_LIB = yes
|
SHARED_LIB = yes
|
||||||
CC_ADA_OPT += -gnatec=$(LSC_DIR)/../build/pragmas.adc -fPIC
|
CC_ADA_OPT += -gnatec=$(LSC_DIR)/../build/pragmas.adc -fPIC
|
||||||
|
|
||||||
|
CC_ADA_WARN_STRICT =
|
||||||
|
@ -9,3 +9,5 @@ ada_source_path: ada_object_path
|
|||||||
ada_object_path:
|
ada_object_path:
|
||||||
$(VERBOSE)mkdir -p $(ADA_RTS)
|
$(VERBOSE)mkdir -p $(ADA_RTS)
|
||||||
$(VERBOSE)echo $(ADA_RTS) > $(ADA_RTS)/ada_object_path
|
$(VERBOSE)echo $(ADA_RTS) > $(ADA_RTS)/ada_object_path
|
||||||
|
|
||||||
|
CC_ADA_WARN_STRICT =
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package body add_package is
|
package body Add_Package is
|
||||||
|
|
||||||
procedure Add (A : in Integer;
|
procedure Add (A : in Integer;
|
||||||
B : in Integer;
|
B : in Integer;
|
||||||
@ -11,4 +11,4 @@ begin
|
|||||||
R := R + 1;
|
R := R + 1;
|
||||||
end Add;
|
end Add;
|
||||||
|
|
||||||
end add_package;
|
end Add_Package;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
package add_package is
|
package Add_Package is
|
||||||
procedure Add(A: in Integer; B: in Integer; R: out Integer);
|
procedure Add (
|
||||||
end add_package;
|
A : in Integer;
|
||||||
|
B : in Integer;
|
||||||
|
R : out Integer);
|
||||||
|
end Add_Package;
|
||||||
|
@ -23,7 +23,7 @@ package Machinery is
|
|||||||
Convention => C,
|
Convention => C,
|
||||||
External_Name => "_ZNK5Spark9Machinery11temperatureEv";
|
External_Name => "_ZNK5Spark9Machinery11temperatureEv";
|
||||||
|
|
||||||
procedure Heat_up (Machinery : in out Machinery_Type)
|
procedure Heat_Up (Machinery : in out Machinery_Type)
|
||||||
with Export,
|
with Export,
|
||||||
Convention => C,
|
Convention => C,
|
||||||
External_Name => "_ZN5Spark9Machinery7heat_upEv";
|
External_Name => "_ZN5Spark9Machinery7heat_upEv";
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
-- \date 2009-09-23
|
-- \date 2009-09-23
|
||||||
--
|
--
|
||||||
|
|
||||||
with add_package;
|
with Add_Package;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Main program
|
-- Main program
|
||||||
@ -17,9 +17,9 @@ procedure main is
|
|||||||
-- Declarations of external C functions
|
-- Declarations of external C functions
|
||||||
--
|
--
|
||||||
procedure ext_c_print_int (a : Integer);
|
procedure ext_c_print_int (a : Integer);
|
||||||
pragma import(C, ext_c_print_int, "print_int");
|
pragma Import (C, ext_c_print_int, "print_int");
|
||||||
|
|
||||||
begin
|
begin
|
||||||
add_package.Add(13, 14, result);
|
Add_Package.Add (13, 14, result);
|
||||||
ext_c_print_int (result);
|
ext_c_print_int (result);
|
||||||
end main;
|
end main;
|
||||||
|
@ -89,7 +89,6 @@ is
|
|||||||
return Buf;
|
return Buf;
|
||||||
end Stage_1;
|
end Stage_1;
|
||||||
|
|
||||||
|
|
||||||
function Stage_2 (
|
function Stage_2 (
|
||||||
Size : Integer
|
Size : Integer
|
||||||
) return Buffer
|
) return Buffer
|
||||||
|
@ -4,39 +4,25 @@ is
|
|||||||
|
|
||||||
type Buffer is array (Integer range <>) of Character;
|
type Buffer is array (Integer range <>) of Character;
|
||||||
|
|
||||||
procedure Calloc (
|
procedure Calloc (Size : Integer);
|
||||||
Size : Integer
|
|
||||||
);
|
|
||||||
|
|
||||||
procedure Ralloc;
|
procedure Ralloc;
|
||||||
|
|
||||||
function Alloc (
|
function Alloc (Size : Integer) return Buffer;
|
||||||
Size : Integer
|
|
||||||
) return Buffer;
|
|
||||||
|
|
||||||
function Recursive_Alloc (
|
function Recursive_Alloc (Round : Integer) return Buffer;
|
||||||
Round : Integer
|
|
||||||
) return Buffer;
|
|
||||||
|
|
||||||
procedure Salloc;
|
procedure Salloc;
|
||||||
|
|
||||||
function Stage_1 (
|
function Stage_1 (Size : Integer) return Buffer;
|
||||||
Size : Integer
|
|
||||||
) return Buffer;
|
|
||||||
|
|
||||||
function Stage_2 (
|
function Stage_2 (Size : Integer) return Buffer;
|
||||||
Size : Integer
|
|
||||||
) return Buffer;
|
|
||||||
|
|
||||||
function Stage_3 (
|
function Stage_3 (Size : Integer) return Buffer;
|
||||||
Size : Integer
|
|
||||||
) return Buffer;
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
procedure Print_Stage (
|
procedure Print_Stage (Stage : Integer)
|
||||||
Stage : Integer
|
|
||||||
)
|
|
||||||
with
|
with
|
||||||
Import,
|
Import,
|
||||||
Convention => C,
|
Convention => C,
|
||||||
|
Reference in New Issue
Block a user