From 741c87c0d92a812538a3c2478f66e0195f1d6194 Mon Sep 17 00:00:00 2001
From: Xu Bo <xubo1@cn.fujitsu.com>
Date: Thu, 7 Dec 2017 16:38:51 +0800
Subject: [PATCH] fix Segmentation fault issue(pdu_index -1)

---
 nfapi/nfapi_interface.h                        | 18 +++++++++---------
 openair2/LAYER2/MAC/defs.h                     |  2 +-
 openair2/LAYER2/MAC/eNB_scheduler_primitives.c |  4 ++--
 openair2/LAYER2/MAC/proto.h                    |  4 ++--
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/nfapi/nfapi_interface.h b/nfapi/nfapi_interface.h
index 45af99a50f..9bb3dbe424 100644
--- a/nfapi/nfapi_interface.h
+++ b/nfapi/nfapi_interface.h
@@ -1308,7 +1308,7 @@ typedef struct {
 typedef struct {
 	nfapi_tl_t tl;
 	uint16_t length;
-	uint16_t pdu_index;
+	int16_t pdu_index;
 	uint16_t transmission_power;
 } nfapi_dl_config_bch_pdu_rel8_t;
 #define NFAPI_DL_CONFIG_REQUEST_BCH_PDU_REL8_TAG 0x2004
@@ -1320,7 +1320,7 @@ typedef struct {
 typedef struct {
 	nfapi_tl_t tl;
 	uint16_t length;
-	uint16_t pdu_index;
+	int16_t pdu_index;
 	uint16_t rnti;
 	uint8_t resource_allocation_type;
 	uint32_t resource_block_coding;
@@ -1344,7 +1344,7 @@ typedef struct {
 typedef struct {
 	nfapi_tl_t tl;
 	uint16_t length;
-	uint16_t pdu_index;
+	int16_t pdu_index;
 	uint16_t rnti;
 	uint8_t resource_allocation_type;
 	uint8_t virtual_resource_block_assignment_flag;
@@ -1429,7 +1429,7 @@ typedef struct {
 typedef struct {
 	nfapi_tl_t tl;
 	uint16_t length;
-	uint16_t pdu_index;
+	int16_t pdu_index;
 	uint16_t p_rnti;
 	uint8_t resource_allocation_type;
 	uint8_t virtual_resource_block_assignment_flag;
@@ -1595,7 +1595,7 @@ typedef struct {
 typedef struct {
 	nfapi_tl_t tl;
 	uint16_t length;
-	uint16_t pdu_index;
+	int16_t pdu_index;
 	uint16_t transmission_power;
 	uint16_t hyper_sfn_2_lsbs;
 } nfapi_dl_config_nbch_pdu_rel13_t;
@@ -1609,7 +1609,7 @@ typedef struct {
 typedef struct {
 	nfapi_tl_t tl;
 	uint16_t length;
-	uint16_t pdu_index;
+	int16_t pdu_index;
 	uint8_t ncce_index;
 	uint8_t aggregation_level;
 	uint8_t start_symbol;
@@ -1642,7 +1642,7 @@ typedef struct {
 typedef struct {
 	nfapi_tl_t tl;
 	uint16_t length;
-	uint16_t pdu_index;
+	int16_t pdu_index;
 	uint8_t start_symbol;
 	uint8_t rnti_type;
 	uint16_t rnti;
@@ -2361,7 +2361,7 @@ typedef struct {
 #define NFAPI_TX_MAX_SEGMENTS 32
 typedef struct {
 	uint16_t pdu_length;
-	uint16_t pdu_index;
+	int16_t pdu_index;
 	uint8_t num_segments;
 	struct {
 		uint32_t segment_length;
@@ -2902,7 +2902,7 @@ typedef struct {
 
 typedef struct {
 	uint8_t sub_error_code;
-	uint16_t pdu_index;
+	int16_t pdu_index;
 } nfapi_error_indication_msg_tx_err;
 
 // 
diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h
index 7b347f334d..e55d403a22 100644
--- a/openair2/LAYER2/MAC/defs.h
+++ b/openair2/LAYER2/MAC/defs.h
@@ -1042,7 +1042,7 @@ typedef struct eNB_MAC_INST_s {
     /// Common cell resources
     COMMON_channels_t common_channels[MAX_NUM_CCs];
     /// current PDU index (BCH,MCH,DLSCH)
-    uint16_t pdu_index[MAX_NUM_CCs];
+    int16_t pdu_index[MAX_NUM_CCs];
 
     /// NFAPI Config Request Structure
     nfapi_config_request_t config[MAX_NUM_CCs];
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index df84675dc1..f09b7852bd 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -1482,7 +1482,7 @@ void
 fill_nfapi_dlsch_config(eNB_MAC_INST * eNB,
 			nfapi_dl_config_request_body_t * dl_req,
 			uint16_t length,
-			uint16_t pdu_index,
+			int16_t pdu_index,
 			uint16_t rnti,
 			uint8_t resource_allocation_type,
 			uint8_t
@@ -1556,7 +1556,7 @@ fill_nfapi_dlsch_config(eNB_MAC_INST * eNB,
 uint16_t
 fill_nfapi_tx_req(nfapi_tx_request_body_t * tx_req_body,
 		  uint16_t absSF, uint16_t pdu_length,
-		  uint16_t pdu_index, uint8_t * pdu)
+		  int16_t pdu_index, uint8_t * pdu)
 {
     nfapi_tx_request_pdu_t *TX_req =
 	&tx_req_body->tx_pdu_list[tx_req_body->number_of_pdus];
diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h
index 34c7a4ef4c..f47d17949e 100644
--- a/openair2/LAYER2/MAC/proto.h
+++ b/openair2/LAYER2/MAC/proto.h
@@ -1040,7 +1040,7 @@ void extract_pusch_csi(module_id_t mod_idP, int CC_idP, int UE_id,
 
 uint16_t fill_nfapi_tx_req(nfapi_tx_request_body_t * tx_req_body,
 			   uint16_t absSF, uint16_t pdu_length,
-			   uint16_t pdu_index, uint8_t * pdu);
+			   int16_t pdu_index, uint8_t * pdu);
 
 void fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *
 					  ul_config_pdu, uint8_t cqi_req,
@@ -1080,7 +1080,7 @@ void program_dlsch_acknak(module_id_t module_idP, int CC_idP, int UE_idP,
 
 void fill_nfapi_dlsch_config(eNB_MAC_INST * eNB,
 			     nfapi_dl_config_request_body_t * dl_req,
-			     uint16_t length, uint16_t pdu_index,
+			     uint16_t length, int16_t pdu_index,
 			     uint16_t rnti,
 			     uint8_t resource_allocation_type,
 			     uint8_t
-- 
GitLab