linuxPackages.usbip: fix build with gcc9

+41
+4
pkgs/os-specific/linux/usbip/default.nix
··· 8 8 patches = [ 9 9 # fixes build with gcc8 10 10 ./fix-snprintf-truncation.patch 11 + # fixes build with gcc9 12 + ./fix-strncpy-truncation.patch 11 13 ]; 12 14 13 15 nativeBuildInputs = [ autoconf automake libtool ]; 14 16 buildInputs = [ udev ]; 17 + 18 + NIX_CFLAGS_COMPILE = [ "-Wno-error=address-of-packed-member" ]; 15 19 16 20 preConfigure = '' 17 21 cd tools/usb/usbip
+37
pkgs/os-specific/linux/usbip/fix-strncpy-truncation.patch
··· 1 + diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c 2 + index bb424638d75b..2fc5837e609a 100644 3 + --- a/tools/usb/usbip/libsrc/usbip_common.c 4 + +++ b/tools/usb/usbip/libsrc/usbip_common.c 5 + @@ -226,8 +226,8 @@ int read_usb_device(struct udev_device *sdev, struct usbip_usb_device *udev) 6 + path = udev_device_get_syspath(sdev); 7 + name = udev_device_get_sysname(sdev); 8 + 9 + - strncpy(udev->path, path, SYSFS_PATH_MAX); 10 + - strncpy(udev->busid, name, SYSFS_BUS_ID_SIZE); 11 + + strncpy(udev->path, path, SYSFS_PATH_MAX-1); 12 + + strncpy(udev->busid, name, SYSFS_BUS_ID_SIZE-1); 13 + 14 + sscanf(name, "%u-%u", &busnum, &devnum); 15 + udev->busnum = busnum; 16 + diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c 17 + index 5a3726eb44ab..95b416af8b99 100644 18 + --- a/tools/usb/usbip/libsrc/usbip_device_driver.c 19 + +++ b/tools/usb/usbip/libsrc/usbip_device_driver.c 20 + @@ -91,7 +91,7 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev) 21 + copy_descr_attr16(dev, &descr, idProduct); 22 + copy_descr_attr16(dev, &descr, bcdDevice); 23 + 24 + - strncpy(dev->path, path, SYSFS_PATH_MAX); 25 + + strncpy(dev->path, path, SYSFS_PATH_MAX-1); 26 + 27 + dev->speed = USB_SPEED_UNKNOWN; 28 + speed = udev_device_get_sysattr_value(sdev, "current_speed"); 29 + @@ -110,7 +110,7 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev) 30 + dev->busnum = 0; 31 + 32 + name = udev_device_get_sysname(plat); 33 + - strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE); 34 + + strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE-1); 35 + return 0; 36 + err: 37 + fclose(fd);