]> asedeno.scripts.mit.edu Git - linux.git/commit
hamradio: dmascc: avoid -Wformat-overflow warning
authorArnd Bergmann <arnd@arndb.de>
Wed, 26 Jul 2017 07:55:33 +0000 (09:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Jul 2017 16:32:44 +0000 (09:32 -0700)
commit9877e1058aaf166b578ed44c8e0fc78fe6e67152
treee05433e6e3bbc6a8d744bdc1cf14125d917ac38b
parent67a75194bce07669bf11e14a24a95f64ebde8b47
hamradio: dmascc: avoid -Wformat-overflow warning

gcc warns that the device name might overflow:

drivers/net/hamradio/dmascc.c: In function 'dmascc_init':
drivers/net/hamradio/dmascc.c:584:22: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=]
   sprintf(dev->name, "dmascc%i", 2 * n + i);
drivers/net/hamradio/dmascc.c:584:3: note: 'sprintf' output between 8 and 17 bytes into a destination of size 16
   sprintf(dev->name, "dmascc%i", 2 * n + i);

>From the static data in this file, I can tell that the index is
strictly limited to 16, so it won't overflow. This simply changes
the sprintf() to snprintf(), which is a good idea in general,
and shuts up this warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hamradio/dmascc.c