Просмотр исходного кода

qcacld-3.0: Introduce hdd_handle_to_context()

Currently direct typecasting is used to convert an HDD handle to HDD
context. Typecasting has the disadvantage that it does not allow the
compiler to validate that the input item being typecast really is an
hdd_handle_t. In order to allow the compiler to typecheck the input
item introduce a converter API, and update the current existing
typecasts to use the converter.

Change-Id: Ifc7c3e062af234b378f1fb806cae0814ac52e423
CRs-Fixed: 2273915
Jeff Johnson 6 лет назад
Родитель
Сommit
ea70b9480d
3 измененных файлов с 13 добавлено и 7 удалено
  1. 11 0
      core/hdd/inc/wlan_hdd_main.h
  2. 1 1
      core/hdd/src/wlan_hdd_main.c
  3. 1 6
      core/hdd/src/wlan_hdd_stats.c

+ 11 - 0
core/hdd/inc/wlan_hdd_main.h

@@ -3385,4 +3385,15 @@ mac_handle_t hdd_adapter_get_mac_handle(struct hdd_adapter *adapter)
 		hdd_context_get_mac_handle(adapter->hdd_ctx) : NULL;
 }
 
+/**
+ * hdd_handle_to_context() - turn an HDD handle into an HDD context
+ * @hdd_handle: HDD handle to be converted
+ *
+ * Return: HDD context referenced by @hdd_handle
+ */
+static inline
+struct hdd_context *hdd_handle_to_context(hdd_handle_t hdd_handle)
+{
+	return (struct hdd_context *)hdd_handle;
+}
 #endif /* end #if !defined(WLAN_HDD_MAIN_H) */

+ 1 - 1
core/hdd/src/wlan_hdd_main.c

@@ -1907,7 +1907,7 @@ static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx,
 void hdd_update_tgt_cfg(hdd_handle_t hdd_handle, struct wma_tgt_cfg *cfg)
 {
 	int ret;
-	struct hdd_context *hdd_ctx = (struct hdd_context *)hdd_handle;
+	struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle);
 	uint8_t temp_band_cap;
 	struct cds_config_info *cds_cfg = cds_get_ini_config();
 	uint8_t antenna_mode;

+ 1 - 6
core/hdd/src/wlan_hdd_stats.c

@@ -2296,17 +2296,12 @@ void wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx,
 
 	hdd_enter();
 
-	if (!ctx) {
-		hdd_err("Invalid HDD context.");
-		return;
-	}
-
 	if (!rsp) {
 		hdd_err("Invalid result.");
 		return;
 	}
 
-	hdd_ctx = (struct hdd_context *)ctx;
+	hdd_ctx = hdd_handle_to_context(ctx);
 	linkLayer_stats_results = rsp;
 
 	status = wlan_hdd_validate_context(hdd_ctx);