• Linus Torvalds's avatar
    gcc-10: disable 'restrict' warning for now · dff2ce17
    Linus Torvalds authored
    commit adc71920 upstream.
    
    gcc-10 now warns about passing aliasing pointers to functions that take
    restricted pointers.
    
    That's actually a great warning, and if we ever start using 'restrict'
    in the kernel, it might be quite useful.  But right now we don't, and it
    turns out that the only thing this warns about is an idiom where we have
    declared a few functions to be "printf-like" (which seems to make gcc
    pick up the restricted pointer thing), and then we print to the same
    buffer that we also use as an input.
    
    And people do that as an odd concatenation pattern, with code like this:
    
        #define sysfs_show_gen_prop(buffer, fmt, ...) \
            snprintf(buffer, PAGE_SIZE, "%s"fmt, buffer, __VA_ARGS__)
    
    where we have 'buffer' as both the destination of the final result, and
    as the initial argument.
    
    Yes, it's a bit questionable.  And outside of the kernel, people do have
    standard declarations like
    
        int snprintf( char *restrict buffe...
    dff2ce17
Makefile 59.7 KB