I think I may have found a bug in the C-style code syntax formatter.
To prove this is not a problem with custom styles, this also happens with the built-in styles.
Here's what happens:
All functions after "__init" are formatted without indentation.
Example 1:
crc32 declared after __init. No indentation for crc32.
static void __init moxart_get_mac_address(struct net_device *dev, u8 mac_addr_flash_offset) // Get MAC address stored in flash memory and write it to net_device
{
int i;
for (i=0; i <= 5; i++) dev->dev_addr[i] = inb(IO_ADDRESS(MOXART_FLASH_BASE) + mac_addr_flash_offset + i);
dbg_printk("MOXART Ethernet: finished get_mac_address dev->base_addr=%x\n", (unsigned int) dev->base_addr);
}
static int crc32(char * s, int length) {
int perByte;
int perBit;
const unsigned long poly = 0xedb88320; // crc polynomial
unsigned long crc_value = 0xffffffff; // crc value - preinitialized to all 1's
for (perByte = 0; perByte < length; perByte++) {
unsigned char c;
c = *(s++);
for (perBit = 0; perBit < 8; perBit++) {
crc_value = (crc_value >> 1) ^ (((crc_value ^ c) & 0x01) ? poly : 0);
c >>= 1;
}
}
return crc_value;
}
Example 2:
crc32 now declared before __init. Format indents the code correctly.
static int crc32(char * s, int length) {
int perByte;
int perBit;
const unsigned long poly = 0xedb88320; // crc polynomial
unsigned long crc_value = 0xffffffff; // crc value - preinitialized to all 1's
for (perByte = 0; perByte < length; perByte++) {
unsigned char c;
c = *(s++);
for (perBit = 0; perBit < 8; perBit++) {
crc_value = (crc_value >> 1) ^ (((crc_value ^ c) & 0x01) ? poly : 0);
c >>= 1;
}
}
return crc_value;
}
static void __init moxart_get_mac_address(struct net_device *dev, u8 mac_addr_flash_offset) // Get MAC address stored in flash memory and write it to net_device
{
int i;
for (i=0; i <= 5; i++) dev->dev_addr[i] = inb(IO_ADDRESS(MOXART_FLASH_BASE) + mac_addr_flash_offset + i);
dbg_printk("MOXART Ethernet: finished get_mac_address dev->base_addr=%x\n", (unsigned int) dev->base_addr);
}
Example 3:
crc32 declared after but this time with __init removed. Format indents the code correctly.
static void moxart_get_mac_address(struct net_device *dev, u8 mac_addr_flash_offset) // Get MAC address stored in flash memory and write it to net_device
{
int i;
for (i=0; i <= 5; i++) dev->dev_addr[i] = inb(IO_ADDRESS(MOXART_FLASH_BASE) + mac_addr_flash_offset + i);
dbg_printk("MOXART Ethernet: finished get_mac_address dev->base_addr=%x\n", (unsigned int) dev->base_addr);
}
static int crc32(char * s, int length) {
int perByte;
int perBit;
const unsigned long poly = 0xedb88320; // crc polynomial
unsigned long crc_value = 0xffffffff; // crc value - preinitialized to all 1's
for (perByte = 0; perByte < length; perByte++) {
unsigned char c;
c = *(s++);
for (perBit = 0; perBit < 8; perBit++) {
crc_value = (crc_value >> 1) ^ (((crc_value ^ c) & 0x01) ? poly : 0);
c >>= 1;
}
}
return crc_value;
}
Any idea why this happens? Is there a workaround? "__init" is defined in the linux kernel source as:
#define __init __section(.init.text) __cold notrace