Search code examples
cutf-8kernelembedded

Error "error: stray '\302' "in program for this Linux kernel code


I have the following piece of code (kernel code to be more specific):

static int is_sram_locked(void)
{
if (OMAP2_DEVICE_TYPE_GP == omap_type()) {
    /* RAMFW: R/W access to all initiators for all qualifier sets */
    if (cpu_is_omap242x()) {
        __raw_writel(0xFF, OMAP24XX_VA_REQINFOPERM0); /* all q-vects */
        __raw_writel(0xCFDE, OMAP24XX_VA_READPERM0);  /* all i-read */
        __raw_writel(0xCFDE, OMAP24XX_VA_WRITEPERM0); /* all i-write */
    }
    if (cpu_is_omap34xx() && !cpu_is_am33xx()) {
        __raw_writel(0xFFFF, OMAP34XX_VA_REQINFOPERM0); /* all q-vects */
        __raw_writel(0xFFFF, OMAP34XX_VA_READPERM0);  /* all i-read */
        __raw_writel(0xFFFF, OMAP34XX_VA_WRITEPERM0); /* all i-write */
        __raw_writel(0x0, OMAP34XX_VA_ADDR_MATCH2);
        __raw_writel(0xFFFFFFFF, OMAP34XX_VA_SMS_RG_ATT0);
    }
    return 0;
} else
    return 1; /* assume locked with no PPA or security driver */
}

This is copy-pasted from Sublime Text 3, and as the title states, I get the following compilation error:

error: stray '\302' in program error: stray '\273' in program

On lines that start with __raw_writel( ... )

I have done research about the problem and I found out that this error tells me that there is an unprintable character on the line as the cause.

'\302 \273' is UTF-8 code for '»' (RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK)

I read that this problem often appears when you copy-paste code from somewhere else and those unprintable characters may have skipped your attention or your keyboard has a different layout that types strange characters. I inspected the code very closely and I could not find any of those foreign characters.

My big question is: How can kernel code that I have never touched can present such errors? And I have more than one file that comes with this error, which brings me to the fact that there might be something else wrong.

I have figured it out that I get this error on lines that start with anything else but a letter such as : '_' and '.' (these are the examples that rise issues for me so far)

Solutions I have tried:

  • Re-writing the entire lines;
  • Copy-paste the code into many UTF-8 unprintable character filters so I can find the 'stray' characters
  • Unicode Character Highlighter Sublime Text packages

Note: I'm also using Vim as editor and my .vimrc puts '»' as Tabs and '·' as spaces, but only for indentation purposes, not as actual characters. I've fixed some similar errors when I copy-pasted from Vim and those characters were actually in text. I deleted the characters and it got fixed. But for this, I can't identify any 'stray' characters present in the code.

How can I fix it?


Solution

  • The macros were the problem. They referred to some macros I modified with some copy-paste code and completely forgot about it.

    Special thanks to all.