public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Phani Kandula <phani.lkml@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: doubt about "switch" - default case in af_inet.c
Date: Thu, 9 Dec 2004 19:27:49 +0530	[thread overview]
Message-ID: <7d34f21904120905573ddb6d25@mail.gmail.com> (raw)

Hi all,

I'm a newbie to the Linux. I'm using 2.6.8 kernel. 
In /usr/src/linux/net/ipv4/af_inet.c I came across this...
 <code>
     switch (sock->state) {
     default:
     //do something..
         goto out;
     case SS_CONNECTED:
     //do something..
         goto out;
     case SS_CONNECTING:
     //do something..
         break;
     case SS_UNCONNECTED:
     //do something..
         break;
     }
 </code>

Is there any advantage in having 'default' as the first case? 
My understanding is that it will be useful only when 'default' is the
most likely case (in general).

Even then, my doubt: How will compiler (say gcc) implement 'default'
as the first value? Program is supposed to see all the cases and then
decide 'default'. Is this correct?

So, is this the best way to do it? please clarify..

Thanks,
Phani

             reply	other threads:[~2004-12-09 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-09 13:57 Phani Kandula [this message]
2004-12-09 14:09 ` doubt about "switch" - default case in af_inet.c linux-os
2004-12-16 18:43 ` Bill Davidsen

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=7d34f21904120905573ddb6d25@mail.gmail.com \
    --to=phani.lkml@gmail.com \
    --cc=linux-kernel@vger.kernel.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