From 23e9d2a227c3c5ff6de8e18fa56c2dd13d5b9b7e Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Mon, 26 Aug 2013 08:59:42 +0000
Subject: [PATCH] - Fix some compiler warnings

[pre-ci tests passed for 32/64 bits platforms]

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4102 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair2/LAYER2/MAC/eNB_scheduler.c           | 12 +--
 openair2/LAYER2/MAC/main.c                    |  2 +-
 openair2/LAYER2/MAC/pre_processor.c           | 20 ++---
 openair2/LAYER2/MAC/ue_procedures.c           | 42 ++++++----
 openair2/LAYER2/RLC/rlc_rrc.c                 |  4 +
 openair2/PHY_INTERFACE/defs.h                 | 10 +--
 .../L2_INTERFACE/openair_rrc_L2_interface.c   |  4 +-
 .../L2_INTERFACE/openair_rrc_L2_interface.h   |  4 +-
 openair2/RRC/LITE/L2_interface.c              |  1 +
 openair2/RRC/LITE/rrc_UE.c                    |  2 +
 openair2/RRC/LITE/rrc_common.c                |  4 +-
 openair2/UTIL/LOG/log.c                       | 25 +++---
 openair2/UTIL/MEM/mem_block.c                 | 84 ++++++++++++-------
 targets/SIMU/USER/oaisim_functions.c          | 14 ++--
 14 files changed, 134 insertions(+), 94 deletions(-)

diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 4539fe8d023..084234755c5 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -1047,7 +1047,7 @@ void schedule_SI(unsigned char Mod_id,u32 frame, unsigned char *nprb,unsigned in
 
 #if defined(USER_MODE) && defined(OAI_EMU)
     if (oai_emulation.info.opt_enabled)
-      trace_pdu(1, (char *)&eNB_mac_inst[Mod_id].BCCH_pdu.payload[0], bcch_sdu_length,
+      trace_pdu(1, &eNB_mac_inst[Mod_id].BCCH_pdu.payload[0], bcch_sdu_length,
                 0xffff, 4, 0xffff, eNB_mac_inst[Mod_id].subframe, 0, 0);
     LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for rnti %x with size %d\n", 
           Mod_id, frame, 0xffff, bcch_sdu_length);
@@ -1800,7 +1800,7 @@ void schedule_RA(unsigned char Mod_id,u32 frame, unsigned char subframe,unsigned
 
 #if defined(USER_MODE) && defined(OAI_EMU)
 	  if (oai_emulation.info.opt_enabled){
-	    trace_pdu(1, (char*)eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)UE_id][0].payload[0],
+	    trace_pdu(1, (uint8_t *)eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)UE_id][0].payload[0],
                   rrc_sdu_length, UE_id, 3, find_UE_RNTI(Mod_id, UE_id),
                   eNB_mac_inst[Mod_id].subframe,0,0);
 	    LOG_D(OPT,"[eNB %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n",
@@ -3287,7 +3287,7 @@ void schedule_ue_spec(unsigned char Mod_id,
   u16 i=0,ii=0,tpmi0=1;
   u8 dl_pow_off[NUMBER_OF_UE_MAX];
   unsigned char rballoc_sub_UE[NUMBER_OF_UE_MAX][N_RBGS_MAX];
-  unsigned char rballoc_sub[N_RBGS_MAX];
+//   unsigned char rballoc_sub[N_RBGS_MAX];
   u16 pre_nb_available_rbs[NUMBER_OF_UE_MAX];
   int mcs;
   //u8 number_of_subbands=13;
@@ -3328,7 +3328,7 @@ void schedule_ue_spec(unsigned char Mod_id,
     pre_nb_available_rbs[i] = 0;
     dl_pow_off[i] = 2;
     for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++){
-      rballoc_sub[j] = 0;
+//       rballoc_sub[j] = 0;
       rballoc_sub_UE[i][j] = 0;
     }
   }
@@ -3951,9 +3951,9 @@ void schedule_ue_spec(unsigned char Mod_id,
 	//eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff);
 
 #if defined(USER_MODE) && defined(OAI_EMU)
-    /* Tracing of PDU is done on UE side */
+        /* Tracing of PDU is done on UE side */
 	if (oai_emulation.info.opt_enabled)
-	  trace_pdu(1, (char*)eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)next_ue][0].payload[0],
+            trace_pdu(1, (uint8_t *)eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)next_ue][0].payload[0],
                 TBS, Mod_id, 3, find_UE_RNTI(Mod_id,next_ue),
                 eNB_mac_inst[Mod_id].subframe,0,0);
 	LOG_D(OPT,"[eNB %d][DLSCH] Frame %d  rnti %x  with size %d\n", 
diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c
index 60c64067951..2a324056685 100644
--- a/openair2/LAYER2/MAC/main.c
+++ b/openair2/LAYER2/MAC/main.c
@@ -414,7 +414,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_activ
   mac_init_global_param();
 
 
-  mac_xface->macphy_init=(void (*)(void))mac_top_init;
+  mac_xface->macphy_init = mac_top_init;
 #ifndef USER_MODE
   mac_xface->macphy_exit = openair_sched_exit;
 #else
diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c
index 82678a0a588..f44513973af 100644
--- a/openair2/LAYER2/MAC/pre_processor.c
+++ b/openair2/LAYER2/MAC/pre_processor.c
@@ -77,11 +77,9 @@ extern inline unsigned int taus(void);
 void store_dlsch_buffer (unsigned char Mod_id,
 			 u32 frame,
 			 unsigned char subframe){
-  
-  
+
   unsigned char next_ue;
   u16 rnti,i=0;
-  LTE_eNB_UE_stats* eNB_UE_stats;
   mac_rlc_status_resp_t rlc_status;
   unsigned char UE_id,granted_UEs;  
 
@@ -98,8 +96,6 @@ void store_dlsch_buffer (unsigned char Mod_id,
     }
   }
 
-
-
   for (UE_id=0;UE_id<granted_UEs;UE_id++) {
     
     next_ue = UE_id;
@@ -118,7 +114,7 @@ void store_dlsch_buffer (unsigned char Mod_id,
       eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total = eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_info[i];//storing the total dlsch buffer
       eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_total += eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_in_buffer[i];
 
-#ifdef DEBUG_eNB_SCHEDULER     
+#ifdef DEBUG_eNB_SCHEDULER
       /* note for dl_buffer_head_sdu_remaining_size_to_send[i] :
        * 0 if head SDU has not been segmented (yet), else remaining size not already segmented and sent
        */
@@ -130,10 +126,10 @@ void store_dlsch_buffer (unsigned char Mod_id,
 	      eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_remaining_size_to_send[i],
 	      eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_is_segmented[i]
 	    );
-#endif   
-      
+#endif
+
     }
-#ifdef DEBUG_eNB_SCHEDULER        
+#ifdef DEBUG_eNB_SCHEDULER
     if ( eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total>0)
       LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n",
 	    Mod_id, frame, subframe, next_ue, 
@@ -152,12 +148,10 @@ void assign_rbs_required (unsigned char Mod_id,
 			  u16 *nb_rbs_required){
 
  
-  unsigned char next_ue,harq_pid=0,round=0;
+  unsigned char next_ue;
   u16 rnti,TBS = 0;
   LTE_eNB_UE_stats* eNB_UE_stats;
-  mac_rlc_status_resp_t rlc_status;
-  unsigned char UE_id,granted_UEs,i=0;  
-
+  unsigned char UE_id, granted_UEs;
 
   granted_UEs = find_dlgranted_UEs(Mod_id);
 
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 0f9ef781bb4..dd8baf7f865 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -42,21 +42,25 @@
 #include "extern.h"
 #include "defs.h"
 #ifdef PHY_EMUL
-#include "SIMULATION/PHY_EMULATION/impl_defs.h"
+# include "SIMULATION/PHY_EMULATION/impl_defs.h"
 #else
-#include "SCHED/defs.h"
-#include "PHY/impl_defs_top.h"
+# include "SCHED/defs.h"
+# include "PHY/impl_defs_top.h"
 #endif
 #include "PHY_INTERFACE/defs.h"
 #include "PHY_INTERFACE/extern.h"
 #include "COMMON/mac_rrc_primitives.h"
+
+#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
 #include "RRC/LITE/extern.h"
 #include "UTIL/LOG/log.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
+#include "UTIL/OPT/opt.h"
 #include "OCG.h"
 #include "OCG_extern.h"
+
 #ifdef PHY_EMUL
-#include "SIMULATION/simulation_defs.h"
+# include "SIMULATION/simulation_defs.h"
 #endif
 #include "pdcp.h"
 
@@ -403,7 +407,6 @@ void ue_send_sdu(u8 Mod_id,u32 frame,u8 *sdu,u16 sdu_len,u8 eNB_index) {
 
 void ue_decode_si(u8 Mod_id,u32 frame, u8 eNB_index, void *pdu,u16 len) {
 
-  int i;
   vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN);
 
   LOG_D(MAC,"[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n",Mod_id,frame,BCCH,len);
@@ -963,22 +966,24 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u
   POWER_HEADROOM_CMD phr;
   POWER_HEADROOM_CMD *phr_p=&phr;
   unsigned short short_padding=0, post_padding=0;
-  int lcid,lcgid;
+  int lcgid;
   int j; // used for padding
   // Compute header length
 
   vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_IN);
 
-#ifdef CBA  
+#ifdef CBA
   if (*access_mode==CBA_ACCESS){
-    LOG_D(MAC,"[UE %d] frame %d subframe %d try CBA transmission\n", Mod_id, frame, subframe);
+    LOG_D(MAC,"[UE %d] frame %d subframe %d try CBA transmission\n",
+          Mod_id, frame, subframe);
  //if (UE_mac_inst[Mod_id].scheduling_info.LCID_status[DTCH] == LCID_EMPTY) 
     if (use_cba_access(Mod_id,frame,subframe,eNB_index)==0){
       *access_mode=POSTPONED_ACCESS;
       vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT);
       return;
     }
-    LOG_D(MAC,"[UE %d] frame %d subframe %d CBA transmission oppurtunity, tbs %d\n", Mod_id, frame, subframe,buflen);
+    LOG_D(MAC,"[UE %d] frame %d subframe %d CBA transmission oppurtunity, tbs %d\n",
+          Mod_id, frame, subframe,buflen);
   }
 #endif
   dcch_header_len=2;//sizeof(SCH_SUBHEADER_SHORT);
@@ -990,14 +995,16 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u
   phr_ce_len = (UE_mac_inst[Mod_id].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0;
   if (phr_ce_len > 0){
     phr_len = phr_ce_len + phr_header_len;
-    LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n",Mod_id, phr_len, phr_ce_len, phr_header_len, buflen);
+    LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n",
+          Mod_id, phr_len, phr_ce_len, phr_header_len, buflen);
   }else
     phr_len=0;
  
   bsr_ce_len = get_bsr_len (Mod_id, buflen-phr_len);
   if (bsr_ce_len > 0 ){
     bsr_len = bsr_ce_len + bsr_header_len;
-    LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n",Mod_id, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen);
+    LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n",
+          Mod_id, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen);
   } else
     bsr_len = 0;
   
@@ -1011,8 +1018,9 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u
     rlc_status = mac_rlc_status_ind(Mod_id+NB_eNB_INST,frame,0,RLC_MBMS_NO,
 				    DCCH,
 				    (buflen-dcch_header_len-bsr_len-phr_len));
-    LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send (Transport Block size %d, mac header len %d)\n",
-	  Mod_id,frame, rlc_status.bytes_in_buffer,buflen,dcch_header_len);
+    LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to "
+          "send (Transport Block size %d, mac header len %d)\n",
+          Mod_id,frame, rlc_status.bytes_in_buffer,buflen,dcch_header_len);
 
     sdu_lengths[0] += mac_rlc_data_req(Mod_id+NB_eNB_INST,frame,RLC_MBMS_NO,
 				       DCCH,
@@ -1037,8 +1045,9 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u
 				    DCCH1,
 				    (buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-sdu_length_total));
 
-    LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH1 -> ULSCH, RRC message has %d bytes to send (Transport Block size %d, mac header len %d)\n",
-	  Mod_id,frame, rlc_status.bytes_in_buffer,buflen,dcch1_header_len);
+    LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH1 -> ULSCH, RRC message has %d bytes to"
+          " send (Transport Block size %d, mac header len %d)\n",
+          Mod_id,frame, rlc_status.bytes_in_buffer,buflen,dcch1_header_len);
 
     sdu_lengths[num_sdus] = mac_rlc_data_req(Mod_id+NB_eNB_INST,frame,RLC_MBMS_NO,
 					     DCCH1,
@@ -1071,7 +1080,8 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u
 				    buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total);
 
     LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[DTCH] %d)\n",
-	  Mod_id,frame, rlc_status.bytes_in_buffer,buflen,dtch_header_len,UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[DTCH]);
+          Mod_id,frame, rlc_status.bytes_in_buffer,buflen,dtch_header_len,
+          UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[DTCH]);
 
     sdu_lengths[num_sdus] = mac_rlc_data_req(Mod_id+NB_eNB_INST,frame,RLC_MBMS_NO,
 					     DTCH,
diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c
index e9a4b74ac48..a89aa5a1a48 100644
--- a/openair2/LAYER2/RLC/rlc_rrc.c
+++ b/openair2/LAYER2/RLC/rlc_rrc.c
@@ -139,6 +139,10 @@ rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t module_idP, u32_t frameP, u
                                   LOG_D(RLC, "[RLC_RRC][MOD_id %d] SRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, rb_id);
                               }
                               break;
+                          default:
+                              LOG_E(RLC, "[RLC_RRC][MOD_id %d] UNKNOWN RLC CONFIG %d \n",
+                                    module_idP, srb_toaddmod->rlc_Config->choice.explicitValue.present);
+                              break;
                       }
                       break;
                   case SRB_ToAddMod__rlc_Config_PR_defaultValue:
diff --git a/openair2/PHY_INTERFACE/defs.h b/openair2/PHY_INTERFACE/defs.h
index da94259a9e2..839efe98ba0 100755
--- a/openair2/PHY_INTERFACE/defs.h
+++ b/openair2/PHY_INTERFACE/defs.h
@@ -57,11 +57,11 @@
 typedef struct
   {
     /// Pointer function that initializes L2
-    void (*macphy_init)(int eMBMS_active, u8 CBA_enabled);
+    int (*macphy_init)(int eMBMS_active, u8 CBA_enabled);
 
     /// Pointer function that stops the low-level scheduler due an exit condition        
-    void (*macphy_exit)(const char *);          
-    
+    void (*macphy_exit)(const char *);
+
     // eNB functions
     /// Invoke dlsch/ulsch scheduling procedure for new subframe
     void (*eNB_dlsch_ulsch_scheduler)(u8 Mod_id, u8 cooperation_flag, u32 frame, u8 subframe);//, int calibration_flag);
@@ -219,13 +219,13 @@ typedef struct
     u16 (*get_nCCE_max)(u8 Mod_id);
 
     /// Function to retrieve number of PRB in an rb_alloc
-    u16 (*get_nb_rb)(u8 ra_header,u32 rb_alloc);
+    u32 (*get_nb_rb)(u8 ra_header, u32 rb_alloc, int n_rb_dl);
 
     /// Function to retrieve transmission mode for UE
     u8 (*get_transmission_mode)(u16 Mod_id,u16 rnti);
 
     /// Function to retrieve rb_alloc bitmap from dci rballoc field and VRB type
-    u32 (*get_rballoc)(u8 vrb_type,u8 rb_alloc_dci);
+    u32 (*get_rballoc)(u8 vrb_type, u16 rb_alloc_dci);
 
     /// Function for UE MAC to retrieve current PHY connectivity mode (PRACH,RA_RESPONSE,PUSCH)
     UE_MODE_t (*get_ue_mode)(u8 Mod_id,u8 eNB_index);
diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c
index aebf56b72aa..79249773944 100644
--- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c
+++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c
@@ -153,7 +153,7 @@ char openair_rrc_ue_init(u8 Mod_id, unsigned char eNB_index){
 #ifdef CELLULAR
   return (rrc_L2_ue_init(Mod_id,eNB_index));
 #else 
-  openair_rrc_lite_ue_init(Mod_id, eNB_index);
+  return openair_rrc_lite_ue_init(Mod_id, eNB_index);
 #endif //CELLULAR
 }
 
@@ -163,6 +163,6 @@ char openair_rrc_eNB_init(u8 Mod_id){
 #ifdef CELLULAR
  return( rrc_L2_eNB_init(Mod_id));
 #else 
-  openair_rrc_lite_eNB_init(Mod_id);
+  return openair_rrc_lite_eNB_init(Mod_id);
 #endif //CELLULAR
 }
diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h
index 1d4983951ec..62762dd4f1b 100644
--- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h
+++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h
@@ -9,7 +9,7 @@ ________________________________________________________________*/
 #define __OPENAIR_RRC_L2_INTERFACE_H__
 
 #include "COMMON/mac_rrc_primitives.h"
- 
+
 s8 mac_rrc_data_req( u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb,char *Buffer,u8,u8);
 s8 mac_rrc_data_ind( u8 Mod_id,  u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_len,u8,u8 Mui);
 void mac_lite_sync_ind( u8 Mod_id, u8 status);
@@ -20,4 +20,6 @@ void mac_out_of_sync_ind(u8 Mod_id,u32 frame,u16 CH_index);
 char openair_rrc_eNB_init(u8 Mod_id);
 char openair_rrc_ue_init(u8 Mod_id, unsigned char eNB_index);
 int mac_get_rrc_status(u8 Mod_id,u8 eNB_flag,u8 index);
+void mac_in_sync_ind(u8 Mod_id,u32 frame, u16 eNB_index);
+
 #endif
diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c
index 2343c750f31..829e04883bd 100644
--- a/openair2/RRC/LITE/L2_interface.c
+++ b/openair2/RRC/LITE/L2_interface.c
@@ -326,4 +326,5 @@ int mac_get_rrc_lite_status(u8 Mod_id,u8 eNB_flag,u8 index){
 int mac_ue_ccch_success_ind(u8 Mod_id, u8 eNB_index) {
   // reset the tx buffer to indicate RRC that ccch was successfully transmitted (for example if contention resolution succeeds)
   UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size=0;
+  return 0;
 }
diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c
index 1b341b174e9..b127170a534 100644
--- a/openair2/RRC/LITE/rrc_UE.c
+++ b/openair2/RRC/LITE/rrc_UE.c
@@ -1129,6 +1129,8 @@ void  rrc_ue_decode_dcch(u8 Mod_id,u32 frame,u8 Srb_id, u8 *Buffer,u8 eNB_index)
       case DL_DCCH_MessageType__c1_PR_spare3:
       case DL_DCCH_MessageType__c1_PR_spare4:
 	break;
+      default:
+        break;
       }
     }
   }
diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c
index 3c299e75578..2d01b79e16f 100644
--- a/openair2/RRC/LITE/rrc_common.c
+++ b/openair2/RRC/LITE/rrc_common.c
@@ -277,7 +277,7 @@ u16 T310[8] = {0,50,100,200,500,1000,2000};
 u16 N310[8] = {1,2,3,4,6,8,10,20};
 u16 N311[8] = {1,2,3,4,6,8,10,20};
 
-rrc_t310_expiration(u32 frame,u8 Mod_id,u8 eNB_index) {
+void rrc_t310_expiration(u32 frame,u8 Mod_id,u8 eNB_index) {
 
   if (UE_rrc_inst[Mod_id].Info[eNB_index].State!=RRC_CONNECTED) {
     LOG_D(RRC,"Timer 310 expired, going to RRC_IDLE\n");
@@ -303,7 +303,7 @@ rrc_t310_expiration(u32 frame,u8 Mod_id,u8 eNB_index) {
     LOG_D(RRC,"Timer 310 expired, trying RRCRestablishment ...\n");    
   }
 }
-    
+
 RRC_status_t rrc_rx_tx(u8 Mod_id,u32 frame, u8 eNB_flag,u8 index){
       
   if(eNB_flag == 0) {
diff --git a/openair2/UTIL/LOG/log.c b/openair2/UTIL/LOG/log.c
index cbc3f2d8e4e..3203544eea3 100755
--- a/openair2/UTIL/LOG/log.c
+++ b/openair2/UTIL/LOG/log.c
@@ -51,7 +51,8 @@
 //#include "UTIL/OCG/OCG.h"
 //#include "UTIL/OCG/OCG_extern.h"
 #ifdef USER_MODE
-#include <string.h>
+# include <pthread.h>
+# include <string.h>
 #endif
 #ifdef RTAI
 #include <rtai.h>
@@ -72,7 +73,7 @@ static char *log_level_highlight_start[] = {LOG_RED, LOG_RED, LOG_RED, LOG_RED,
 static char *log_level_highlight_end[]   = {LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET, LOG_RESET,LOG_RESET,  "",""};	/*!< \brief Optional end-format strings for highlighting */
 
 
-static int bypass_log_hdr;
+// static int bypass_log_hdr;
 
 //extern MAC_xface *mac_xface;
 
@@ -81,21 +82,21 @@ int logInit (void) {
 #ifdef USER_MODE
   int i;
   g_log = calloc(1, sizeof(log_t));
-  memset(g_log, 0, sizeof(log_t));
+
 #else
   g_log = kmalloc(sizeof(log_t),GFP_KERNEL);
 #endif
   if (g_log == NULL) {
 #ifdef USER_MODE
-    perror ("cannot allocated memory for log generation modeul \n");
-    exit(-1);
+    perror ("cannot allocated memory for log generation module \n");
+    exit(EXIT_FAILURE);
 #else
-    printk("cannot allocated memory for log generation modeul \n");
+    printk("cannot allocated memory for log generation module \n");
     return(-1);
 #endif
   }
   
-  g_log->log_component[PHY].name = "PHY";
+    g_log->log_component[PHY].name = "PHY";
     g_log->log_component[PHY].level = LOG_EMERG;
     g_log->log_component[PHY].flag =  LOG_MED;
     g_log->log_component[PHY].interval =  1;
@@ -330,6 +331,7 @@ int logInit (void) {
   printk("log init done\n");
 #endif
 
+  return 0;
 }
 
 //log record: add to a list 
@@ -339,7 +341,7 @@ void logRecord( const char *file, const char *func,
 
   va_list args;
   LOG_params log_params;
-  int len, err;
+  int len;
   //LOG_elt *log = NULL;
 
   va_start(args, format);
@@ -491,6 +493,7 @@ else
 
 }
 
+#if !defined(LOG_NO_THREAD)
 void *log_thread_function(void * list) {
 
   LOG_params log_params;
@@ -537,14 +540,14 @@ void *log_thread_function(void * list) {
     //free(log_elt);
   }
 }
-
+#endif
 
 //log record, format, and print:  executed in the main thread (mt)
 void logRecord_mt( const char *file, const char *func,
 		int line,  int comp, int level, 
 		char *format, ...) {
-   
-  int len, i;
+
+  int len;
   va_list args;
   log_component_t *c;
 
diff --git a/openair2/UTIL/MEM/mem_block.c b/openair2/UTIL/MEM/mem_block.c
index 1cc0b5d3fb0..9b449a88fba 100644
--- a/openair2/UTIL/MEM/mem_block.c
+++ b/openair2/UTIL/MEM/mem_block.c
@@ -19,7 +19,7 @@
 //#define DEBUG_MEM_MNGT_ALLOC_SIZE
 //#define DEBUG_MEM_MNGT_ALLOC
 //-----------------------------------------------------------------------------
-#ifdef USER_MODE
+#if defined(USER_MODE) && defined(DEBUG_MEM_MNGT_ALLOC)
 u32_t             counters[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 #endif
 //-----------------------------------------------------------------------------
@@ -359,11 +359,11 @@ void
 check_free_mem_block (mem_block_t * leP)
 {
 //-----------------------------------------------------------------------------
-  int             block_index;
+  ptrdiff_t             block_index;
   if ((leP >= &mem_block_var.mem_blocks[0]) && (leP <= &mem_block_var.mem_blocks[MEM_MNGT_NB_ELEMENTS])) {
-    block_index = ((u32_t) leP - (u32) (&mem_block_var.mem_blocks[0])) / sizeof (mem_block_t);
+    block_index = (leP - (&mem_block_var.mem_blocks[0])) / sizeof (mem_block_t);
     if (block_index < MEM_MNGT_MB0_NB_BLOCKS) {
-      if (((u32_t) (leP->data) != (u32) (&(mem_block_var.mem_pool0[block_index][0]))) && (leP->pool_id != MEM_MNGT_POOL_ID0)) {
+      if ((leP->data != (&(mem_block_var.mem_pool0[block_index][0]))) && (leP->pool_id != MEM_MNGT_POOL_ID0)) {
         msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
     } else if (block_index < (MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS)) {
@@ -374,59 +374,79 @@ check_free_mem_block (mem_block_t * leP)
       if ((leP->data != &(mem_block_var.mem_pool2[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID2)) {
         msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
-    } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS) {
+    } else if (block_index <
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS) {
       if ((leP->data != &(mem_block_var.mem_pool3[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID3)) {
         msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
-    } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS) {
+    } else if (block_index <
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS) {
       if ((leP->data != &(mem_block_var.mem_pool4[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID4)) {
         msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
-    } else if (block_index < MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS) {
+    } else if (block_index <
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS) {
       if ((leP->data != &(mem_block_var.mem_pool5[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID5)) {
         msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
     } else if (block_index <
-               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + MEM_MNGT_MB6_NB_BLOCKS) {
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS
+             + MEM_MNGT_MB6_NB_BLOCKS) {
       if ((leP->data != &(mem_block_var.mem_pool6[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID6)) {
         msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
     } else if (block_index <
-               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + MEM_MNGT_MB6_NB_BLOCKS +
-               MEM_MNGT_MB7_NB_BLOCKS) {
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS
+             + MEM_MNGT_MB6_NB_BLOCKS + MEM_MNGT_MB7_NB_BLOCKS) {
       if ((leP->data != &(mem_block_var.mem_pool7[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID7)) {
         msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
     } else if (block_index <
-               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + MEM_MNGT_MB6_NB_BLOCKS +
-               MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS) {
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS
+             + MEM_MNGT_MB6_NB_BLOCKS + MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS) {
       if ((leP->data != &(mem_block_var.mem_pool8[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID8)) {
         msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
     } else if (block_index <
-               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + MEM_MNGT_MB6_NB_BLOCKS +
-               MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS + MEM_MNGT_MB9_NB_BLOCKS) {
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS
+             + MEM_MNGT_MB6_NB_BLOCKS + MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS
+             + MEM_MNGT_MB9_NB_BLOCKS) {
       if ((leP->data != &(mem_block_var.mem_pool9[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID9)) {
         msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
       }
-	} else if (block_index <
-		MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + MEM_MNGT_MB6_NB_BLOCKS +
-		MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS + MEM_MNGT_MB9_NB_BLOCKS + MEM_MNGT_MB10_NB_BLOCKS) {
-		if ((leP->data != &(mem_block_var.mem_pool10[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID10)) {
-			msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
-		}
-	} else if (block_index <
-		MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + MEM_MNGT_MB6_NB_BLOCKS +
-		MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS + MEM_MNGT_MB9_NB_BLOCKS + MEM_MNGT_MB10_NB_BLOCKS + MEM_MNGT_MB11_NB_BLOCKS) {
-		if ((leP->data != &(mem_block_var.mem_pool11[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID11)) {
-			msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
-		}
-	}  else if (block_index <
-		MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS + MEM_MNGT_MB6_NB_BLOCKS + MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS + MEM_MNGT_MB9_NB_BLOCKS + MEM_MNGT_MB10_NB_BLOCKS+ MEM_MNGT_MB11_NB_BLOCKS+ MEM_MNGT_MB12_NB_BLOCKS) {
-		if ((leP->data != &(mem_block_var.mem_pool12[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID12)) {
-			msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
-		}
-	}
+    } else if (block_index <
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS
+             + MEM_MNGT_MB6_NB_BLOCKS + MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS
+             + MEM_MNGT_MB9_NB_BLOCKS + MEM_MNGT_MB10_NB_BLOCKS) {
+      if ((leP->data != &(mem_block_var.mem_pool10[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID10)) {
+        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+      }
+    } else if (block_index <
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS
+             + MEM_MNGT_MB6_NB_BLOCKS + MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS
+             + MEM_MNGT_MB9_NB_BLOCKS + MEM_MNGT_MB10_NB_BLOCKS+ MEM_MNGT_MB11_NB_BLOCKS) {
+      if ((leP->data != &(mem_block_var.mem_pool11[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID11)) {
+        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+      }
+    } else if (block_index <
+               MEM_MNGT_MB0_NB_BLOCKS + MEM_MNGT_MB1_NB_BLOCKS + MEM_MNGT_MB2_NB_BLOCKS
+             + MEM_MNGT_MB3_NB_BLOCKS + MEM_MNGT_MB4_NB_BLOCKS + MEM_MNGT_MB5_NB_BLOCKS
+             + MEM_MNGT_MB6_NB_BLOCKS + MEM_MNGT_MB7_NB_BLOCKS + MEM_MNGT_MB8_NB_BLOCKS
+             + MEM_MNGT_MB9_NB_BLOCKS + MEM_MNGT_MB10_NB_BLOCKS+ MEM_MNGT_MB11_NB_BLOCKS
+             + MEM_MNGT_MB12_NB_BLOCKS) {
+      if ((leP->data != &(mem_block_var.mem_pool12[block_index][0])) && (leP->pool_id != MEM_MNGT_POOL_ID12)) {
+        msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
+      }
+    }
   } else {
     msg ("[MEM][ERROR][FATAL] free mem block is corrupted\n");
   }
diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c
index 80a867bc663..da517ad5f08 100644
--- a/targets/SIMU/USER/oaisim_functions.c
+++ b/targets/SIMU/USER/oaisim_functions.c
@@ -8,13 +8,17 @@
 #include "LAYER2/PDCP_v10.1.0/pdcp.h"
 #include "LAYER2/PDCP_v10.1.0/pdcp_primitives.h"
 #include "RRC/LITE/extern.h"
+#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
 #include "PHY_INTERFACE/extern.h"
 #include "ARCH/CBMIMO1/DEVICE_DRIVER/extern.h"
 #include "SCHED/extern.h"
+#include "SIMULATION/ETH_TRANSPORT/proto.h"
 #include "UTIL/OCG/OCG_extern.h"
 #include "UTIL/LOG/vcd_signal_dumper.h"
 #include "UTIL/OPT/opt.h"
 
+#include "cor_SF_sim.h"
+
 #ifdef SMBV
 extern u8 config_smbv;
 extern char smbv_ip[16];
@@ -356,14 +360,14 @@ void check_and_adjust_params() {
   s32 ret;
   int i,j;
 
-  if (oai_emulation.info.nb_ue_local > NUMBER_OF_UE_MAX ) {
+  if (oai_emulation.info.nb_ue_local > NUMBER_OF_UE_MAX) {
     LOG_E(EMU,"Enter fewer than %d UEs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_UE_MAX);
-    exit (-1);
+    exit(EXIT_FAILURE);
   }
 
   if (oai_emulation.info.nb_enb_local > NUMBER_OF_eNB_MAX) {
     LOG_E(EMU,"Enter fewer than %d eNBs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_eNB_MAX);
-    exit (-1);
+    exit(EXIT_FAILURE);
   }
 
   // fix ethernet and abstraction with RRC_CELLULAR Flag
@@ -377,7 +381,7 @@ void check_and_adjust_params() {
 
   // setup netdevice interface (netlink socket)
   LOG_I(EMU,"[INIT] Starting NAS netlink interface\n");
-  ret = netlink_init ();
+  ret = netlink_init();
   if (ret < 0)
     LOG_E(EMU,"[INIT] Netlink not available, careful ...\n");
 
@@ -820,7 +824,7 @@ void update_otg_eNB(int module_id, unsigned int ctime) {
 }
 
 void update_otg_UE(int module_id, unsigned int ctime) {
-  #if defined(USER_MODE) && defined(OAI_EMU)
+#if defined(USER_MODE) && defined(OAI_EMU)
   if (oai_emulation.info.otg_enabled ==1 ) {
     int dst_id, src_id;
     int eNB_index = 0; //See how phy_procedures_UE_lte is called: 3rd parameter from the right = 0
-- 
GitLab