From patchwork Thu Apr 7 11:00:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 8771031 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 137909F36E for ; Thu, 7 Apr 2016 11:01:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7998B20204 for ; Thu, 7 Apr 2016 11:00:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA7A4201EC for ; Thu, 7 Apr 2016 11:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755431AbcDGLAg (ORCPT ); Thu, 7 Apr 2016 07:00:36 -0400 Received: from smtprelay0231.hostedemail.com ([216.40.44.231]:53796 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755272AbcDGLAf (ORCPT ); Thu, 7 Apr 2016 07:00:35 -0400 Received: from filter.hostedemail.com (unknown [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id 8319D268E11; Thu, 7 Apr 2016 11:00:33 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, joe@perches.com, :::::::::::::::, RULES_HIT:41:69:355:379:541:599:966:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1535:1544:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2553:2559:2562:2828:2914:3138:3139:3140:3141:3142:3354:3622:3865:3867:3868:3872:3874:4321:4385:5007:7903:8957:10004:10848:11026:11232:11473:11658:11783:11914:12043:12296:12438:12517:12519:12555:12740:13161:13229:13439:13894:14181:14659:14721:21060:21080:30012:30054:30090:30091, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0, LFtime:4, LUA_SUMMARY:none X-HE-Tag: pot04_79126245c6f0f X-Filterd-Recvd-Size: 5129 Received: from XPS-9350.home (unknown [71.118.176.190]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Thu, 7 Apr 2016 11:00:31 +0000 (UTC) Message-ID: <1460026830.6715.80.camel@perches.com> Subject: Re: [PATCH 525/525] Staging: Wilc1000: Fixed coding style ether_addr_copy From: Joe Perches To: Shyam Saini , johnny.kim@atmel.com Cc: austin.shin@atmel.com, chris.park@atmel.com, tony.cho@atmel.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Date: Thu, 07 Apr 2016 04:00:30 -0700 In-Reply-To: <1460021835-8370-1-git-send-email-mayhs11saini@gmail.com> References: <1460021835-8370-1-git-send-email-mayhs11saini@gmail.com> X-Mailer: Evolution 3.18.5.2-0ubuntu1 Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 2016-04-07 at 15:07 +0530, Shyam Saini wrote: > Fixed following warning detected by checkpatch.pl: > warning: Prefer ether_addr_copy() over memcpy() if the Ethernet addressesare __aligned(2) Please don't just do checkpatch cleanups but strive to make the code more intelligible for humans. Also, there's a malloc that may fail that writes through the returned pointer that could be NULL. The kmalloc/memcpy could be a kmemdup. It would make the code shorter and clearer to remove u32 ap_index and use a temporary pointer for all the last_scanned_shadow[ap_index]. uses instead. Something like: ---  drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 54 +++++++++++------------  1 file changed, 25 insertions(+), 29 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 358632b..35696e2 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -339,49 +339,45 @@ static void add_network_to_shadow(struct network_info *pstrNetworkInfo,     void *user_void, void *pJoinParams)  {   int ap_found = is_network_in_shadow(pstrNetworkInfo, user_void); - u32 ap_index = 0;   u8 rssi_index = 0; + struct network_info *ni;     if (last_scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW)   return;     if (ap_found == -1) { - ap_index = last_scanned_cnt; + ni = &last_scanned_shadow[last_scanned_cnt];   last_scanned_cnt++;   } else { - ap_index = ap_found; + ni = &last_scanned_shadow[ap_found];   } - rssi_index = last_scanned_shadow[ap_index].str_rssi.u8Index; - last_scanned_shadow[ap_index].str_rssi.as8RSSI[rssi_index++] = pstrNetworkInfo->rssi; + rssi_index = ni->str_rssi.u8Index; + ni->str_rssi.as8RSSI[rssi_index++] = pstrNetworkInfo->rssi;   if (rssi_index == NUM_RSSI) {   rssi_index = 0; - last_scanned_shadow[ap_index].str_rssi.u8Full = 1; + ni->str_rssi.u8Full = 1;   } - last_scanned_shadow[ap_index].str_rssi.u8Index = rssi_index; - last_scanned_shadow[ap_index].rssi = pstrNetworkInfo->rssi; - last_scanned_shadow[ap_index].cap_info = pstrNetworkInfo->cap_info; - last_scanned_shadow[ap_index].ssid_len = pstrNetworkInfo->ssid_len; - memcpy(last_scanned_shadow[ap_index].ssid, -        pstrNetworkInfo->ssid, pstrNetworkInfo->ssid_len); - memcpy(last_scanned_shadow[ap_index].bssid, -        pstrNetworkInfo->bssid, ETH_ALEN); - last_scanned_shadow[ap_index].beacon_period = pstrNetworkInfo->beacon_period; - last_scanned_shadow[ap_index].dtim_period = pstrNetworkInfo->dtim_period; - last_scanned_shadow[ap_index].ch = pstrNetworkInfo->ch; - last_scanned_shadow[ap_index].ies_len = pstrNetworkInfo->ies_len; - last_scanned_shadow[ap_index].tsf_hi = pstrNetworkInfo->tsf_hi; + ni->str_rssi.u8Index = rssi_index; + ni->rssi = pstrNetworkInfo->rssi; + ni->cap_info = pstrNetworkInfo->cap_info; + ni->ssid_len = pstrNetworkInfo->ssid_len; + memcpy(ni->ssid, pstrNetworkInfo->ssid, pstrNetworkInfo->ssid_len); + ether_addr_copy(ni->bssid, pstrNetworkInfo->bssid); + ni->beacon_period = pstrNetworkInfo->beacon_period; + ni->dtim_period = pstrNetworkInfo->dtim_period; + ni->ch = pstrNetworkInfo->ch; + ni->ies_len = pstrNetworkInfo->ies_len; + ni->tsf_hi = pstrNetworkInfo->tsf_hi;   if (ap_found != -1) - kfree(last_scanned_shadow[ap_index].ies); - last_scanned_shadow[ap_index].ies = kmalloc(pstrNetworkInfo->ies_len, -     GFP_KERNEL); - memcpy(last_scanned_shadow[ap_index].ies, -        pstrNetworkInfo->ies, pstrNetworkInfo->ies_len); - last_scanned_shadow[ap_index].time_scan = jiffies; - last_scanned_shadow[ap_index].time_scan_cached = jiffies; - last_scanned_shadow[ap_index].found = 1; + kfree(ni->ies); + ni->ies = kmemdup(pstrNetworkInfo->ies, pstrNetworkInfo->ies_len, +   GFP_KERNEL); + ni->time_scan = jiffies; + ni->time_scan_cached = jiffies; + ni->found = 1;   if (ap_found != -1) - kfree(last_scanned_shadow[ap_index].join_params); - last_scanned_shadow[ap_index].join_params = pJoinParams; + kfree(ni->join_params); + ni->join_params = pJoinParams;  }    static void CfgScanResult(enum scan_event scan_event,