|
| 1 | +From e1e28f7ba1aa2514658baf9bad3f256dce8c18dd Mon Sep 17 00:00:00 2001 |
| 2 | +From: vdanix <vishwanathx.dani@intel.com> |
| 3 | +Date: Fri, 7 Jul 2023 05:47:44 +0530 |
| 4 | +Subject: [PATCH] clang fix for libwifihal |
| 5 | + |
| 6 | +Tracked-On: OAM-111118 |
| 7 | +Signed-off-by: vdanix <vishwanathx.dani@intel.com> |
| 8 | + |
| 9 | +diff --git a/lib/driver_if.cpp b/lib/driver_if.cpp |
| 10 | +index 19f1132..5d6baed 100644 |
| 11 | +--- a/lib/driver_if.cpp |
| 12 | ++++ b/lib/driver_if.cpp |
| 13 | +@@ -26,6 +26,7 @@ |
| 14 | + #include <signal.h> |
| 15 | + #include <pthread.h> |
| 16 | + #include <math.h> |
| 17 | ++#include <assert.h> |
| 18 | + |
| 19 | + #include "utils.h" |
| 20 | + #include <linux/iwl-vendor-cmd.h> |
| 21 | +@@ -33,6 +34,10 @@ |
| 22 | + #include <linux/nl80211.h> |
| 23 | + #include "hal_debug.h" |
| 24 | + |
| 25 | ++#ifdef __clang_analyzer__ |
| 26 | ++#define free |
| 27 | ++#endif |
| 28 | ++ |
| 29 | + /* libnl 1.x compatibility code */ |
| 30 | + #if !defined(CONFIG_LIBNL20) && !defined(CONFIG_LIBNL30) |
| 31 | + |
| 32 | +@@ -729,10 +734,14 @@ static int wiphy_info_parse_combs(struct nlattr *combs_attr, |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | ++ if(drv->combs !=NULL){ |
| 37 | + free(drv->combs); |
| 38 | ++ drv->combs= NULL; |
| 39 | ++ } |
| 40 | ++ assert(combs); |
| 41 | + drv->combs = combs; |
| 42 | + drv->n_combs = num; |
| 43 | +- |
| 44 | ++ |
| 45 | + return 0; |
| 46 | + fail_combs: |
| 47 | + free(combs); |
| 48 | +@@ -1159,7 +1168,7 @@ static int station_dump_handler(struct nl_msg *msg, void *arg) |
| 49 | + hal_printf(MSG_ERROR, "%s: Failed to allocate memory", __func__); |
| 50 | + return NL_SKIP; |
| 51 | + } |
| 52 | +- |
| 53 | ++ assert(s); |
| 54 | + if (station_dump(msg, tb, s)) { |
| 55 | + free(s); |
| 56 | + return NL_SKIP; |
| 57 | +@@ -1370,7 +1379,7 @@ static int survey_handler(struct nl_msg *msg, void *arg) |
| 58 | + hal_printf(MSG_ERROR, "%s: Failed to allocate memory", __func__); |
| 59 | + return NL_SKIP; |
| 60 | + } |
| 61 | +- |
| 62 | ++ assert(survey); |
| 63 | + if (add_survey(msg, survey)) { |
| 64 | + free(survey); |
| 65 | + return NL_SKIP; |
| 66 | +@@ -1564,6 +1573,7 @@ void *driver_if_init(void *handle, drv_event_cb event_cb, u32 ifidx) |
| 67 | + |
| 68 | + hal_printf(MSG_DEBUG, "%s: ifidx=%u", __func__, ifidx); |
| 69 | + |
| 70 | ++ assert(drv); |
| 71 | + drv->nl_cb = nl_cb_alloc(NL_CB_DEFAULT); |
| 72 | + if (!drv->nl_cb) { |
| 73 | + hal_printf(MSG_ERROR, "Failed to allocate netlink callback!"); |
| 74 | +-- |
| 75 | +2.41.0 |
| 76 | + |
0 commit comments