All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath11k: use min() to make code cleaner
@ 2021-12-20 11:21 ` cgel.zte
  0 siblings, 0 replies; 5+ messages in thread
From: cgel.zte @ 2021-12-20 11:21 UTC (permalink / raw)
  To: kvalo
  Cc: davem, kuba, ath11k, linux-wireless, netdev, linux-kernel,
	Changcheng Deng, Zeal Robot

From: Changcheng Deng <deng.changcheng@zte.com.cn>

Use min() in order to make code cleaner.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/net/wireless/ath/ath11k/wmi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index 2b4d27d807ab..083856034136 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -614,8 +614,7 @@ int ath11k_wmi_mgmt_send(struct ath11k *ar, u32 vdev_id, u32 buf_id,
 	u32 buf_len;
 	int ret, len;
 
-	buf_len = frame->len < WMI_MGMT_SEND_DOWNLD_LEN ?
-		  frame->len : WMI_MGMT_SEND_DOWNLD_LEN;
+	buf_len = min(frame->len, WMI_MGMT_SEND_DOWNLD_LEN);
 
 	len = sizeof(*cmd) + sizeof(*frame_tlv) + roundup(buf_len, 4);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] ath11k: use min() to make code cleaner
@ 2021-12-20 11:21 ` cgel.zte
  0 siblings, 0 replies; 5+ messages in thread
From: cgel.zte @ 2021-12-20 11:21 UTC (permalink / raw)
  To: kvalo
  Cc: davem, kuba, ath11k, linux-wireless, netdev, linux-kernel,
	Changcheng Deng, Zeal Robot

From: Changcheng Deng <deng.changcheng@zte.com.cn>

Use min() in order to make code cleaner.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/net/wireless/ath/ath11k/wmi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c
index 2b4d27d807ab..083856034136 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -614,8 +614,7 @@ int ath11k_wmi_mgmt_send(struct ath11k *ar, u32 vdev_id, u32 buf_id,
 	u32 buf_len;
 	int ret, len;
 
-	buf_len = frame->len < WMI_MGMT_SEND_DOWNLD_LEN ?
-		  frame->len : WMI_MGMT_SEND_DOWNLD_LEN;
+	buf_len = min(frame->len, WMI_MGMT_SEND_DOWNLD_LEN);
 
 	len = sizeof(*cmd) + sizeof(*frame_tlv) + roundup(buf_len, 4);
 
-- 
2.25.1


-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ath11k: use min() to make code cleaner
  2021-12-20 11:21 ` cgel.zte
  (?)
@ 2021-12-20 17:12   ` kernel test robot
  -1 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-12-20 17:12 UTC (permalink / raw)
  To: cgel.zte, kvalo
  Cc: llvm, kbuild-all, davem, kuba, ath11k, linux-wireless, netdev,
	linux-kernel, Changcheng Deng, Zeal Robot

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kvalo-ath/ath-next]
[also build test WARNING on v5.16-rc6 next-20211220]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/ath11k-use-min-to-make-code-cleaner/20211220-192326
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: hexagon-randconfig-r001-20211220 (https://download.01.org/0day-ci/archive/20211221/202112210104.cbWjNxoN-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 555eacf75f21cd1dfc6363d73ad187b730349543)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/526b459a20794d7325764c3fea5fd3e0521d6084
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review cgel-zte-gmail-com/ath11k-use-min-to-make-code-cleaner/20211220-192326
        git checkout 526b459a20794d7325764c3fea5fd3e0521d6084
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/net/wireless/ath/ath11k/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/ath/ath11k/wmi.c:617:12: warning: comparison of distinct pointer types ('typeof (frame->len) *' (aka 'unsigned int *') and 'typeof (64) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
           buf_len = min(frame->len, WMI_MGMT_SEND_DOWNLD_LEN);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:45:19: note: expanded from macro 'min'
   #define min(x, y)       __careful_cmp(x, y, <)
                           ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
           __builtin_choose_expr(__safe_cmp(x, y), \
                                 ^~~~~~~~~~~~~~~~
   include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
                   (__typecheck(x, y) && __no_side_effects(x, y))
                    ^~~~~~~~~~~~~~~~~
   include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
           (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                      ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
   1 warning generated.


vim +617 drivers/net/wireless/ath/ath11k/wmi.c

   606	
   607	int ath11k_wmi_mgmt_send(struct ath11k *ar, u32 vdev_id, u32 buf_id,
   608				 struct sk_buff *frame)
   609	{
   610		struct ath11k_pdev_wmi *wmi = ar->wmi;
   611		struct wmi_mgmt_send_cmd *cmd;
   612		struct wmi_tlv *frame_tlv;
   613		struct sk_buff *skb;
   614		u32 buf_len;
   615		int ret, len;
   616	
 > 617		buf_len = min(frame->len, WMI_MGMT_SEND_DOWNLD_LEN);
   618	
   619		len = sizeof(*cmd) + sizeof(*frame_tlv) + roundup(buf_len, 4);
   620	
   621		skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
   622		if (!skb)
   623			return -ENOMEM;
   624	
   625		cmd = (struct wmi_mgmt_send_cmd *)skb->data;
   626		cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_MGMT_TX_SEND_CMD) |
   627				  FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
   628		cmd->vdev_id = vdev_id;
   629		cmd->desc_id = buf_id;
   630		cmd->chanfreq = 0;
   631		cmd->paddr_lo = lower_32_bits(ATH11K_SKB_CB(frame)->paddr);
   632		cmd->paddr_hi = upper_32_bits(ATH11K_SKB_CB(frame)->paddr);
   633		cmd->frame_len = frame->len;
   634		cmd->buf_len = buf_len;
   635		cmd->tx_params_valid = 0;
   636	
   637		frame_tlv = (struct wmi_tlv *)(skb->data + sizeof(*cmd));
   638		frame_tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
   639				    FIELD_PREP(WMI_TLV_LEN, buf_len);
   640	
   641		memcpy(frame_tlv->value, frame->data, buf_len);
   642	
   643		ath11k_ce_byte_swap(frame_tlv->value, buf_len);
   644	
   645		ret = ath11k_wmi_cmd_send(wmi, skb, WMI_MGMT_TX_SEND_CMDID);
   646		if (ret) {
   647			ath11k_warn(ar->ab,
   648				    "failed to submit WMI_MGMT_TX_SEND_CMDID cmd\n");
   649			dev_kfree_skb(skb);
   650		}
   651	
   652		return ret;
   653	}
   654	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ath11k: use min() to make code cleaner
@ 2021-12-20 17:12   ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-12-20 17:12 UTC (permalink / raw)
  To: cgel.zte, kvalo
  Cc: llvm, kbuild-all, davem, kuba, ath11k, linux-wireless, netdev,
	linux-kernel, Changcheng Deng, Zeal Robot

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kvalo-ath/ath-next]
[also build test WARNING on v5.16-rc6 next-20211220]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/ath11k-use-min-to-make-code-cleaner/20211220-192326
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: hexagon-randconfig-r001-20211220 (https://download.01.org/0day-ci/archive/20211221/202112210104.cbWjNxoN-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 555eacf75f21cd1dfc6363d73ad187b730349543)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/526b459a20794d7325764c3fea5fd3e0521d6084
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review cgel-zte-gmail-com/ath11k-use-min-to-make-code-cleaner/20211220-192326
        git checkout 526b459a20794d7325764c3fea5fd3e0521d6084
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/net/wireless/ath/ath11k/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/ath/ath11k/wmi.c:617:12: warning: comparison of distinct pointer types ('typeof (frame->len) *' (aka 'unsigned int *') and 'typeof (64) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
           buf_len = min(frame->len, WMI_MGMT_SEND_DOWNLD_LEN);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:45:19: note: expanded from macro 'min'
   #define min(x, y)       __careful_cmp(x, y, <)
                           ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
           __builtin_choose_expr(__safe_cmp(x, y), \
                                 ^~~~~~~~~~~~~~~~
   include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
                   (__typecheck(x, y) && __no_side_effects(x, y))
                    ^~~~~~~~~~~~~~~~~
   include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
           (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                      ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
   1 warning generated.


vim +617 drivers/net/wireless/ath/ath11k/wmi.c

   606	
   607	int ath11k_wmi_mgmt_send(struct ath11k *ar, u32 vdev_id, u32 buf_id,
   608				 struct sk_buff *frame)
   609	{
   610		struct ath11k_pdev_wmi *wmi = ar->wmi;
   611		struct wmi_mgmt_send_cmd *cmd;
   612		struct wmi_tlv *frame_tlv;
   613		struct sk_buff *skb;
   614		u32 buf_len;
   615		int ret, len;
   616	
 > 617		buf_len = min(frame->len, WMI_MGMT_SEND_DOWNLD_LEN);
   618	
   619		len = sizeof(*cmd) + sizeof(*frame_tlv) + roundup(buf_len, 4);
   620	
   621		skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
   622		if (!skb)
   623			return -ENOMEM;
   624	
   625		cmd = (struct wmi_mgmt_send_cmd *)skb->data;
   626		cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_MGMT_TX_SEND_CMD) |
   627				  FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
   628		cmd->vdev_id = vdev_id;
   629		cmd->desc_id = buf_id;
   630		cmd->chanfreq = 0;
   631		cmd->paddr_lo = lower_32_bits(ATH11K_SKB_CB(frame)->paddr);
   632		cmd->paddr_hi = upper_32_bits(ATH11K_SKB_CB(frame)->paddr);
   633		cmd->frame_len = frame->len;
   634		cmd->buf_len = buf_len;
   635		cmd->tx_params_valid = 0;
   636	
   637		frame_tlv = (struct wmi_tlv *)(skb->data + sizeof(*cmd));
   638		frame_tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
   639				    FIELD_PREP(WMI_TLV_LEN, buf_len);
   640	
   641		memcpy(frame_tlv->value, frame->data, buf_len);
   642	
   643		ath11k_ce_byte_swap(frame_tlv->value, buf_len);
   644	
   645		ret = ath11k_wmi_cmd_send(wmi, skb, WMI_MGMT_TX_SEND_CMDID);
   646		if (ret) {
   647			ath11k_warn(ar->ab,
   648				    "failed to submit WMI_MGMT_TX_SEND_CMDID cmd\n");
   649			dev_kfree_skb(skb);
   650		}
   651	
   652		return ret;
   653	}
   654	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ath11k: use min() to make code cleaner
@ 2021-12-20 17:12   ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-12-20 17:12 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4714 bytes --]

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kvalo-ath/ath-next]
[also build test WARNING on v5.16-rc6 next-20211220]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/ath11k-use-min-to-make-code-cleaner/20211220-192326
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: hexagon-randconfig-r001-20211220 (https://download.01.org/0day-ci/archive/20211221/202112210104.cbWjNxoN-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 555eacf75f21cd1dfc6363d73ad187b730349543)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/526b459a20794d7325764c3fea5fd3e0521d6084
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review cgel-zte-gmail-com/ath11k-use-min-to-make-code-cleaner/20211220-192326
        git checkout 526b459a20794d7325764c3fea5fd3e0521d6084
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/net/wireless/ath/ath11k/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/ath/ath11k/wmi.c:617:12: warning: comparison of distinct pointer types ('typeof (frame->len) *' (aka 'unsigned int *') and 'typeof (64) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
           buf_len = min(frame->len, WMI_MGMT_SEND_DOWNLD_LEN);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:45:19: note: expanded from macro 'min'
   #define min(x, y)       __careful_cmp(x, y, <)
                           ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
           __builtin_choose_expr(__safe_cmp(x, y), \
                                 ^~~~~~~~~~~~~~~~
   include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
                   (__typecheck(x, y) && __no_side_effects(x, y))
                    ^~~~~~~~~~~~~~~~~
   include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
           (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                      ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
   1 warning generated.


vim +617 drivers/net/wireless/ath/ath11k/wmi.c

   606	
   607	int ath11k_wmi_mgmt_send(struct ath11k *ar, u32 vdev_id, u32 buf_id,
   608				 struct sk_buff *frame)
   609	{
   610		struct ath11k_pdev_wmi *wmi = ar->wmi;
   611		struct wmi_mgmt_send_cmd *cmd;
   612		struct wmi_tlv *frame_tlv;
   613		struct sk_buff *skb;
   614		u32 buf_len;
   615		int ret, len;
   616	
 > 617		buf_len = min(frame->len, WMI_MGMT_SEND_DOWNLD_LEN);
   618	
   619		len = sizeof(*cmd) + sizeof(*frame_tlv) + roundup(buf_len, 4);
   620	
   621		skb = ath11k_wmi_alloc_skb(wmi->wmi_ab, len);
   622		if (!skb)
   623			return -ENOMEM;
   624	
   625		cmd = (struct wmi_mgmt_send_cmd *)skb->data;
   626		cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_MGMT_TX_SEND_CMD) |
   627				  FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE);
   628		cmd->vdev_id = vdev_id;
   629		cmd->desc_id = buf_id;
   630		cmd->chanfreq = 0;
   631		cmd->paddr_lo = lower_32_bits(ATH11K_SKB_CB(frame)->paddr);
   632		cmd->paddr_hi = upper_32_bits(ATH11K_SKB_CB(frame)->paddr);
   633		cmd->frame_len = frame->len;
   634		cmd->buf_len = buf_len;
   635		cmd->tx_params_valid = 0;
   636	
   637		frame_tlv = (struct wmi_tlv *)(skb->data + sizeof(*cmd));
   638		frame_tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) |
   639				    FIELD_PREP(WMI_TLV_LEN, buf_len);
   640	
   641		memcpy(frame_tlv->value, frame->data, buf_len);
   642	
   643		ath11k_ce_byte_swap(frame_tlv->value, buf_len);
   644	
   645		ret = ath11k_wmi_cmd_send(wmi, skb, WMI_MGMT_TX_SEND_CMDID);
   646		if (ret) {
   647			ath11k_warn(ar->ab,
   648				    "failed to submit WMI_MGMT_TX_SEND_CMDID cmd\n");
   649			dev_kfree_skb(skb);
   650		}
   651	
   652		return ret;
   653	}
   654	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-20 17:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 11:21 [PATCH] ath11k: use min() to make code cleaner cgel.zte
2021-12-20 11:21 ` cgel.zte
2021-12-20 17:12 ` kernel test robot
2021-12-20 17:12   ` kernel test robot
2021-12-20 17:12   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.