kissste / RTL8710_SDK_Pick_Padding_Checksum

Source code to that replicates Pick, Padding and Checksum binaries of RTL8710, RTL8711 and RTL8195 GCC SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple issues in padding.c

onitake opened this issue · comments

When compiling padding.c on a 64-bit architecture with gcc -Wall -Os, several potential issues are reported:

padding.c: In function ‘main’:
padding.c:23:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
    printf("total %d %s, padding data %x, name %s\n", bufferSize, unit, paddingData, argv[3]);
                  ~^                                  ~~~~~~~~~~
                  %ld
padding.c:50:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("Original size %d\n", originalSize);
                         ~^     ~~~~~~~~~~~~
                         %ld
padding.c:53:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("Padding  size %d\n", paddedSize);
                         ~^     ~~~~~~~~~~
                         %ld
padding.c:63:11: warning: statement with no effect [-Wunused-value]
    result -1;
    ~~~~~~~^~

The "%d" formatting errors should be fixed by replacing them with "%zd" - the type specifier for size_t. %ld should not be used, as that can lead to problems on certain 32-bit architectures.

result -1 should probably be return -1?
Or, replace with result = -1 and do a return result at the end.