From: Julia Lawall <julia.lawall@lip6.fr>
To: Haneen Mohammed <hamohammed.sa@gmail.com>
Cc: outreachy-kernel@googlegroups.com, gregkh@linuxfoundation.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [Outreachy kernel] [PATCH] staging: wlan-ng: Replace pr_debug with netdev_dbg
Date: Wed, 13 Sep 2017 07:51:49 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.20.1709130750040.2354@hadrien> (raw)
In-Reply-To: <20170913043225.GA9679@Haneen>
On Tue, 12 Sep 2017, Haneen Mohammed wrote:
> This patch replace pr_debug with netdev_dbg when appropriate net_device
> structure is found.
> Issue found using the following Coccinelle script:
>
> @r exists@
> identifier f, s, i;
> position p;
> @@
>
> f(...,struct s *i,...) {
> <+... when != i == NULL
> (
> pr_err@p(...);
> |
> pr_info@p(...);
> |
> pr_debug@p(...);
> )
> ...+>
> }
>
> @rr@
> identifier r.s, fld;
> @@
>
> struct s {
> ...
> struct net_device *fld;
> ... };
>
> @@
> identifier r.i, r.s, rr.fld;
> position r.p;
> @@
> (
> -pr_err@p
> +netdev_err
> (
> + i->fld,
> ...)
> |
> -pr_info@p
> +netdev_info
> (
> + i->fld,
> ...)
> |
> -pr_debug@p
> +netdev_dbg
> (
> + i->fld,
> ...)
> )
>
> Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
In each case, you would want to check that the value of the parameter
cannot be NULL. It's find in this case because every function starts by
accessing a field of wlandev, and the variable is never updated in the
middle of a function.
julia
> ---
> drivers/staging/wlan-ng/prism2mgmt.c | 78 ++++++++++++++++++++++--------------
> 1 file changed, 47 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c
> index c4aa9e7..7207059 100644
> --- a/drivers/staging/wlan-ng/prism2mgmt.c
> +++ b/drivers/staging/wlan-ng/prism2mgmt.c
> @@ -394,8 +394,9 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp)
> count = HFA384x_SCANRESULT_MAX;
>
> if (req->bssindex.data >= count) {
> - pr_debug("requested index (%d) out of range (%d)\n",
> - req->bssindex.data, count);
> + netdev_dbg(wlandev->netdev,
> + "requested index (%d) out of range (%d)\n",
> + req->bssindex.data, count);
> result = 2;
> req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
> goto exit;
> @@ -684,7 +685,8 @@ int prism2mgmt_start(struct wlandevice *wlandev, void *msgp)
>
> goto done;
> failed:
> - pr_debug("Failed to set a config option, result=%d\n", result);
> + netdev_dbg(wlandev->netdev,
> + "Failed to set a config option, result=%d\n", result);
> msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
>
> done:
> @@ -1120,15 +1122,17 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> /* Disable monitor mode */
> result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
> if (result) {
> - pr_debug("failed to disable monitor mode, result=%d\n",
> - result);
> + netdev_dbg(wlandev->netdev,
> + "failed to disable monitor mode, result=%d\n",
> + result);
> goto failed;
> }
> /* Disable port 0 */
> result = hfa384x_drvr_disable(hw, 0);
> if (result) {
> - pr_debug
> - ("failed to disable port 0 after sniffing, result=%d\n",
> + netdev_dbg
> + (wlandev->netdev,
> + "failed to disable port 0 after sniffing, result=%d\n",
> result);
> goto failed;
> }
> @@ -1140,8 +1144,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> HFA384x_RID_CNFWEPFLAGS,
> hw->presniff_wepflags);
> if (result) {
> - pr_debug
> - ("failed to restore wepflags=0x%04x, result=%d\n",
> + netdev_dbg
> + (wlandev->netdev,
> + "failed to restore wepflags=0x%04x, result=%d\n",
> hw->presniff_wepflags, result);
> goto failed;
> }
> @@ -1153,8 +1158,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> HFA384x_RID_CNFPORTTYPE,
> word);
> if (result) {
> - pr_debug
> - ("failed to restore porttype, result=%d\n",
> + netdev_dbg
> + (wlandev->netdev,
> + "failed to restore porttype, result=%d\n",
> result);
> goto failed;
> }
> @@ -1162,8 +1168,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> /* Enable the port */
> result = hfa384x_drvr_enable(hw, 0);
> if (result) {
> - pr_debug("failed to enable port to presniff setting, result=%d\n",
> - result);
> + netdev_dbg(wlandev->netdev,
> + "failed to enable port to presniff setting, result=%d\n",
> + result);
> goto failed;
> }
> } else {
> @@ -1182,8 +1189,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> HFA384x_RID_CNFPORTTYPE,
> &(hw->presniff_port_type));
> if (result) {
> - pr_debug
> - ("failed to read porttype, result=%d\n",
> + netdev_dbg
> + (wlandev->netdev,
> + "failed to read porttype, result=%d\n",
> result);
> goto failed;
> }
> @@ -1192,24 +1200,27 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> HFA384x_RID_CNFWEPFLAGS,
> &(hw->presniff_wepflags));
> if (result) {
> - pr_debug
> - ("failed to read wepflags, result=%d\n",
> + netdev_dbg
> + (wlandev->netdev,
> + "failed to read wepflags, result=%d\n",
> result);
> goto failed;
> }
> hfa384x_drvr_stop(hw);
> result = hfa384x_drvr_start(hw);
> if (result) {
> - pr_debug("failed to restart the card for sniffing, result=%d\n",
> - result);
> + netdev_dbg(wlandev->netdev,
> + "failed to restart the card for sniffing, result=%d\n",
> + result);
> goto failed;
> }
> } else {
> /* Disable the port */
> result = hfa384x_drvr_disable(hw, 0);
> if (result) {
> - pr_debug("failed to enable port for sniffing, result=%d\n",
> - result);
> + netdev_dbg(wlandev->netdev,
> + "failed to enable port for sniffing, result=%d\n",
> + result);
> goto failed;
> }
> }
> @@ -1225,8 +1236,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> hw->sniff_channel = word;
>
> if (result) {
> - pr_debug("failed to set channel %d, result=%d\n",
> - word, result);
> + netdev_dbg(wlandev->netdev,
> + "failed to set channel %d, result=%d\n",
> + word, result);
> goto failed;
> }
>
> @@ -1238,8 +1250,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> HFA384x_RID_CNFPORTTYPE,
> word);
> if (result) {
> - pr_debug
> - ("failed to set porttype %d, result=%d\n",
> + netdev_dbg
> + (wlandev->netdev,
> + "failed to set porttype %d, result=%d\n",
> word, result);
> goto failed;
> }
> @@ -1257,8 +1270,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> }
>
> if (result) {
> - pr_debug
> - ("failed to set wepflags=0x%04x, result=%d\n",
> + netdev_dbg
> + (wlandev->netdev,
> + "failed to set wepflags=0x%04x, result=%d\n",
> word, result);
> goto failed;
> }
> @@ -1283,16 +1297,18 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
> /* Enable the port */
> result = hfa384x_drvr_enable(hw, 0);
> if (result) {
> - pr_debug
> - ("failed to enable port for sniffing, result=%d\n",
> + netdev_dbg
> + (wlandev->netdev,
> + "failed to enable port for sniffing, result=%d\n",
> result);
> goto failed;
> }
> /* Enable monitor mode */
> result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE);
> if (result) {
> - pr_debug("failed to enable monitor mode, result=%d\n",
> - result);
> + netdev_dbg(wlandev->netdev,
> + "failed to enable monitor mode, result=%d\n",
> + result);
> goto failed;
> }
>
> --
> 2.7.4
>
> --
> 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-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170913043225.GA9679%40Haneen.
> For more options, visit https://groups.google.com/d/optout.
>
prev parent reply other threads:[~2017-09-13 5:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-13 4:32 Haneen Mohammed
2017-09-13 5:51 ` Julia Lawall [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1709130750040.2354@hadrien \
--to=julia.lawall@lip6.fr \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hamohammed.sa@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=outreachy-kernel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome