Remark #111: Statement is unreachable

There are several common cases where code will not be executed.

Example #1: from Linux-2.6-rc3 file net/key/af_key.c

    477         case IPPROTO_COMP:
    478                 return SADB_X_SATYPE_IPCOMP;
    479                 break;

Trailing break statement will never be reached.

Example #2:  from Linux-2.6-rc3 sound/core/oss/pcm_oss.c

   1647         if (ptrl == task_name) {
   1648                 goto __not_found;
   1649                 return NULL;
   1650         }

return statement after goto will never be reached

Example #3: from Linux-2.6-rc3 fs/reiserfs/journal.c

    924         while (1) {
    925                 other_jl = JOURNAL_LIST_ENTRY(entry);

    926-950    ........                

    951         }
    952         return 0;

statements after an an infinite loop are rarely executed :-)

How to resolve:

Removing unnecessary code is usually the preferred course of action.

SourceForge.net Logo