kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Question regarding strange-looking code in drivers/isdn/i4l/isdn_ppp.c
Date: Mon, 2 Feb 2015 11:35:49 -0800	[thread overview]
Message-ID: <20150202193549.GA12397@kroah.com> (raw)
In-Reply-To: <20150202192625.GA5776@esper.localdomain>

On Mon, Feb 02, 2015 at 08:26:26PM +0100, Bas Peters wrote:
> Hi,
> 
> I was checking some code in drivers/isdn/isdn_pp and came across the following:
> 
> 	case PPP_VJC_COMP:
> 		if (is->debug & 0x20)
> 			printk(KERN_DEBUG "isdn_ppp: VJC_COMP\n");
> 		{
> 			struct sk_buff *skb_old = skb;
> 			int pkt_len;
> 			skb = dev_alloc_skb(skb_old->len + 128);
> 
> 			if (!skb) {
> 				printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name);
> 				skb = skb_old;
> 				goto drop_packet;
> 			}
> 			skb_put(skb, skb_old->len + 128);
> 			skb_copy_from_linear_data(skb_old, skb->data,
> 						  skb_old->len);
> 			if (net_dev->local->ppp_slot < 0) {
> 				printk(KERN_ERR "%s: net_dev->local->ppp_slot(%d) out of range\n",
> 				       __func__, net_dev->local->ppp_slot);
> 				goto drop_packet;
> 			}
> 			pkt_len = slhc_uncompress(ippp_table[net_dev->local->ppp_slot]->slcomp,
> 						  skb->data, skb_old->len);
> 			kfree_skb(skb_old);
> 			if (pkt_len < 0)
> 				goto drop_packet;
> 
> 			skb_trim(skb, pkt_len);
> 			skb->protocol = htons(ETH_P_IP);
> 		}
> 		break;
> 
> Could you explain to me why there are braces AFTER the printk
> invocation? Was it perhaps intended that the printk was included in
> the braces?

Nope, the printk is for a debugging flag.

The braces afterward is for the new variable scope, it's odd looking
yes, but correct code and formatting.

Hope this helps,

greg k-h

  parent reply	other threads:[~2015-02-02 19:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-02 19:26 Question regarding strange-looking code in drivers/isdn/i4l/isdn_ppp.c Bas Peters
2015-02-02 19:34 ` Jeff Haran
2015-02-02 19:36   ` Bas Peters
2015-02-02 19:35 ` Greg KH [this message]
2015-02-02 20:14   ` Henry Hallam
2015-02-02 20:20 ` anish singh

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=20150202193549.GA12397@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /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;
as well as URLs for NNTP newsgroup(s).