u32->u16 how can I catch this?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a kernel module, with problems like this:
u32 b;
u16 a;

a = b;

I want to catch all such situation, and change type of  "a" to u32.

But how can I do that,
my simple test tell me that at least gcc 4.1.x can not catch such error:
$cat gcc-wrap.c
#include <stdint.h>
#include <stdio.h>

static void f(uint16_t v)
{
       printf("%s: %u\n", __FUNCTION__, (unsigned int)v);
}

int main()
{
       uint32_t a = 1 << 17;
       uint16_t b = a;

       printf("%lu, %lu\n", (unsigned long)a, (unsigned long)b);
       f(b);
       return 0;
}

$gcc -Wall gcc-wrap.c

do not produce any error.

So my questions,
a)is any option for gcc to produce warning about such casts?
b)How can I play with gcc options for particular file,
something like
$make CFLAGS="-Wall -Wconversion" drivers/.../file.o
c)icc can catch such situations, can I use it for particular file?

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux