Message ID | Y1neXqVYZ8mq8jH+@marshmallow |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp581422wru; Wed, 26 Oct 2022 18:37:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MqA+BjG+mOJKXn+/Uwg/pQJoBTieU9eo85T6ZxUMcNZJzG/7jVfHb5OaVFlg7Csh4BRxc X-Received: by 2002:a17:90b:380b:b0:20d:7364:796f with SMTP id mq11-20020a17090b380b00b0020d7364796fmr7116513pjb.13.1666834640232; Wed, 26 Oct 2022 18:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666834640; cv=none; d=google.com; s=arc-20160816; b=LPI7GN8WCg6qFZQKwgtXdazcEXBgE+XxI9x1baYmrZKDiy0hqwYn3st+CvT8VNIG0S bGZIfKS3XcLtiUOv7AUv/LOWmllZgfH3vM8R5MquiqSPoXpMH7V+dLfIueeHW7Ymoa8t 7Cmy233jg4ruBO0UgGL1vhvDZF8BzJQqgWNL1KXa3+3SXYIWbWVpT28owSMea72/mLXH UkjPNAYiDvVRkMz/hOc5KaHpQDVdDZh8IrUKriKptBvMhwwpIfFwNIEkjb2K22dKJjYR V9n+krUMjO6EAEZKCvrYn5nT/aw5nN6Lxt98m02lysQWBZVyNTerTfIR+SOAOhfX6k2C jGRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=GHA4PABhtEK1rXCzmMniG/pV1qITSZAaITYQ81bgOXc=; b=DZmf6GBC5p64JrOtR7XIfnfCiEdff4d4o7UiXkGa5KaqufuqvDKL7/lumzqRp6N0s4 5Jt9zMc+oWhA1+qedE8LFwzHCSsMdbgUVYK2qInKMja6U26+66W5cNQQfhVFKXNDOQH8 sMy+1N49Tphv9blAYueCMAQFivlJoPq6fNC10ojg2Ygyt21sVA3Int37Afk8GnqyV7CF YIvKS7DVJPb73YX3igUd6LkQpVxLbWVrfJaxZrsImDzQNpaTSvb9eUgFAMvFk9c/dw2+ Vawva7O357OUKbtd2j1MMci/1T2IY+bp1Th4Ezlthzy1H49eE3c7AClJRUGfFZ7Tg+X7 y5Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oZtRdUiV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u4-20020a63f644000000b0045fd05b2ce8si8980458pgj.239.2022.10.26.18.37.07; Wed, 26 Oct 2022 18:37:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oZtRdUiV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233487AbiJ0B1B (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Wed, 26 Oct 2022 21:27:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233244AbiJ0B06 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 26 Oct 2022 21:26:58 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 574FA6B64B for <linux-kernel@vger.kernel.org>; Wed, 26 Oct 2022 18:26:58 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id t10-20020a17090a4e4a00b0020af4bcae10so20472pjl.3 for <linux-kernel@vger.kernel.org>; Wed, 26 Oct 2022 18:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=GHA4PABhtEK1rXCzmMniG/pV1qITSZAaITYQ81bgOXc=; b=oZtRdUiV4y1KcexeIjhm5ZaiRVBbr/CjhTTKej0NGu1CTmnwmXu37d0Y24JHY7HEKt 7s6XazoTKjYXoD0jedPfTjRl2jwpQHqzet7yg/RjpRRJyOjObRZXttCs4veLT3lIHD86 C29pmXUHUx7AHZgZH5G/JGnL39YQdSckDLNy5IN/45+EFgSeF/gHH88qdut8K6fQiXC3 VOaMOo5QbFS3Fnd0ntmFp1ZuMUUURgyHRHi4eJ3H+KC+toON1Pity1aBmGFLZBYVfxfX ymSxLypehov09orGq+EaXgAj54GIVn9L35j3wf2mY01wTIHVmKy+upRoqyPhG2h7uSUF FUiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GHA4PABhtEK1rXCzmMniG/pV1qITSZAaITYQ81bgOXc=; b=Mo/0192qbMNiIXIvZ98HLE2ds9Mvm4g/9yxS93Ex7r51ZLiieE/o49j0reRdJ9cBIx O8kUiXVIjUXGYgnsBWChlqvYykUHWbf+qXczYMRx2VItalwjeqHoLS3wkSsXGr18ac7X 8aYtiCAR+Zzk/7dQYiD1kNs27tu0o5Vp60F2Den2WNJjRlZvtQvfwRilHUBkuVl4Wcdb Od2N+xoP2L6ohxj/C912d77nJZx0HQhZYhAgozcIk1e0h1WL1aHwv7eU4QoQxpN4z+xT j4L7YdF69baep2mhlu7NPq7vY72EjBotsfp9kijWWTAOOi58CH72MrpeL+fH7Am5W16g 2fyA== X-Gm-Message-State: ACrzQf2ogqmkbu4GIrqU9qtPrzYsF6c7isBGxmQKJDgQ0vn2Hwx2sTQf 0kAMrpg5oXqlbtTiMQCk2pxbIg5So90XyA== X-Received: by 2002:a17:90a:b10b:b0:212:fbc3:e623 with SMTP id z11-20020a17090ab10b00b00212fbc3e623mr7386982pjq.5.1666834017847; Wed, 26 Oct 2022 18:26:57 -0700 (PDT) Received: from marshmallow (192-184-163-51.fiber.dynamic.sonic.net. [192.184.163.51]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a178600b00210c84b8ae5sm7533pja.35.2022.10.26.18.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 18:26:57 -0700 (PDT) Date: Wed, 26 Oct 2022 18:26:54 -0700 From: Emily Peri <eperi1024@gmail.com> To: gregkh@linuxfoundation.org, outreachy@lists.linux.dev, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] staging: rtl8723bs: Replace ternary statement with min function Message-ID: <Y1neXqVYZ8mq8jH+@marshmallow> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747802799551870966?= X-GMAIL-MSGID: =?utf-8?q?1747802799551870966?= |
Series |
staging: rtl8723bs: Replace ternary statement with min function
|
|
Commit Message
Emily Peri
Oct. 27, 2022, 1:26 a.m. UTC
Ternary statements that pick the min of two values can be replaced by
the built-in min() function. This improves readability, since its quicker
to understand min(x, y) than x < y ? x : y. Issue found by coccicheck.
Signed-off-by: Emily Peri <eperi1024@gmail.com>
---
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, 26 Oct 2022, Emily Peri wrote: > Ternary statements that pick the min of two values can be replaced by > the built-in min() function. This improves readability, since its quicker > to understand min(x, y) than x < y ? x : y. Issue found by coccicheck. It looks like a nice change, but I get a compiler error afer the patch, julia > > Signed-off-by: Emily Peri <eperi1024@gmail.com> > --- > drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > index 6aeb169c6ebf..0cf7d9f82b83 100644 > --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > @@ -1551,7 +1551,7 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel > > wps_ie = rtw_get_wps_ie(buf, ielen, NULL, &wps_ielen); > if (wps_ie && wps_ielen > 0) { > - padapter->securitypriv.wps_ie_len = wps_ielen < MAX_WPS_IE_LEN ? wps_ielen : MAX_WPS_IE_LEN; > + padapter->securitypriv.wps_ie_len = min(wps_ielen, MAX_WPS_IE_LEN); > memcpy(padapter->securitypriv.wps_ie, wps_ie, padapter->securitypriv.wps_ie_len); > set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); > } else { > -- > 2.34.1 > > >
On Wed, Oct 26, 2022 at 06:26:54PM -0700, Emily Peri wrote: > Ternary statements that pick the min of two values can be replaced by > the built-in min() function. This improves readability, since its quicker > to understand min(x, y) than x < y ? x : y. Issue found by coccicheck. > > Signed-off-by: Emily Peri <eperi1024@gmail.com> This breaks the build. Use min_t(uint, wps_ielen, MAX_WPS_IE_LEN); regards, dan carpenter
On Thu, Oct 27, 2022 at 08:12:14AM +0200, Julia Lawall wrote: > > > On Wed, 26 Oct 2022, Emily Peri wrote: > > > Ternary statements that pick the min of two values can be replaced by > > the built-in min() function. This improves readability, since its quicker > > to understand min(x, y) than x < y ? x : y. Issue found by coccicheck. > > It looks like a nice change, but I get a compiler error afer the patch, > > julia Okay, I think I know the issue. Another person commented (Dan Carpenter) that the function needs to be min_t, I'm guessing so the function returns the value as the correct type. But one thing I'm wondering is, why I didn't I get a compiler error when I compiled the kernel myself? Also-- this is just a general question, when we work on drivers I'm guessing we don't need to include header files from include/linux, right? > > > > Signed-off-by: Emily Peri <eperi1024@gmail.com> > > --- > > drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > > index 6aeb169c6ebf..0cf7d9f82b83 100644 > > --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > > +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c > > @@ -1551,7 +1551,7 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel > > > > wps_ie = rtw_get_wps_ie(buf, ielen, NULL, &wps_ielen); > > if (wps_ie && wps_ielen > 0) { > > - padapter->securitypriv.wps_ie_len = wps_ielen < MAX_WPS_IE_LEN ? wps_ielen : MAX_WPS_IE_LEN; > > + padapter->securitypriv.wps_ie_len = min(wps_ielen, MAX_WPS_IE_LEN); > > memcpy(padapter->securitypriv.wps_ie, wps_ie, padapter->securitypriv.wps_ie_len); > > set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); > > } else { > > -- > > 2.34.1 > > > > > >
On Thu, Oct 27, 2022 at 10:32:15AM +0300, Dan Carpenter wrote: > On Wed, Oct 26, 2022 at 06:26:54PM -0700, Emily Peri wrote: > > Ternary statements that pick the min of two values can be replaced by > > the built-in min() function. This improves readability, since its quicker > > to understand min(x, y) than x < y ? x : y. Issue found by coccicheck. > > > > Signed-off-by: Emily Peri <eperi1024@gmail.com> > > This breaks the build. Use min_t(uint, wps_ielen, MAX_WPS_IE_LEN); > > regards, > dan carpenter Oh! Thanks for the feedback, that makes sense! When you say 'breaks the build,' do you mean it didn't compile, or the module didn't load (or something else)? I'm trying to figure out what I did wrong when testing it. Best, Emily
On Fri, 28 Oct 2022, Emily Peri wrote: > On Thu, Oct 27, 2022 at 10:32:15AM +0300, Dan Carpenter wrote: > > On Wed, Oct 26, 2022 at 06:26:54PM -0700, Emily Peri wrote: > > > Ternary statements that pick the min of two values can be replaced by > > > the built-in min() function. This improves readability, since its quicker > > > to understand min(x, y) than x < y ? x : y. Issue found by coccicheck. > > > > > > Signed-off-by: Emily Peri <eperi1024@gmail.com> > > > > This breaks the build. Use min_t(uint, wps_ielen, MAX_WPS_IE_LEN); > > > > regards, > > dan carpenter > > Oh! Thanks for the feedback, that makes sense! When you say 'breaks the > build,' do you mean it didn't compile, or the module didn't load (or > something else)? I'm trying to figure out what I did wrong when testing > it. Normally it means that it didn't compile. Check that you actually have a .o file for the affected file. julia
Hi Emily, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on staging/staging-testing] url: https://github.com/intel-lab-lkp/linux/commits/Emily-Peri/staging-rtl8723bs-Replace-ternary-statement-with-min-function/20221027-092729 patch link: https://lore.kernel.org/r/Y1neXqVYZ8mq8jH%2B%40marshmallow patch subject: [PATCH] staging: rtl8723bs: Replace ternary statement with min function config: powerpc-allyesconfig compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920) 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 # install powerpc cross compiling tool for clang build # apt-get install binutils-powerpc-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/c222133e1748e829da70718b25eccc968ab1a073 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Emily-Peri/staging-rtl8723bs-Replace-ternary-statement-with-min-function/20221027-092729 git checkout c222133e1748e829da70718b25eccc968ab1a073 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/staging/rtl8723bs/ drivers/tty/serial/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:1554:40: warning: comparison of distinct pointer types ('typeof (wps_ielen) *' (aka 'unsigned int *') and 'typeof ((512)) *' (aka 'int *')) [-Wcompare-distinct-pointer-types] padapter->securitypriv.wps_ie_len = min(wps_ielen, MAX_WPS_IE_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 +1554 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 1443 1444 static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t ielen) 1445 { 1446 u8 *buf = NULL; 1447 int group_cipher = 0, pairwise_cipher = 0; 1448 int ret = 0; 1449 int wpa_ielen = 0; 1450 int wpa2_ielen = 0; 1451 u8 *pwpa, *pwpa2; 1452 u8 null_addr[] = {0, 0, 0, 0, 0, 0}; 1453 1454 if (!pie || !ielen) { 1455 /* Treat this as normal case, but need to clear WIFI_UNDER_WPS */ 1456 _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); 1457 goto exit; 1458 } 1459 1460 if (ielen > MAX_WPA_IE_LEN+MAX_WPS_IE_LEN+MAX_P2P_IE_LEN) { 1461 ret = -EINVAL; 1462 goto exit; 1463 } 1464 1465 buf = rtw_zmalloc(ielen); 1466 if (!buf) { 1467 ret = -ENOMEM; 1468 goto exit; 1469 } 1470 1471 memcpy(buf, pie, ielen); 1472 1473 if (ielen < RSN_HEADER_LEN) { 1474 ret = -1; 1475 goto exit; 1476 } 1477 1478 pwpa = rtw_get_wpa_ie(buf, &wpa_ielen, ielen); 1479 if (pwpa && wpa_ielen > 0) { 1480 if (rtw_parse_wpa_ie(pwpa, wpa_ielen+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { 1481 padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; 1482 padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; 1483 memcpy(padapter->securitypriv.supplicant_ie, &pwpa[0], wpa_ielen+2); 1484 } 1485 } 1486 1487 pwpa2 = rtw_get_wpa2_ie(buf, &wpa2_ielen, ielen); 1488 if (pwpa2 && wpa2_ielen > 0) { 1489 if (rtw_parse_wpa2_ie(pwpa2, wpa2_ielen+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { 1490 padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; 1491 padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; 1492 memcpy(padapter->securitypriv.supplicant_ie, &pwpa2[0], wpa2_ielen+2); 1493 } 1494 } 1495 1496 if (group_cipher == 0) 1497 group_cipher = WPA_CIPHER_NONE; 1498 1499 if (pairwise_cipher == 0) 1500 pairwise_cipher = WPA_CIPHER_NONE; 1501 1502 switch (group_cipher) { 1503 case WPA_CIPHER_NONE: 1504 padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; 1505 padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; 1506 break; 1507 case WPA_CIPHER_WEP40: 1508 padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; 1509 padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; 1510 break; 1511 case WPA_CIPHER_TKIP: 1512 padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; 1513 padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; 1514 break; 1515 case WPA_CIPHER_CCMP: 1516 padapter->securitypriv.dot118021XGrpPrivacy = _AES_; 1517 padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; 1518 break; 1519 case WPA_CIPHER_WEP104: 1520 padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; 1521 padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; 1522 break; 1523 } 1524 1525 switch (pairwise_cipher) { 1526 case WPA_CIPHER_NONE: 1527 padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; 1528 padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; 1529 break; 1530 case WPA_CIPHER_WEP40: 1531 padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; 1532 padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; 1533 break; 1534 case WPA_CIPHER_TKIP: 1535 padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; 1536 padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; 1537 break; 1538 case WPA_CIPHER_CCMP: 1539 padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; 1540 padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; 1541 break; 1542 case WPA_CIPHER_WEP104: 1543 padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; 1544 padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; 1545 break; 1546 } 1547 1548 {/* handle wps_ie */ 1549 uint wps_ielen; 1550 u8 *wps_ie; 1551 1552 wps_ie = rtw_get_wps_ie(buf, ielen, NULL, &wps_ielen); 1553 if (wps_ie && wps_ielen > 0) { > 1554 padapter->securitypriv.wps_ie_len = min(wps_ielen, MAX_WPS_IE_LEN); 1555 memcpy(padapter->securitypriv.wps_ie, wps_ie, padapter->securitypriv.wps_ie_len); 1556 set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); 1557 } else { 1558 _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); 1559 } 1560 } 1561 1562 /* TKIP and AES disallow multicast packets until installing group key */ 1563 if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ 1564 || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ 1565 || padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) 1566 /* WPS open need to enable multicast */ 1567 /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */ 1568 rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr); 1569 1570 exit: 1571 kfree(buf); 1572 if (ret) 1573 _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); 1574 return ret; 1575 } 1576
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 6aeb169c6ebf..0cf7d9f82b83 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1551,7 +1551,7 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel wps_ie = rtw_get_wps_ie(buf, ielen, NULL, &wps_ielen); if (wps_ie && wps_ielen > 0) { - padapter->securitypriv.wps_ie_len = wps_ielen < MAX_WPS_IE_LEN ? wps_ielen : MAX_WPS_IE_LEN; + padapter->securitypriv.wps_ie_len = min(wps_ielen, MAX_WPS_IE_LEN); memcpy(padapter->securitypriv.wps_ie, wps_ie, padapter->securitypriv.wps_ie_len); set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); } else {