Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#200 "File does not have expected format" in the Linux kernel

Neil Horman
Elad Lahav

This looks like a new issue with recent CVS snapshots,
as well as with version 15.6. It does not happen with 15.5.
To reproduce, run 'cscope -R -k -q' in the Linux kernel
directory. Then, query for references to ip_append_data.
Note also that this error only occurs with -q, so it's
probably related to the inverted index files.


  • Elad Lahav
    Elad Lahav

    Logged In: YES
    Originator: YES

    I have traced back the problem to revision 1.26 of display.c.
    The command says that the code for counting references is a duplicate of countrefs(), and thus countrefs() can be called instead. This, however, does not seem to be the case, as the bug disappears if I revert to the old display.c code.
    An easy way to reconstruct the bug is to run 'cscope -k -q -L0 ip_append_data' on the file include/net/ip.h from the Linux kernel.

  • Logged In: YES
    Originator: NO

    I don't think you really found the culprit. The problem is in the database file, not in display()'s way of reading it. To be precise, the problem is that the "function" field of the record read from FILE *refsfound is empty, which it may never be.

  • Elad Lahav
    Elad Lahav

    Logged In: YES
    Originator: YES

    So the change to display.c has only revealed a problem that was there all along.
    This reference is correctly detected as <global> if cscope does not build an inverted index. With the index, the function scope is set to an empty string. Any clue as to why this happens?

  • Henri de Veer
    Henri de Veer

    Logged In: YES
    Originator: NO

    I found out that the function "putpostingref()" in find.c does not set the "function" array leading (indirectly) to this problem.
    Not all branches evaluate to a valid 'function' result, this will later cause an empty field in the temporary search result causing the above mentioned empty field.

    The code fragment from putpostingref() :

    if \(p-&gt;fcnoffset == 0\) \{
        if \(p-&gt;type == FCNDEF\) \{ /\* need to find the function name \*/
            if \(dbseek\(p-&gt;lineoffset\) \!= -1\) \{
        else if \(p-&gt;type \!= FCNCALL\) \{
            strcpy\(function, global\);
    else if \(p-&gt;fcnoffset \!= lastfcnoffset\) \{
        if \(dbseek\(p-&gt;fcnoffset\) \!= -1\) \{
            fetch\_string\_from\_dbase\(function, sizeof\(function\)\);
            lastfcnoffset = p-&gt;fcnoffset;

    The 'p->fcnoffset == 0' is true but the 'p->type' is FCNCALL.
    When this happens the "function" variable is not set!

    When I add the next line to to function (at the beginning) to avoid an empty function:


    The display problem vanishes, but the root cause is not yet known to me.

    What i also saw is that it is related to the inverted index and has to do with duplicate (external?) definitions in different files.

    Anyone an idea what is really wrong?

  • Same thing happens with Apple’s mDNSResponder source when searching for mDNS_Init.

  • The following patch fixes an instance of this bug where the first match is in a header file which causes the "function" variable to remain uninitialized and thus generates a "temp1" file with a first line that is missing function name. A little ugly, but it fixes this instance of the problem.

    --- find.c 2006-08-20 12:15:54.000000000 -0700
    +++ /home/jrosser/src/bugfixes/cscope-15.7/find.c 2009-03-05 10:46:50.972195000 -0800
    @@ -1118,7 +1118,9 @@ getposting(void)
    static void
    putpostingref(POSTING *p, char *pat)
    - static char function[PATLEN + 1]; /* function name */
    + // initialize function to "unknown" so that the first line of temp1
    + // is properly formed if symbol matches a header file entry first time
    + static char function[PATLEN + 1] = "unknown";/* function name */

    if (p->fcnoffset == 0) {
    if (p->type == FCNDEF) { /* need to find the function name */


  • Anonymous

    Why has this bugfix not been merged? This is a really annoying bug.

    Last edit: Anonymous 2014-03-16
  • Neil Horman
    Neil Horman

    • assigned_to: Neil Horman
    • Group: -->
  • Bill Lash
    Bill Lash


    Thanks for fixing this. I had seen this happen before, but never looked into it further.

    One question about the change. Is there a reason why you initialixed the value to "unknown" instead of "<global>"? the output without using -q says global:

    >cvs/cscope/src/cscope -k -L0 ip_append_data ip.h
    ip.h <global> 116 int ip_append_data(struct sock sk, struct flowi4 fl4,

    >cvs/cscope/src/cscope -k -q -L0 ip_append_data ip.h
    ip.h unknown 116 int ip_append_data(struct sock sk, struct flowi4 fl4,

    Last edit: Bill Lash 2014-05-30