Skip to content

Commit

Permalink
vfio-pci/nvlink2: Fix ancient gcc warnings
Browse files Browse the repository at this point in the history
Using the {0} construct as a generic initializer is perfectly fine in C,
however due to a bug in old gcc there is a warning:

  + /kisskb/src/drivers/vfio/pci/vfio_pci_nvlink2.c: warning: (near
initialization for 'cap.header') [-Wmissing-braces]:  => 181:9

Since for whatever reason we still want to compile the modern kernel
with such an old gcc without warnings, this changes the capabilities
initialization.

The gcc bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119

Fixes: 7f92891 ("vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] subdriver")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Alexey Kardashevskiy authored and Alex Williamson committed Jan 23, 2019
1 parent 33e5ee7 commit 9a71ac7
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions drivers/vfio/pci/vfio_pci_nvlink2.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ static int vfio_pci_nvgpu_add_capability(struct vfio_pci_device *vdev,
struct vfio_pci_region *region, struct vfio_info_cap *caps)
{
struct vfio_pci_nvgpu_data *data = region->data;
struct vfio_region_info_cap_nvlink2_ssatgt cap = { 0 };

cap.header.id = VFIO_REGION_INFO_CAP_NVLINK2_SSATGT;
cap.header.version = 1;
cap.tgt = data->gpu_tgt;
struct vfio_region_info_cap_nvlink2_ssatgt cap = {
.header.id = VFIO_REGION_INFO_CAP_NVLINK2_SSATGT,
.header.version = 1,
.tgt = data->gpu_tgt
};

return vfio_info_add_capability(caps, &cap.header, sizeof(cap));
}
Expand Down Expand Up @@ -361,18 +361,18 @@ static int vfio_pci_npu2_add_capability(struct vfio_pci_device *vdev,
struct vfio_pci_region *region, struct vfio_info_cap *caps)
{
struct vfio_pci_npu2_data *data = region->data;
struct vfio_region_info_cap_nvlink2_ssatgt captgt = { 0 };
struct vfio_region_info_cap_nvlink2_lnkspd capspd = { 0 };
struct vfio_region_info_cap_nvlink2_ssatgt captgt = {
.header.id = VFIO_REGION_INFO_CAP_NVLINK2_SSATGT,
.header.version = 1,
.tgt = data->gpu_tgt
};
struct vfio_region_info_cap_nvlink2_lnkspd capspd = {
.header.id = VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD,
.header.version = 1,
.link_speed = data->link_speed
};
int ret;

captgt.header.id = VFIO_REGION_INFO_CAP_NVLINK2_SSATGT;
captgt.header.version = 1;
captgt.tgt = data->gpu_tgt;

capspd.header.id = VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD;
capspd.header.version = 1;
capspd.link_speed = data->link_speed;

ret = vfio_info_add_capability(caps, &captgt.header, sizeof(captgt));
if (ret)
return ret;
Expand Down

0 comments on commit 9a71ac7

Please sign in to comment.