All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: mahendra singh meena <mahendra.devel@gmail.com>
Cc: marcel@holtmann.org, padovan@profusion.mobi,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: bfusb: Fixed some coding style issues
Date: Sun, 15 Jan 2012 12:33:06 -0800	[thread overview]
Message-ID: <1326659586.6164.18.camel@joe2Laptop> (raw)
In-Reply-To: <4F132D37.7030405@gmail.com>

On Mon, 2012-01-16 at 01:17 +0530, mahendra singh meena wrote:
> Fixed some coding style issues shown by scripts/checkpatch.pl
[]
> diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
[]
> @@ -127,11 +127,13 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
>  {
>  	struct bfusb_data_scb *scb = (void *) skb->cb;
>  	struct urb *urb = bfusb_get_completed(data);
> +	struct urb *urb_chk = urb;
>  	int err, pipe;
> 
>  	BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len);
> +	urb = usb_alloc_urb(0, GFP_ATOMIC);
> 
> -	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
> +	if (!urb_chk && !urb)

Broken patch.

You are now always calling usb_alloc_urb and
overwriting the original urb that is returned
from bfusb_get_completed().

Not everything that checkpatch flags needs to be
modified.

The original is better than even a correct
proposed patch because it's more readable and it
uses fewer variables.

If you _really_ want to avoid checkpatch warnings,
then don't use the additional automatic.

	if (!urb) {
		urb = usb_alloc_urb(0, GFP_ATOMIC);
		if (!urb)
			return -ENOMEM;
	}

> @@ -145,7 +147,7 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
> 
>  	err = usb_submit_urb(urb, GFP_ATOMIC);
>  	if (err) {
> -		BT_ERR("%s bulk tx submit failed urb %p err %d",
> +		BT_ERR("%s bulk tx submit failed urb %p err %d",

? What does checkpatch complain about this?

>  					data->hdev->name, urb, err);
>  		skb_unlink(skb, &data->pending_q);
>  		usb_free_urb(urb);
> @@ -214,11 +216,13 @@ static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
>  {
>  	struct bfusb_data_scb *scb;
>  	struct sk_buff *skb;
> +	struct urb *urb_chk = urb;
>  	int err, pipe, size = HCI_MAX_FRAME_SIZE + 32;
> 
>  	BT_DBG("bfusb %p urb %p", data, urb);
> +	urb = usb_alloc_urb(0, GFP_ATOMIC);
> 
> -	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
> +	if (!urb && !urb_chk)
>  		return -ENOMEM;

Same broken change.

> @@ -283,30 +288,37 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
>  		switch (pkt_type) {
>  		case HCI_EVENT_PKT:
>  			if (len >= HCI_EVENT_HDR_SIZE) {
> -				struct hci_event_hdr *hdr = (struct hci_event_hdr *) buf;
> +				struct hci_event_hdr *hdr;
> +				hdr = (struct hci_event_hdr *) buf;

It'd probably be better to change the type of "buf" to void *
and avoid all the casts.

> @@ -514,12 +528,14 @@ static int bfusb_send_frame(struct sk_buff *skb)
>  	while (count) {
>  		size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE);
> 
> -		buf[0] = 0xc1 | ((sent == 0) ? 0x04 : 0) | ((count == size) ? 0x08 : 0);
> +		buf[0] = 0xc1 | ((sent == 0) ? 0x04 : 0) |
> +						((count == size) ? 0x08 : 0);

When wrapping just for 80 columns, please try to use
alignments that are a bit more readable and perhaps
remove unnecessary parentheses like:

		buf[0] = 0xc1 |
			 (sent == 0 ? 0x04 : 0) |
			 (count == size ? 0x08 : 0);

      reply	other threads:[~2012-01-15 20:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-15 19:47 [PATCH] Bluetooth: bfusb: Fixed some coding style issues mahendra singh meena
2012-01-15 20:33 ` Joe Perches [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=1326659586.6164.18.camel@joe2Laptop \
    --to=joe@perches.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mahendra.devel@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=padovan@profusion.mobi \
    /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 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.