[PATCH 1/2] staging: ks7010: Unnecessary parentheses are removed.

18 views
Skip to first unread message

Arushi Singhal

unread,
Feb 19, 2017, 1:26:14 PM2/19/17
to gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
Unnecessary parentheses should be avoided as reported by checkpatch.pl.
Remove unnecessary parentheses, as reported by checkpatch as are nicer
to read.For example:-
It's often nicer to read if &(foo[0]) is converted to foo like:
memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);

Signed-off-by: Arushi Singhal <arushising...@gmail.com>
---
drivers/staging/ks7010/ks_hostif.c | 24 ++++++++++++------------
drivers/staging/ks7010/ks_wlan_net.c | 20 ++++++++++----------
2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 3b2e28749b63..bbc39cbabdc1 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -212,7 +212,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
memset(ap, 0, sizeof(struct local_ap_t));

/* bssid */
- memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
+ memcpy(&ap->bssid[0], &ap_info->bssid[0], ETH_ALEN);
/* rssi */
ap->rssi = ap_info->rssi;
/* sq */
@@ -224,7 +224,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
/* channel */
ap->channel = ap_info->ch_info;

- bp = &(ap_info->body[0]);
+ bp = &ap_info->body[0];
bsize = ap_info->body_size;
offset = 0;

@@ -239,19 +239,19 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
*(bp + 1));
ap->ssid.size = SSID_MAX_SIZE;
}
- memcpy(&(ap->ssid.body[0]), bp + 2, ap->ssid.size);
+ memcpy(&ap->ssid.body[0], bp + 2, ap->ssid.size);
break;
case 1: /* rate */
case 50: /* ext rate */
if ((*(bp + 1) + ap->rate_set.size) <=
RATE_SET_MAX_SIZE) {
- memcpy(&(ap->rate_set.body[ap->rate_set.size]),
+ memcpy(&ap->rate_set.body[ap->rate_set.size],
bp + 2, *(bp + 1));
ap->rate_set.size += *(bp + 1);
} else {
DPRINTK(1, "size over :: rate size=%d\n",
(*(bp + 1) + ap->rate_set.size));
- memcpy(&(ap->rate_set.body[ap->rate_set.size]),
+ memcpy(&ap->rate_set.body[ap->rate_set.size],
bp + 2,
RATE_SET_MAX_SIZE - ap->rate_set.size);
ap->rate_set.size +=
@@ -269,7 +269,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
*(bp + 1));
ap->rsn_ie.size = RSN_IE_BODY_MAX;
}
- memcpy(&(ap->rsn_ie.body[0]), bp + 2, ap->rsn_ie.size);
+ memcpy(&ap->rsn_ie.body[0], bp + 2, ap->rsn_ie.size);
break;
case 221: /* WPA */
if (!memcmp(bp + 2, "\x00\x50\xf2\x01", 4)) { /* WPA OUI check */
@@ -282,7 +282,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
*(bp + 1));
ap->wpa_ie.size = RSN_IE_BODY_MAX;
}
- memcpy(&(ap->wpa_ie.body[0]), bp + 2,
+ memcpy(&ap->wpa_ie.body[0], bp + 2,
ap->wpa_ie.size);
}
break;
@@ -832,8 +832,8 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
if (priv->scan_ind_count != 0) {
for (i = 0; i < priv->aplist.size; i++) { /* bssid check */
if (!memcmp
- (&(ap_info->bssid[0]),
- &(priv->aplist.ap[i].bssid[0]), ETH_ALEN)) {
+ (&ap_info->bssid[0],
+ &priv->aplist.ap[i].bssid[0], ETH_ALEN)) {
if (ap_info->frame_type ==
FRAME_TYPE_PROBE_RESP)
get_ap_information(priv, ap_info,
@@ -2652,7 +2652,7 @@ int hostif_init(struct ks_wlan_private *priv)

priv->aplist.size = 0;
for (i = 0; i < LOCAL_APLIST_MAX; i++)
- memset(&(priv->aplist.ap[i]), 0, sizeof(struct local_ap_t));
+ memset(&priv->aplist.ap[i], 0, sizeof(struct local_ap_t));
priv->infra_status = 0;
priv->current_rate = 4;
priv->connect_status = DISCONNECT_STATUS;
@@ -2675,12 +2675,12 @@ int hostif_init(struct ks_wlan_private *priv)
INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task);

/* WPA */
- memset(&(priv->wpa), 0, sizeof(priv->wpa));
+ memset(&priv->wpa, 0, sizeof(priv->wpa));
priv->wpa.rsn_enabled = 0;
priv->wpa.mic_failure.failure = 0;
priv->wpa.mic_failure.last_failure_time = 0;
priv->wpa.mic_failure.stop = 0;
- memset(&(priv->pmklist), 0, sizeof(priv->pmklist));
+ memset(&priv->pmklist, 0, sizeof(priv->pmklist));
INIT_LIST_HEAD(&priv->pmklist.head);
for (i = 0; i < PMK_LIST_MAX; i++)
INIT_LIST_HEAD(&priv->pmklist.pmk[i].list);
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 8c55428b71c7..2233c9fa982a 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -423,7 +423,7 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info,

/* for SLEEP MODE */
if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS)
- memcpy(awrq->sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN);
+ memcpy(awrq->sa_data, &priv->current_ap.bssid[0], ETH_ALEN);
else
eth_zero_addr(awrq->sa_data);

@@ -1364,7 +1364,7 @@ static int ks_wlan_get_aplist(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
for (i = 0; i < priv->aplist.size; i++) {
- memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]),
+ memcpy(address[i].sa_data, &priv->aplist.ap[i].bssid[0],
ETH_ALEN);
address[i].sa_family = ARPHRD_ETHER;
qual[i].level = 256 - priv->aplist.ap[i].rssi;
@@ -1454,7 +1454,7 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
iwe.u.data.flags = 1;
current_ev =
iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- &(ap->ssid.body[0]));
+ &ap->ssid.body[0]);

/* Add mode */
iwe.cmd = SIOCGIWMODE;
@@ -1496,7 +1496,7 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
iwe.u.data.length = 0;
current_ev =
iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- &(ap->ssid.body[0]));
+ &ap->ssid.body[0]);

/* Rate : stuffing multiple values in a single event require a bit
* more of magic - Jean II */
@@ -1612,7 +1612,7 @@ static int ks_wlan_get_scan(struct net_device *dev,
current_ev = ks_wlan_translate_scan(dev, current_ev,
// extra + IW_SCAN_MAX_DATA,
extra + dwrq->length,
- &(priv->current_ap));
+ &priv->current_ap);
}
#endif
/* Read and parse all entries */
@@ -1625,7 +1625,7 @@ static int ks_wlan_get_scan(struct net_device *dev,
current_ev = ks_wlan_translate_scan(dev, info, current_ev,
// extra + IW_SCAN_MAX_DATA,
extra + dwrq->length,
- &(priv->aplist.ap[i]));
+ &priv->aplist.ap[i]);
}
/* Length of data */
dwrq->length = (current_ev - extra);
@@ -2080,7 +2080,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
}
break;
case IW_PMKSA_FLUSH:
- memset(&(priv->pmklist), 0, sizeof(priv->pmklist));
+ memset(&priv->pmklist, 0, sizeof(priv->pmklist));
INIT_LIST_HEAD(&priv->pmklist.head);
for (i = 0; i < PMK_LIST_MAX; i++)
INIT_LIST_HEAD(&priv->pmklist.pmk[i].list);
@@ -2178,7 +2178,7 @@ static int ks_wlan_get_firmware_version(struct net_device *dev,
{
struct ks_wlan_private *priv =
(struct ks_wlan_private *)netdev_priv(dev);
- strcpy(extra, &(priv->firmware_version[0]));
+ strcpy(extra, &priv->firmware_version[0]);
dwrq->length = priv->version_size + 1;
return 0;
}
@@ -2433,7 +2433,7 @@ static int ks_wlan_data_read(struct net_device *dev,
read_length = priv->dev_size[priv->dev_count];

/* Copy data */
- memcpy(extra, &(priv->dev_data[priv->dev_count][0]), read_length);
+ memcpy(extra, &priv->dev_data[priv->dev_count][0], read_length);

spin_unlock(&priv->dev_read_lock); /* release spin lock */

@@ -3254,7 +3254,7 @@ static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,

switch (cmd) {
case SIOCIWFIRSTPRIV + 20: /* KS_WLAN_SET_STOP_REQ */
- rc = ks_wlan_set_stop_request(dev, NULL, &(wrq->u.mode), NULL);
+ rc = ks_wlan_set_stop_request(dev, NULL, &wrq->u.mode, NULL);
break;
// All other calls are currently unsupported
default:
--
2.11.0

Joe Perches

unread,
Feb 19, 2017, 1:53:17 PM2/19/17
to Arushi Singhal, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
On Sun, 2017-02-19 at 23:56 +0530, Arushi Singhal wrote:
> Unnecessary parentheses should be avoided as reported by checkpatch.pl.
> Remove unnecessary parentheses, as reported by checkpatch as are nicer
> to read.For example:-
> It's often nicer to read if &(foo[0]) is converted to foo like:
> memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
> memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
[]
> diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
[]
> @@ -212,7 +212,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
> memset(ap, 0, sizeof(struct local_ap_t));
>
> /* bssid */
> - memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
> + memcpy(&ap->bssid[0], &ap_info->bssid[0], ETH_ALEN);

This code doesn't match the suggested style of
your commit message.

Julia Lawall

unread,
Feb 19, 2017, 1:55:28 PM2/19/17
to Arushi Singhal, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com


On Sun, 19 Feb 2017, Arushi Singhal wrote:

> Unnecessary parentheses should be avoided as reported by checkpatch.pl.
> Remove unnecessary parentheses, as reported by checkpatch as are nicer
> to read.For example:-
> It's often nicer to read if &(foo[0]) is converted to foo like:
> memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
> memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);

You didn't actually remove the & and [0].

julia
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kern...@googlegroups.com.
> To post to this group, send email to outreach...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170219182607.GA17005%40arushi-HP-Pavilion-Notebook.
> For more options, visit https://groups.google.com/d/optout.
>

Julia Lawall

unread,
Feb 19, 2017, 1:58:08 PM2/19/17
to Joe Perches, Arushi Singhal, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
Is what is suggested in the commit message correct? That is, is the 0th
element of an array always at the same address as a pointer to the array
itself? Probably just paramoid...

julia

>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kern...@googlegroups.com.
> To post to this group, send email to outreach...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1487529117.2198.36.camel%40perches.com.

Joe Perches

unread,
Feb 19, 2017, 2:18:39 PM2/19/17
to Julia Lawall, Arushi Singhal, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
On Sun, 2017-02-19 at 19:58 +0100, Julia Lawall wrote:
> On Sun, 19 Feb 2017, Joe Perches wrote:
> > On Sun, 2017-02-19 at 23:56 +0530, Arushi Singhal wrote:
> > > Unnecessary parentheses should be avoided as reported by checkpatch.pl.
> > > Remove unnecessary parentheses, as reported by checkpatch as are nicer
> > > to read.For example:-
> > > It's often nicer to read if &(foo[0]) is converted to foo like:
> > > memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
> > > memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
> > []
> > > diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
> > []
> > > @@ -212,7 +212,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
> > > memset(ap, 0, sizeof(struct local_ap_t));
> > >
> > > /* bssid */
> > > - memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
> > > + memcpy(&ap->bssid[0], &ap_info->bssid[0], ETH_ALEN);
> >
> > This code doesn't match the suggested style of
> > your commit message.
>
> Is what is suggested in the commit message correct? That is, is the 0th
> element of an array always at the same address as a pointer to the array
> itself?

I think your wording is a little fuzzy.

Assuming you mean not a pointer to the array,
but the array itself, yes.

Julia Lawall

unread,
Feb 19, 2017, 2:20:05 PM2/19/17
to Joe Perches, Arushi Singhal, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
Yes, I mean the array itself,sorry. Thanks.

Arushi, it would be good it you could make the change you proposed to
make. The calls would look much more normal that way.

thanks,
julia

>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kern...@googlegroups.com.
> To post to this group, send email to outreach...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1487531915.2198.38.camel%40perches.com.

Arushi Singhal

unread,
Feb 19, 2017, 2:56:05 PM2/19/17
to outreachy-kernel, j...@perches.com, arushising...@gmail.com, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org

Hi
Actually sorry this is because of some mistake in rebasing.
I will correct it send the correct version.

Arushi Singhal

unread,
Feb 20, 2017, 1:53:15 AM2/20/17
to gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
Unnecessary parentheses should be avoided as reported by checkpatch.pl.
Remove unnecessary parentheses, as reported by checkpatch as are nicer
to read.For example:-
It's often nicer to read if &(foo[0]) is converted to foo like:
memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);

Signed-off-by: Arushi Singhal <arushising...@gmail.com>
---
drivers/staging/ks7010/ks_hostif.c | 20 ++++++++++----------
drivers/staging/ks7010/ks_wlan_net.c | 20 ++++++++++----------
2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index ba283ab741a7..2d5ec57c5cfd 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -239,19 +239,19 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
*(bp + 1));
ap->ssid.size = SSID_MAX_SIZE;
}
- memcpy(&(ap->ssid.body[0]), bp + 2, ap->ssid.size);
+ memcpy(ap->ssid.body, bp + 2, ap->ssid.size);
break;
case 1: /* rate */
case 50: /* ext rate */
if ((*(bp + 1) + ap->rate_set.size) <=
RATE_SET_MAX_SIZE) {
- memcpy(&(ap->rate_set.body[ap->rate_set.size]),
+ memcpy(&ap->rate_set.body[ap->rate_set.size],
bp + 2, *(bp + 1));
ap->rate_set.size += *(bp + 1);
} else {
DPRINTK(1, "size over :: rate size=%d\n",
(*(bp + 1) + ap->rate_set.size));
- memcpy(&(ap->rate_set.body[ap->rate_set.size]),
+ memcpy(&ap->rate_set.body[ap->rate_set.size],
bp + 2,
RATE_SET_MAX_SIZE - ap->rate_set.size);
ap->rate_set.size +=
@@ -269,7 +269,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
*(bp + 1));
ap->rsn_ie.size = RSN_IE_BODY_MAX;
}
- memcpy(&(ap->rsn_ie.body[0]), bp + 2, ap->rsn_ie.size);
+ memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size);
break;
case 221: /* WPA */
if (!memcmp(bp + 2, "\x00\x50\xf2\x01", 4)) { /* WPA OUI check */
@@ -282,7 +282,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
*(bp + 1));
ap->wpa_ie.size = RSN_IE_BODY_MAX;
}
- memcpy(&(ap->wpa_ie.body[0]), bp + 2,
+ memcpy(ap->wpa_ie.body, bp + 2,
ap->wpa_ie.size);
}
break;
@@ -832,8 +832,8 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
if (priv->scan_ind_count != 0) {
for (i = 0; i < priv->aplist.size; i++) { /* bssid check */
if (!memcmp
- (&(ap_info->bssid[0]),
- &(priv->aplist.ap[i].bssid[0]), ETH_ALEN)) {
+ (ap_info->bssid,
index 8c55428b71c7..9f4bd7c3ea12 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -423,7 +423,7 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info,

/* for SLEEP MODE */
if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS)
- memcpy(awrq->sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN);
+ memcpy(awrq->sa_data, priv->current_ap.bssid, ETH_ALEN);
else
eth_zero_addr(awrq->sa_data);

@@ -1364,7 +1364,7 @@ static int ks_wlan_get_aplist(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
for (i = 0; i < priv->aplist.size; i++) {
- memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]),
+ memcpy(address[i].sa_data, &priv->aplist.ap[i].bssid[0],
ETH_ALEN);
address[i].sa_family = ARPHRD_ETHER;
qual[i].level = 256 - priv->aplist.ap[i].rssi;
@@ -1454,7 +1454,7 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
iwe.u.data.flags = 1;
current_ev =
iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- &(ap->ssid.body[0]));
+ ap->ssid.body);

/* Add mode */
iwe.cmd = SIOCGIWMODE;
@@ -1496,7 +1496,7 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
iwe.u.data.length = 0;
current_ev =
iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- &(ap->ssid.body[0]));
+ ap->ssid.body);
+ strcpy(extra, priv->firmware_version);

Julia Lawall

unread,
Feb 20, 2017, 2:02:22 AM2/20/17
to Arushi Singhal, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com


On Mon, 20 Feb 2017, Arushi Singhal wrote:

> Unnecessary parentheses should be avoided as reported by checkpatch.pl.
> Remove unnecessary parentheses, as reported by checkpatch as are nicer
> to read.For example:-
> It's often nicer to read if &(foo[0]) is converted to foo like:
> memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
> memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);

The commit message is not well presented. One has the impression that all
of the changes are related to 0 array elements. It would be better to
split the patch into two: one for removing parentheses, and one for making
the &x[0] -> x change. They don't really have anything to do with each
other.

julia
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kern...@googlegroups.com.
> To post to this group, send email to outreach...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170220065310.GA21888%40arushi-HP-Pavilion-Notebook.

Arushi Singhal

unread,
Feb 20, 2017, 2:49:05 AM2/20/17
to outreachy-kernel, arushising...@gmail.com, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org


On Monday, February 20, 2017 at 12:32:22 PM UTC+5:30, Julia Lawall wrote:


On Mon, 20 Feb 2017, Arushi Singhal wrote:

> Unnecessary parentheses should be avoided as reported by checkpatch.pl.
> Remove unnecessary parentheses, as reported by checkpatch as are nicer
> to read.For example:-
> It's often nicer to read if &(foo[0]) is converted to foo like:
>      memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
>      memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);

The commit message is not well presented.  One has the impression that all
of the changes are related to 0 array elements.  It would be better to
split the patch into two: one for removing parentheses, and one for making
the &x[0] -> x change.  They don't really have anything to do with each
other.

julia


Hi
So should I change the commit message to more appropriate one so that it
better explain the changes?

Julia Lawall

unread,
Feb 20, 2017, 3:48:40 AM2/20/17
to Arushi Singhal, outreachy-kernel, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org
Yes please. Remember to put v2 in the subject line and to explain the
change you made under the ---

julia
> To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/f41dab07-08d8-4545-93fb-
> 88c9845767bb%40googlegroups.com.

Arushi Singhal

unread,
Feb 26, 2017, 12:27:47 PM2/26/17
to gre...@linuxfoundation.org, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
Unnecessary parentheses are removed as reported by checkpatch.pl
to make coder nicer and to improve readability.
Also coding style is improved.For example:-
It's often nicer to read if &(foo[0]) is converted to foo like:
memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);

Signed-off-by: Arushi Singhal <arushising...@gmail.com>
---
Changes in v4:
- Commit message made more accurate and as per the changes.

drivers/staging/ks7010/ks_hostif.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index b643a37fb943..1fbd495e5e63 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -113,7 +113,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
int rc = 0;

DPRINTK(3, "\n");
- ap = &priv->current_ap;
+ ap = &(priv->current_ap);

if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) {
memset(ap, 0, sizeof(struct local_ap_t));
@@ -121,19 +121,19 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
}

/* bssid */
- memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
+ memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
/* essid */
- memcpy(ap->ssid.body, priv->reg.ssid.body,
+ memcpy(&(ap->ssid.body[0]), &(priv->reg.ssid.body[0]),
priv->reg.ssid.size);
ap->ssid.size = priv->reg.ssid.size;
/* rate_set */
- memcpy(ap->rate_set.body, ap_info->rate_set.body,
+ memcpy(&(ap->rate_set.body[0]), &(ap_info->rate_set.body[0]),
ap_info->rate_set.size);
ap->rate_set.size = ap_info->rate_set.size;
if (ap_info->ext_rate_set.size) {
/* rate_set */
- memcpy(&ap->rate_set.body[ap->rate_set.size],
- ap_info->ext_rate_set.body,
+ memcpy(&(ap->rate_set.body[ap->rate_set.size]),
+ &(ap_info->ext_rate_set.body[0]),
ap_info->ext_rate_set.size);
ap->rate_set.size += ap_info->ext_rate_set.size;
}
@@ -153,11 +153,11 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
ap->rsn_ie.id = 0x30;
if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
ap->rsn_ie.size = ap_info->rsn.size;
- memcpy(ap->rsn_ie.body, ap_info->rsn.body,
+ memcpy(&(ap->rsn_ie.body[0]), &(ap_info->rsn.body[0]),
ap_info->rsn.size);
} else {
ap->rsn_ie.size = RSN_IE_BODY_MAX;
- memcpy(ap->rsn_ie.body, ap_info->rsn.body,
+ memcpy(&(ap->rsn_ie.body[0]), &(ap_info->rsn.body[0]),
RSN_IE_BODY_MAX);
}
} else if ((ap_info->rsn_mode & RSN_MODE_WPA)
@@ -165,11 +165,11 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
ap->wpa_ie.id = 0xdd;
if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
ap->wpa_ie.size = ap_info->rsn.size;
- memcpy(ap->wpa_ie.body, ap_info->rsn.body,
+ memcpy(&(ap->wpa_ie.body[0]), &(ap_info->rsn.body[0]),
ap_info->rsn.size);
} else {
ap->wpa_ie.size = RSN_IE_BODY_MAX;
- memcpy(ap->wpa_ie.body, ap_info->rsn.body,
+ memcpy(&(ap->wpa_ie.body[0]), &(ap_info->rsn.body[0]),
RSN_IE_BODY_MAX);
}
} else {
@@ -212,7 +212,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
memset(ap, 0, sizeof(struct local_ap_t));

/* bssid */
- memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
+ memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
/* rssi */
ap->rssi = ap_info->rssi;
/* sq */
@@ -224,7 +224,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
/* channel */
ap->channel = ap_info->ch_info;

- bp = ap_info->body;
+ bp = &(ap_info->body[0]);
bsize = ap_info->body_size;
offset = 0;

--
2.11.0

Arushi Singhal

unread,
Feb 26, 2017, 12:32:53 PM2/26/17
to gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
Unnecessary parentheses are removed as reported by checkpatch.pl
to make coder nicer and to improve readability.
Also coding style is improved.For example:-
It's often nicer to read if &(foo[0]) is converted to foo like:
memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);

Signed-off-by: Arushi Singhal <arushising...@gmail.com>
---
Changes in v4:
- Commit message made more accurate and as per the changes.
- previously versions were not marked.

drivers/staging/ks7010/ks_hostif.c | 44 ++++++++++++++++++------------------
drivers/staging/ks7010/ks_wlan_net.c | 20 ++++++++--------
2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 6e36aa2aea99..1fbd495e5e63 100644
@@ -239,19 +239,19 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
*(bp + 1));
ap->ssid.size = SSID_MAX_SIZE;
}
- memcpy(ap->ssid.body, bp + 2, ap->ssid.size);
+ memcpy(&(ap->ssid.body[0]), bp + 2, ap->ssid.size);
break;
case 1: /* rate */
case 50: /* ext rate */
if ((*(bp + 1) + ap->rate_set.size) <=
RATE_SET_MAX_SIZE) {
- memcpy(&ap->rate_set.body[ap->rate_set.size],
+ memcpy(&(ap->rate_set.body[ap->rate_set.size]),
bp + 2, *(bp + 1));
ap->rate_set.size += *(bp + 1);
} else {
DPRINTK(1, "size over :: rate size=%d\n",
(*(bp + 1) + ap->rate_set.size));
- memcpy(&ap->rate_set.body[ap->rate_set.size],
+ memcpy(&(ap->rate_set.body[ap->rate_set.size]),
bp + 2,
RATE_SET_MAX_SIZE - ap->rate_set.size);
ap->rate_set.size +=
@@ -269,7 +269,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
*(bp + 1));
ap->rsn_ie.size = RSN_IE_BODY_MAX;
}
- memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size);
+ memcpy(&(ap->rsn_ie.body[0]), bp + 2, ap->rsn_ie.size);
break;
case 221: /* WPA */
if (!memcmp(bp + 2, "\x00\x50\xf2\x01", 4)) { /* WPA OUI check */
@@ -282,7 +282,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
*(bp + 1));
ap->wpa_ie.size = RSN_IE_BODY_MAX;
}
- memcpy(ap->wpa_ie.body, bp + 2,
+ memcpy(&(ap->wpa_ie.body[0]), bp + 2,
ap->wpa_ie.size);
}
break;
@@ -832,8 +832,8 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
if (priv->scan_ind_count != 0) {
for (i = 0; i < priv->aplist.size; i++) { /* bssid check */
if (!memcmp
- (ap_info->bssid,
- &priv->aplist.ap[i].bssid[0], ETH_ALEN)) {
+ (&(ap_info->bssid[0]),
+ &(priv->aplist.ap[i].bssid[0]), ETH_ALEN)) {
if (ap_info->frame_type ==
FRAME_TYPE_PROBE_RESP)
get_ap_information(priv, ap_info,
@@ -2652,7 +2652,7 @@ int hostif_init(struct ks_wlan_private *priv)

priv->aplist.size = 0;
for (i = 0; i < LOCAL_APLIST_MAX; i++)
- memset(&priv->aplist.ap[i], 0, sizeof(struct local_ap_t));
+ memset(&(priv->aplist.ap[i]), 0, sizeof(struct local_ap_t));
priv->infra_status = 0;
priv->current_rate = 4;
priv->connect_status = DISCONNECT_STATUS;
@@ -2675,12 +2675,12 @@ int hostif_init(struct ks_wlan_private *priv)
INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task);

/* WPA */
- memset(&priv->wpa, 0, sizeof(priv->wpa));
+ memset(&(priv->wpa), 0, sizeof(priv->wpa));
priv->wpa.rsn_enabled = 0;
priv->wpa.mic_failure.failure = 0;
priv->wpa.mic_failure.last_failure_time = 0;
priv->wpa.mic_failure.stop = 0;
- memset(&priv->pmklist, 0, sizeof(priv->pmklist));
+ memset(&(priv->pmklist), 0, sizeof(priv->pmklist));
INIT_LIST_HEAD(&priv->pmklist.head);
for (i = 0; i < PMK_LIST_MAX; i++)
INIT_LIST_HEAD(&priv->pmklist.pmk[i].list);
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 9f4bd7c3ea12..8c55428b71c7 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -423,7 +423,7 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info,

/* for SLEEP MODE */
if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS)
- memcpy(awrq->sa_data, priv->current_ap.bssid, ETH_ALEN);
+ memcpy(awrq->sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN);
else
eth_zero_addr(awrq->sa_data);

@@ -1364,7 +1364,7 @@ static int ks_wlan_get_aplist(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
for (i = 0; i < priv->aplist.size; i++) {
- memcpy(address[i].sa_data, &priv->aplist.ap[i].bssid[0],
+ memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]),
ETH_ALEN);
address[i].sa_family = ARPHRD_ETHER;
qual[i].level = 256 - priv->aplist.ap[i].rssi;
@@ -1454,7 +1454,7 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
iwe.u.data.flags = 1;
current_ev =
iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- ap->ssid.body);
+ &(ap->ssid.body[0]));

/* Add mode */
iwe.cmd = SIOCGIWMODE;
@@ -1496,7 +1496,7 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
iwe.u.data.length = 0;
current_ev =
iwe_stream_add_point(info, current_ev, end_buf, &iwe,
- ap->ssid.body);
+ &(ap->ssid.body[0]));

/* Rate : stuffing multiple values in a single event require a bit
* more of magic - Jean II */
@@ -1612,7 +1612,7 @@ static int ks_wlan_get_scan(struct net_device *dev,
current_ev = ks_wlan_translate_scan(dev, current_ev,
// extra + IW_SCAN_MAX_DATA,
extra + dwrq->length,
- &priv->current_ap);
+ &(priv->current_ap));
}
#endif
/* Read and parse all entries */
@@ -1625,7 +1625,7 @@ static int ks_wlan_get_scan(struct net_device *dev,
current_ev = ks_wlan_translate_scan(dev, info, current_ev,
// extra + IW_SCAN_MAX_DATA,
extra + dwrq->length,
- &priv->aplist.ap[i]);
+ &(priv->aplist.ap[i]));
}
/* Length of data */
dwrq->length = (current_ev - extra);
@@ -2080,7 +2080,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev,
}
break;
case IW_PMKSA_FLUSH:
- memset(&priv->pmklist, 0, sizeof(priv->pmklist));
+ memset(&(priv->pmklist), 0, sizeof(priv->pmklist));
INIT_LIST_HEAD(&priv->pmklist.head);
for (i = 0; i < PMK_LIST_MAX; i++)
INIT_LIST_HEAD(&priv->pmklist.pmk[i].list);
@@ -2178,7 +2178,7 @@ static int ks_wlan_get_firmware_version(struct net_device *dev,
{
struct ks_wlan_private *priv =
(struct ks_wlan_private *)netdev_priv(dev);
- strcpy(extra, priv->firmware_version);
+ strcpy(extra, &(priv->firmware_version[0]));
dwrq->length = priv->version_size + 1;
return 0;
}
@@ -2433,7 +2433,7 @@ static int ks_wlan_data_read(struct net_device *dev,
read_length = priv->dev_size[priv->dev_count];

/* Copy data */
- memcpy(extra, &priv->dev_data[priv->dev_count][0], read_length);
+ memcpy(extra, &(priv->dev_data[priv->dev_count][0]), read_length);

spin_unlock(&priv->dev_read_lock); /* release spin lock */

@@ -3254,7 +3254,7 @@ static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,

switch (cmd) {
case SIOCIWFIRSTPRIV + 20: /* KS_WLAN_SET_STOP_REQ */
- rc = ks_wlan_set_stop_request(dev, NULL, &wrq->u.mode, NULL);
+ rc = ks_wlan_set_stop_request(dev, NULL, &(wrq->u.mode), NULL);

Julia Lawall

unread,
Feb 26, 2017, 12:33:46 PM2/26/17
to Arushi Singhal, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
On Sun, 26 Feb 2017, Arushi Singhal wrote:

> Unnecessary parentheses are removed as reported by checkpatch.pl
> to make coder nicer and to improve readability.
> Also coding style is improved.For example:-
> It's often nicer to read if &(foo[0]) is converted to foo like:
> memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
> memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);

Something is wrong in this patch. It looks like it is introducing the
code that you wanted to remove.

In the commit message, there should be a space after the period. It is
not clear what "For example:-" means. If it is part of the same sentence
as the next line, then tIts in the next line should not be capitalized.

Did Greg not accept the previous version of this patch?

julia
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kern...@googlegroups.com.
> To post to this group, send email to outreach...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170226172741.GA20524%40arushi-HP-Pavilion-Notebook.

Julia Lawall

unread,
Feb 26, 2017, 12:34:19 PM2/26/17
to Arushi Singhal, gre...@linuxfoundation.org, de...@driverdev.osuosl.org, linux-...@vger.kernel.org, outreach...@googlegroups.com
On Sun, 26 Feb 2017, Arushi Singhal wrote:

> Unnecessary parentheses are removed as reported by checkpatch.pl
> to make coder nicer and to improve readability.
> Also coding style is improved.For example:-
> It's often nicer to read if &(foo[0]) is converted to foo like:
> memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN);
> memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);

This also appears to be backwards.

julia
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kern...@googlegroups.com.
> To post to this group, send email to outreach...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170226173248.GA21452%40arushi-HP-Pavilion-Notebook.
Reply all
Reply to author
Forward
0 new messages