瀏覽代碼

qcacmn: qdf: Replace explicit comparison to NULL

Per the Linux Kernel coding style, as enforced by the kernel
checkpatch script, pointers should not be explicitly compared to
NULL. Therefore within qdf replace any such comparisons with logical
operations performed on the pointer itself.

Change-Id: Ie7662617dad8138b803dc54e7759d3b6d76c53ce
CRs-Fixed: 2418255
Jeff Johnson 6 年之前
父節點
當前提交
2831229bd7

+ 1 - 1
qdf/linux/src/qdf_crypto.c

@@ -223,7 +223,7 @@ int qdf_aes_s2v(const uint8_t *key, unsigned int key_len, const uint8_t *s[],
 	ret = qdf_get_keyed_hash(alg, key, key_len, a, &t_len, 1, out);
 
 error:
-	if (t != NULL && t != d)
+	if (t && t != d)
 		qdf_mem_free(t);
 	return ret;
 }

+ 3 - 3
qdf/linux/src/qdf_defer.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -38,7 +38,7 @@ void __qdf_defer_func(struct work_struct *work)
 {
 	__qdf_work_t *ctx = container_of(work, __qdf_work_t, work);
 
-	if (ctx->fn == NULL) {
+	if (!ctx->fn) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "No callback registered !!");
 		return;
@@ -58,7 +58,7 @@ __qdf_defer_delayed_func(struct work_struct *dwork)
 {
 	__qdf_delayed_work_t  *ctx = container_of(dwork, __qdf_delayed_work_t,
 		 dwork.work);
-	if (ctx->fn == NULL) {
+	if (!ctx->fn) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "BugCheck: Callback is not initilized while creating delayed work queue");
 		return;

+ 1 - 1
qdf/linux/src/qdf_event.c

@@ -248,7 +248,7 @@ void qdf_complete_wait_events(void)
 	qdf_list_peek_front(&qdf_wait_event_list,
 			    &list_node);
 
-	while (list_node != NULL) {
+	while (list_node) {
 		event_node = qdf_container_of(list_node,
 						struct qdf_evt_node, node);
 

+ 10 - 10
qdf/linux/src/qdf_lock.c

@@ -41,7 +41,7 @@
 QDF_STATUS qdf_mutex_create(qdf_mutex_t *lock, const char *func, int line)
 {
 	/* check for invalid pointer */
-	if (lock == NULL) {
+	if (!lock) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: NULL pointer passed in", __func__);
 		return QDF_STATUS_E_FAULT;
@@ -90,7 +90,7 @@ QDF_STATUS qdf_mutex_acquire(qdf_mutex_t *lock)
 {
 	int rc;
 	/* check for invalid pointer */
-	if (lock == NULL) {
+	if (!lock) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: NULL pointer passed in", __func__);
 		QDF_ASSERT(0);
@@ -168,7 +168,7 @@ qdf_export_symbol(qdf_mutex_acquire);
 QDF_STATUS qdf_mutex_release(qdf_mutex_t *lock)
 {
 	/* check for invalid pointer */
-	if (lock == NULL) {
+	if (!lock) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: NULL pointer passed in", __func__);
 		QDF_ASSERT(0);
@@ -407,7 +407,7 @@ QDF_STATUS qdf_runtime_pm_get(void)
 
 	ol_sc = cds_get_context(QDF_MODULE_ID_HIF);
 
-	if (ol_sc == NULL) {
+	if (!ol_sc) {
 		QDF_ASSERT(0);
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: HIF context is null!", __func__);
@@ -440,7 +440,7 @@ QDF_STATUS qdf_runtime_pm_put(void)
 
 	ol_sc = cds_get_context(QDF_MODULE_ID_HIF);
 
-	if (ol_sc == NULL) {
+	if (!ol_sc) {
 		QDF_ASSERT(0);
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: HIF context is null!", __func__);
@@ -470,7 +470,7 @@ QDF_STATUS qdf_runtime_pm_prevent_suspend(qdf_runtime_lock_t *lock)
 
 	ol_sc = cds_get_context(QDF_MODULE_ID_HIF);
 
-	if (ol_sc == NULL) {
+	if (!ol_sc) {
 		QDF_ASSERT(0);
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: HIF context is null!", __func__);
@@ -499,7 +499,7 @@ QDF_STATUS qdf_runtime_pm_allow_suspend(qdf_runtime_lock_t *lock)
 	int ret;
 
 	ol_sc = cds_get_context(QDF_MODULE_ID_HIF);
-	if (ol_sc == NULL) {
+	if (!ol_sc) {
 		QDF_ASSERT(0);
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 		"%s: HIF context is null!", __func__);
@@ -640,7 +640,7 @@ qdf_export_symbol(qdf_spinlock_release);
 QDF_STATUS qdf_mutex_destroy(qdf_mutex_t *lock)
 {
 	/* check for invalid pointer */
-	if (NULL == lock) {
+	if (!lock) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: NULL pointer passed in", __func__);
 		return QDF_STATUS_E_FAULT;
@@ -728,7 +728,7 @@ static bool qdf_is_lock_cookie_free(struct qdf_lock_cookie *lock_cookie)
 {
 	struct qdf_lock_cookie *tmp = lock_cookie->u.empty_node.next;
 
-	return qdf_is_lock_cookie(tmp) || (tmp == NULL);
+	return qdf_is_lock_cookie(tmp) || (!tmp);
 }
 
 static struct qdf_lock_cookie *qdf_get_lock_cookie(void)
@@ -798,7 +798,7 @@ void qdf_lock_stats_cookie_create(struct lock_stats *stats,
 {
 	struct qdf_lock_cookie *cookie = qdf_get_lock_cookie();
 
-	if (cookie == NULL) {
+	if (!cookie) {
 		int count;
 
 		qdf_atomic_inc(&lock_cookie_get_failures);

+ 7 - 7
qdf/linux/src/qdf_mc_timer.c

@@ -98,7 +98,7 @@ qdf_export_symbol(qdf_try_allowing_sleep);
  */
 QDF_TIMER_STATE qdf_mc_timer_get_current_state(qdf_mc_timer_t *timer)
 {
-	if (NULL == timer) {
+	if (!timer) {
 		QDF_ASSERT(0);
 		return QDF_TIMER_STATE_UNUSED;
 	}
@@ -357,7 +357,7 @@ QDF_STATUS qdf_mc_timer_init_debug(qdf_mc_timer_t *timer,
 	QDF_STATUS qdf_status;
 
 	/* check for invalid pointer */
-	if ((timer == NULL) || (callback == NULL)) {
+	if ((!timer) || (!callback)) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: Null params being passed", __func__);
 		QDF_ASSERT(0);
@@ -406,7 +406,7 @@ QDF_STATUS qdf_mc_timer_init(qdf_mc_timer_t *timer, QDF_TIMER_TYPE timer_type,
 			     void *user_data)
 {
 	/* check for invalid pointer */
-	if ((timer == NULL) || (callback == NULL)) {
+	if ((!timer) || (!callback)) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: Null params being passed", __func__);
 		QDF_ASSERT(0);
@@ -459,7 +459,7 @@ QDF_STATUS qdf_mc_timer_destroy(qdf_mc_timer_t *timer)
 	QDF_STATUS v_status = QDF_STATUS_SUCCESS;
 
 	/* check for invalid pointer */
-	if (NULL == timer) {
+	if (!timer) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: Null timer pointer being passed", __func__);
 		QDF_ASSERT(0);
@@ -557,7 +557,7 @@ QDF_STATUS qdf_mc_timer_destroy(qdf_mc_timer_t *timer)
 	QDF_STATUS v_status = QDF_STATUS_SUCCESS;
 
 	/* check for invalid pointer */
-	if (NULL == timer) {
+	if (!timer) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s: Null timer pointer being passed", __func__);
 		QDF_ASSERT(0);
@@ -637,7 +637,7 @@ qdf_export_symbol(qdf_mc_timer_destroy);
 QDF_STATUS qdf_mc_timer_start(qdf_mc_timer_t *timer, uint32_t expiration_time)
 {
 	/* check for invalid pointer */
-	if (NULL == timer) {
+	if (!timer) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s Null timer pointer being passed", __func__);
 		QDF_ASSERT(0);
@@ -718,7 +718,7 @@ qdf_export_symbol(qdf_mc_timer_start);
 QDF_STATUS qdf_mc_timer_stop(qdf_mc_timer_t *timer)
 {
 	/* check for invalid pointer */
-	if (NULL == timer) {
+	if (!timer) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s Null timer pointer being passed", __func__);
 		QDF_ASSERT(0);

+ 6 - 6
qdf/linux/src/qdf_mem.c

@@ -691,7 +691,7 @@ int __qdf_mempool_init(qdf_device_t osdev, __qdf_mempool_t *pool_addr,
 		 */
 		new_pool = (__qdf_mempool_ctxt_t *)
 			kmalloc(sizeof(__qdf_mempool_ctxt_t), GFP_KERNEL);
-		if (new_pool == NULL)
+		if (!new_pool)
 			return QDF_STATUS_E_NOMEM;
 
 		memset(new_pool, 0, sizeof(*new_pool));
@@ -704,7 +704,7 @@ int __qdf_mempool_init(qdf_device_t osdev, __qdf_mempool_t *pool_addr,
 	}
 
 	for (pool_id = 0; pool_id < MAX_MEM_POOLS; pool_id++) {
-		if (osdev->mem_pool[pool_id] == NULL)
+		if (!osdev->mem_pool[pool_id])
 			break;
 	}
 
@@ -713,7 +713,7 @@ int __qdf_mempool_init(qdf_device_t osdev, __qdf_mempool_t *pool_addr,
 
 	new_pool = osdev->mem_pool[pool_id] = (__qdf_mempool_ctxt_t *)
 		kmalloc(sizeof(__qdf_mempool_ctxt_t), GFP_KERNEL);
-	if (new_pool == NULL)
+	if (!new_pool)
 		return -ENOMEM;
 
 	memset(new_pool, 0, sizeof(*new_pool));
@@ -727,7 +727,7 @@ int __qdf_mempool_init(qdf_device_t osdev, __qdf_mempool_t *pool_addr,
 				((align)?(align - 1):0);
 
 	new_pool->pool_mem = kzalloc(new_pool->mem_size, GFP_KERNEL);
-	if (new_pool->pool_mem == NULL) {
+	if (!new_pool->pool_mem) {
 			/* TBD: Check if we need get_free_pages above */
 		kfree(new_pool);
 		osdev->mem_pool[pool_id] = NULL;
@@ -802,7 +802,7 @@ void *__qdf_mempool_alloc(qdf_device_t osdev, __qdf_mempool_t pool)
 	spin_lock_bh(&pool->lock);
 
 	buf = STAILQ_FIRST(&pool->free_list);
-	if (buf != NULL) {
+	if (buf) {
 		STAILQ_REMOVE_HEAD(&pool->free_list, mempool_entry);
 		pool->free_cnt--;
 	}
@@ -1805,7 +1805,7 @@ qdf_export_symbol(qdf_mem_exit);
  */
 void qdf_ether_addr_copy(void *dst_addr, const void *src_addr)
 {
-	if ((dst_addr == NULL) || (src_addr == NULL)) {
+	if ((!dst_addr) || (!src_addr)) {
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "%s called with NULL parameter, source:%pK destination:%pK",
 			  __func__, src_addr, dst_addr);

+ 6 - 6
qdf/linux/src/qdf_nbuf.c

@@ -2175,7 +2175,7 @@ static QDF_NBUF_TRACK *qdf_nbuf_track_alloc(void)
 
 	spin_lock_irqsave(&qdf_net_buf_track_free_list_lock, irq_flag);
 	qdf_net_buf_track_used_list_count++;
-	if (qdf_net_buf_track_free_list != NULL) {
+	if (qdf_net_buf_track_free_list) {
 		new_node = qdf_net_buf_track_free_list;
 		qdf_net_buf_track_free_list =
 			qdf_net_buf_track_free_list->p_next;
@@ -2184,7 +2184,7 @@ static QDF_NBUF_TRACK *qdf_nbuf_track_alloc(void)
 	update_max_used();
 	spin_unlock_irqrestore(&qdf_net_buf_track_free_list_lock, irq_flag);
 
-	if (new_node != NULL)
+	if (new_node)
 		return new_node;
 
 	if (in_interrupt() || irqs_disabled() || in_atomic())
@@ -2254,7 +2254,7 @@ static void qdf_nbuf_track_prefill(void)
 	head = NULL;
 	for (i = 0; i < FREEQ_POOLSIZE; i++) {
 		node = qdf_nbuf_track_alloc();
-		if (node == NULL)
+		if (!node)
 			continue;
 		node->p_next = head;
 		head = node;
@@ -2570,7 +2570,7 @@ void qdf_net_buf_debug_delete_node(qdf_nbuf_t net_buf)
 	while (p_node) {
 		p_prev = p_node;
 		p_node = p_node->p_next;
-		if ((NULL != p_node) && (p_node->net_buf == net_buf)) {
+		if ((p_node) && (p_node->net_buf == net_buf)) {
 			p_prev->p_next = p_node->p_next;
 			break;
 		}
@@ -3604,7 +3604,7 @@ qdf_export_symbol(__qdf_nbuf_dma_map_info);
 void
 __qdf_nbuf_frag_info(struct sk_buff *skb, qdf_sglist_t  *sg)
 {
-	qdf_assert(skb != NULL);
+	qdf_assert(skb);
 	sg->sg_segs[0].vaddr = skb->data;
 	sg->sg_segs[0].len   = skb->len;
 	sg->nsegs            = 1;
@@ -3630,7 +3630,7 @@ __qdf_nbuf_frag_info(struct sk_buff *skb, qdf_sglist_t  *sg)
 
 	struct skb_shared_info  *sh = skb_shinfo(skb);
 
-	qdf_assert(skb != NULL);
+	qdf_assert(skb);
 	sg->sg_segs[0].vaddr = skb->data;
 	sg->sg_segs[0].len   = skb->len;
 	sg->nsegs            = 1;

+ 5 - 5
qdf/linux/src/qdf_trace.c

@@ -449,7 +449,7 @@ void qdf_trace_enable(uint32_t bitmask_of_module_id, uint8_t enable)
 	} else {
 		if (enable) {
 			for (i = 0; i < QDF_MODULE_ID_MAX; i++) {
-				if (NULL != qdf_trace_restore_cb_table[i]) {
+				if (qdf_trace_restore_cb_table[i]) {
 					qdf_trace_cb_table[i] =
 						qdf_trace_restore_cb_table[i];
 				}
@@ -536,7 +536,7 @@ void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data)
 		return;
 
 	/* if module is not registered, don't record for that module */
-	if (NULL == qdf_trace_cb_table[module])
+	if (!qdf_trace_cb_table[module])
 		return;
 
 	qdf_get_time_of_the_day_in_hr_min_sec_usec(time, sizeof(time));
@@ -710,7 +710,7 @@ void qdf_trace_dump_all(void *p_mac, uint8_t code, uint8_t session,
 		spin_unlock(&ltrace_lock);
 		for (;; ) {
 			if ((code == 0 || (code == p_record.code)) &&
-			    (qdf_trace_cb_table[p_record.module] != NULL)) {
+			    (qdf_trace_cb_table[p_record.module])) {
 				if (0 == bitmask_of_module) {
 					qdf_trace_cb_table[p_record.
 							   module] (p_mac,
@@ -799,7 +799,7 @@ QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size,
 	char *buf_ptr = buf;
 
 	for (module = 0; module < QDF_MODULE_ID_MAX; module++) {
-		if (NULL != qdf_state_info_table[module]) {
+		if (qdf_state_info_table[module]) {
 			qdf_state_info_table[module](&buf_ptr, &buf_len);
 			if (!buf_len) {
 				ret = QDF_STATUS_E_NOMEM;
@@ -3180,7 +3180,7 @@ static void process_qdf_dbg_arr_param(struct category_info *cinfo,
 	mod_val_str = qdf_dbg_arr[array_index];
 	mod_str = strsep(&mod_val_str, "=");
 	val_str = mod_val_str;
-	if (val_str == NULL) {
+	if (!val_str) {
 		pr_info("qdf_dbg_arr: %s not in the <mod>=<val> form\n",
 				mod_str);
 		return;