• Arnd Bergmann's avatar
    media: usbvision-i2c: fix format overflow warning · d82cf248
    Arnd Bergmann authored
    gcc-7 notices that we copy a fixed length string into another
    string of the same size, with additional characters:
    
    drivers/media/usb/usbvision/usbvision-i2c.c: In function 'usbvision_i2c_register':
    drivers/media/usb/usbvision/usbvision-i2c.c:190:36: error: '%d' directive writing between 1 and 11 bytes into a region of size between 0 and 47 [-Werror=format-overflow=]
      sprintf(usbvision->i2c_adap.name, "%s-%d-%s", i2c_adap_template.name,
                                        ^~~~~~~~~~
    drivers/media/usb/usbvision/usbvision-i2c.c:190:2: note: 'sprintf' output between 4 and 76 bytes into a destination of size 48
    
    Using snprintf() makes the code more robust in general, but will still
    trigger a possible warning about truncation in the string.
    We know this won't happen as the template name is always "usbvision", so
    we can easily avoid the warning as well by using this as the format string
    directly.
    Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
    Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
    d82cf248
usbvision-i2c.c 11.4 KB